Using of Design Patterns in GPS Application


The aim of this paper is to provide guidelines for developing GPS application using design patterns. The paper provides good coding practice and methodology using a database and design patterns in GPS application. GPS software is implemented in language C# using the Observer design pattern.


Keywords: Design Patterns,GPS Application,Observer Pattern



 The Global Positioning System (GPS) is a satellite based navigation system. Initially, GPS was developed as a military system. It was later made available to civilians. GPS provides continuous positioning and timing information, anywhere in the world under any weather conditions. It servers unlimited number of users, and users can only receive the satellite signals [1].

We need to propose a GPS application consists of reading data from a GPS receiver which constantly sends a stream data. Recently, some authors proposed a software for GPS applications based on the design patterns [2] and in the paper [3] it was made a design for the GNSS (Global Navigation Satellite System). The concept of software design was firstly introduced in Gamma et. al. [4], a book that rapidly became a fundamental reference on the topic. Design patterns summarize previous engineering experience with solving typical problem and provide a way for applying reusability at the design level. They generally coding knowledge of design strategies and best practices.

This paper present a software written in language C# based on selected design patterns for GPS application. The data from GPS receiver are not storaged directly to the program but in the database system.



 Design patterns were originally created by the Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) which is responsible for formalizing the design patterns we use today. These authors published a book [4], which initiated the concept of design patterns in software development. The patterns generally have been accepted as “best practices” within development community. Each pattern is presented by a template so we can learn how to apply the patterns. The patterns are effective way to describe solution to complex problems. Design patterns are all about the reuse of solutions. All problems are not equal, but if we can break down a problem and find the similarities with problem that we can solve those solutions.

The design patterns are the most powerful tool for software developer in the last time. It is also important to learn how to apply pattern to specific problem to get the desired result. According to these authors design patterns are primarily based on the following principles of object-oriented design: Program to an interface not an implementation, and favor object composition over inheritance. Since the work by Kernighan et al. [5] there is a concern on the style in writing software and its impact in the quality of the final written program. The original group of patterns was implemented in the era of C++, with some using Smalltalk and reflecting the capabilities of those languages. Java and C# have added significant language new features over the last decade. It seems that programming of the design patterns in C or C++ might be complicated. In C# however, we can easily use the Observer pattern for example. Really, the Observer pattern assume that the object containing the data is separated from the objects that display the data. We use the language C# in programming of GPS application.



Location-based systems are those which exploit the concepts of mobility in context of local environmental conditions, deliver information that is relevant to users in context of their location [6]. A key characteristic of local-based systems is the changing physical location of the mobile user. The location is not only based on triangulation of co-ordinates, by also based on time, where objects move through space and time.

Private sector has an interest in mobile location-base systems. Here are opportunities for travel, social networking, leisure and entertainment. Supporting technology for location-based systems typically includes mobile network platforms for determining location. We can see increasing complexity at higher levels of abstraction in location-based systems. We focus an effort on the use of design patterns to formalize and structure of such systems. We propose a GPS application as a component of location-base system associated with design patterns.

The GPS application consists from reading data from a GPS receiver which constantly sends a stream @GPRMC sentences. An examples of sentence is: $GPRMC, 140036, A, 5226.5059, N, 00207.6806, W, 2.0, 064.64, 120710, 001.0, E*34, where A is navigation receiver warning (A = OK, V = warning), 5226.001.0, N is Latitude (52 deg. 26.5059 min West), 07.6806 min West, 2.0 is speed over grounds (Knots), 064.64 is Cource Mades Good (degrees), 120710 is Date of fix (12 July 2010), 001.0, E is the Magnetic variation (1.0 deg. East), *34 is the mandatory checksum. The application can the continually reads (parse and stores) the sentence as records in a buffer. Those records are then available for the application to read. The application can display three views, a text view, a compass which uses the cource made good part of the sentence, and a breadcrumb trail, which shows the tail as well as minimum height, maximum height send and the ascent (the different between them) [2]. Now we are going to propose a software application based on the design patterns to create the GPS application. We use the Observer pattern and we show as this pattern can be applied to the GPS application.

The Observer pattern defines a one-many dependency between objects so that  object change state all its dependents are notified and updated automatically. The classes and/or objects participating in this pattern are: the subject knows its observes, any number of observer objects may observe the subject. The subject provides an interface for attaching and detaching observer objects. The class ConcreteSubject (see Figure 1 below) sends a notification to its observers when its state is changed. The Observer defines an updating interface for objects that should be notified of changes in a subject. The class ConcreteObserver implements the Observer updating interface. The Observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, The Observer pattern is also a key part in the familiar MVC (Model-View-Controller) architectural pattern. In fact, the Observer pattern was first implemented in Smalltalk’s MVC based user interface framework [4].

GPS application that we create will use the data that are sent from the GPS receiver to the database. This is advantage with respect to the storage of data from the receivers. The data stored in the database are persistent and we can go back to them when watching history records. The data are taken then to the GPS application from the database into an object in the program. The application stores the sentences to the object in the program and displays different views. We use the Observer design pattern for the programming of the GPS application. The Observer pattern can present data in several forms. We often want to display data in more than one form at the same time. When we implement the Observer pattern, we usually refer to the data as the Subject and each of the displays as an Observer. Then each observer has a know interface that the subject calls when the data change.

We have written a program in C# to illustrate how can use this powerful concept based on the Observer design pattern. The structural UML diagram for the GPS application could be as it is shown on the Figure 1:



Fig.1: UML class diagram for the observer pattern.


The C# program code is as follows:

using System;

using System.Collections.Generic;

using System.Data;

using System.Data.OleDb;

class Prg {

abstract class Subject {

List<Observer> observers = new List<Observer>();

public void Attach(Observer observer)   {



public void Detach(Observer observer)  {



public void Notify()  {

foreach (Observer o in observers)




class ConcreteSubject : Subject    {

string subjectState;

public string SubjectState  {

get { return subjectState; }

set { subjectState = value; }



abstract class Observer {

public abstract void Update();


class TextObserver : Observer {

ConcreteSubject subject;

string observerState;


public TextObserver(ConcreteSubject subject) {

this.subject = subject;



public override void Update() {

observerState = subject.SubjectState;

Console.WriteLine(“Observer has a new state {0}”, observerState);

Console.WriteLine(“Here is data in text form”);




static void Main()    {

ConcreteSubject s = new ConcreteSubject();

s.Attach(new TextObserver(s));

string connString = “Provider = Microsoft.ACE.OLEDB.12.0; Data Source=C:\\ABOX\\Archive.accdb”;

string sql = “select * from ArchiveTable”;

OleDbConnection conn = new OleDbConnection(connString);


OleDbCommand cmd = new OleDbCommand(sql, conn);

OleDbDataReader r = cmd.ExecuteReader();

while (r.Read())    {

s.SubjectState = r[0].ToString();








What kind of notification should a subject send to its observers? In our application that all the observers are handled by the string representation. In more realistic situations this might not always be the case, especially if the observers could also be used to observer other data objects.



 The book [6] illustrates how two important contemporary software advances – patterns and UML – can be applied advantageously to the real-time software. In this paper we have shown as the design patterns, namely the concept of the Observer pattern, can be used with the language C# successfully in developing of GPS applications using a database as a data source from GPS receivers.

Design patterns encapsulate experience and formalizing good practices in software development. We have shown as to build the GPS application applying the methodology of design patterns. The use of design patterns brings many benefits in the software development process. Many of the patterns are well documented and categorized according to different criteria. Design patterns support the development of software for the location-based systems.



[1]  El-Rabbany A, Introduction to GP: The Global Positioning System, Artech

House, Inc., Norwood, 2002.

[2]  Gillbrand D., and Hammed K., The Use of Design Patterns on a Location-

       Based GPS Application, IJCSI, Vol.8, Issue 3, No. 1., May, 2011,

[3]  Fernandes-Prades C., Aviles C., Esteve L., Arribas J., Closas P., 5th ESA

Workshop on Satellite Navigation Technologies and European Workshop on

GNSS Signals and Signal Processing, Netherlands, 8-10 December, 2010.

[4] Gamma, E., Helm, R., Johnson, R., and Vlissides, J. Design Patterns:

      Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995.

[5] Kernighan B.W., and Plaugher P.J., The Elements of Programming Style, 2nd

ed., McGraw-Hill Book Company, 1978.

[6] Douglass B.P., Real-Time Design Patterns: Robust Scalable Architecture for

     Real-Time, Addison-Wesley, 2003.



doc. RNDr. Viliam Malcher, PhD.

Faculty of Management

Department of Information Systems

Comenius University

820 05 Bratislava  25

Odbojárov 10

P.O.  Box 95

Slovak Republic (Europe)


RNDr. Igor Odrobina, CSc.

Fakulty of Mathematics

Physics and Informatics

Department of Applied Mathematics and Statistics

Comenius University

842 48 Bratislava 4

Mlynská dolina

Slovak Republic (Europe)



Ing. Jaroslav Vojtechovský, PhD.
Pracovisko: Fakulta managementu UK, Odbojárov 10, Bratislava

prof. RNDr. Michal Greguš, PhD.
Pracovisko: Fakulta managementu UK, Odbojárov 10, Bratislava



Digital Science Magazine, Číslo 2, Ročník V., ISSN: 1339-3782