SlideShare a Scribd company logo
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
DOI : 10.5121/ijait.2014.4602 19
EXACT IMPLEMENTATION OF DESIGN PATTERNS IN
C# LANGUAGE
Viliam Malcher
Faculty of Management, Department of Information Systems, Comenius University
820 05 Bratislava 25, Odbojárov 10, P.O. Box 95, Slovak Republic, Europe
ABSTRACT
A design pattern is a general solution to a commonly occurring problem in software design. It is a
template to solve a problem that can be used in many different situations. Patterns formalize best practices
that the programmer can use to solve common problems when designing an application or systems. In this
article we have focused our attention on it, how the proposed UML diagrams can be implemented in C#
language and whether it is possible to make the diagram implementation in the program code with the
greatest possible precision.
.
KEYWORDS
Design patterns, UML diagrams, C# language, Implementation of design patterns
1. INTRODUCTION
Written program could be flexible, easily maintainable, and reusable, it means might be elegant.
How we know that a program is elegant as it can be? The answer is that a successful programmer
has two primary tools − a good programming language and design patterns.
Design patterns represent some templates to create a program that we can use for some group of
similar tasks. For example, let us consider a picture. We want to add borders and captions to the
picture. Or let us to consider a user and an admin (administrator) type of rights. What do these
things have in common? At a first view it seems that nothing. However, with picture frame and
labels, the picture can be seen as that, which is "decorated" with frames and labels. Similarly,
admin rights can be seen as the user rights, and some rights more. So, the admin rights we do not
have to program from the basic state, it is enough to create admin rights by specifying of the user
– admin rights will be a decoration of user rights. For these types of tasks is proposed a model
called the Decorator [1].
In this paper we discuss how for proposed UML diagrams [2-4] of design patterns can be
implemented programs in C# language exactly as it could be. For some patterns were set up
differently the UML diagrams [5] if we compare it with the GoF [1]. For the pattern represented
by the UML diagram does not exist sufficiently accurate software implementation, so that we can
meet with different implementations of the patterns sometimes. This can reduce their
understanding. Our aim is to show how this can be improved.
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
20
2. DESIGN PATTERNS AND UML DIAGRAMS
In the original work of the GoF group [1] were introduced the 23 design patterns, which are
considered as basic patterns. Every design pattern has a corresponding UML diagram. However,
even for same patterns were established different UML diagrams [5]. Then we have two
problems. The first problem is to determine the UML diagram for the pattern. Most programs are
based on the proposal, which did GoF. The second problem is how make sufficiently accurately
software implementation of the UML diagrams for the design patterns.
Take as an example the Decorator pattern. The GoF have proposed for this pattern following
diagram [1]:
Figure 1. The UML diagram proposed by the GoF group [1]
In the book [1] was given a fragment of code in C++ language, how it could be programmatically
implemented the UML diagram shown in Figure 1. J. Bishop has proposed a slightly modified the
UML diagram for the implementation of the Decorator [5] shown in Figure 2
Fig. 2. The UML diagram for Decorator proposed in the book [5]
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
21
It also were implemented the program code in C# language based on the diagram (Figure 2).
Some parts of the code are problematic in terms of the exact implementation. In the book [5] it
had not been established software implementing of association, aggregation, composition, and
other relations between the classes. Our task is therefore to implement software for the basic
relationships between two classes in C# and based on them to create a C# code of design patterns.
We do it for the Decorator pattern as an example.
The UML diagrams are not often an exact copy of the program. In the diagram are shown
important elements. Accessibility of all attributes and operations are appropriately marked
(private (-), protected (#), public (+)), attributes are usually private and methods are public. Types
associated with the operations are usually not mentioned. If however the types are important, they
can be inserted after the colon. The same procedure is applied for parameters of the methods.
Designing an application using object-oriented programming provides inheritance,
polymorphism, encapsulation, etc. Apart from these concepts, it is very important to understand
some logical concepts along with technical concepts. In this article, we will be discussing some of
the concepts, which we use in most of the classes.
Association. Association is defined as a structural relationship, which conceptually means that the
two classes are linked to each other. In this relationship one class instance uses the other class
instance or vice-versa, or both may be using each other. But the main point is, that the lifetime of
the instances of two classes are independent of each other and there is no ownership between two
classes.
Consider an example of Student-Teacher relationship. Conceptually speaking, each student can
be associated to multiple teachers and each teacher can associate to multiple students. We have
two classes Student and Teacher having the association relationship. Both classes are on an equal
level, there is no ownership. This means that it is not possible to create an object instance of the
class in the second class. On the other hand, the Student class can call the methods, which are
present in the class Teacher, this reflects the direction of the arrow in the diagram. The class
Teacher will not call the method created in the Student class. We make an implementation of this
relationship in C# language as follows:
using System;
class Program {
class Teacher {
public void MethodT() { }
}
class Student {
public Student(Teacher t) {
t.MethodT();
}
}
static void Main() {
Teacher t = new Teacher();
Student s = new Student(t);
Console.ReadLine();
}
}
Listing 1: The association relation between classes
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
22
The diagram for the association is shown in Figure 3
Figure 3. The UML diagram for the association
The constructors, properties, and void in methods we will not showed in the diagram.
Aggregation. In the case of aggregation each object has its own life cycle. The diagram that
represents the type of aggregation relationship shows a line at the end of which is empty diamond.
Let us consider an example of two classes Person and Address, that are related the aggregation.
We propose for it the following structural code in C#:
using System;
class Program {
class Address { }
class Person {
Address address;
public Person(Address a) {
address = a;
}
}
static void Main() {
Address address = new Address();
Person person = new Person(address);
Console.ReadLine();
}
}
Listing 2: The aggregation relation between classes
The design of diagram for the aggregation reads:
Figure 4. The UML diagram for the aggregation
It should be noted here that the address object is created outside of the class Person.
Composition. In the case of the composition a child object has no its life cycle, and if its parent
object is removed, the child object will also be deleted. Let us take an example of the relationship
between a house and a room. The house can contain multiple rooms, there is no independent
living room and each room can not belong to two different houses. If we delete the house, the
room will be automatically removed. Thus, this object will be canceled if canceled an object of
house type. The implementation of the composition by C# language is as follows
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
23
using System;
using System.Collections;
class Program {
class Room {
string roomType;
public Room(string roomType) {
this.roomType = roomType;
}
public string RoomType {
get { return roomType; }
}
}
class House {
ArrayList roomList = new ArrayList();
public void CreateRoom(string roomType){
Room r = new Room(roomType);
roomList.Add(r.RoomType);
}
}
static void Main() {
House myHouse = new House();
myHouse.CreateRoom("dining Room");
myHouse.CreateRoom("bathroom");
Console.ReadLine();
}
}
Listing 3: The composition relation between classes
The diagram design for the composition reads:
Figure 5. The UML diagram for the composition
If you take as an example of house and room, it would make sense to say that the room is part of
house; the room life is designed lifetime of the house. If the house is destroyed, the rooms are
destroyed along with it.
Dependency. This relationship exists between two classes if a change in the definition of one may
cause change to the other. The relationship is display by a dashed line with an open arrow:
Figure 6. The UML diagram for the dependency
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
24
The implementation of this diagram for the dependency could be as follows:
using System;
class Program {
class B {
public string MethodB() {
return "MethodB is called";
}
}
class A {
public B MethodA() {
return new B();
}
}
static void Main() {
B b;
A a = new A();
b = a.MethodA();
Console.WriteLine(b.MethodB());
Console.ReadKey();
}
}
Listing 4: The example of the dependency
The above implementation in C# language of the basic relationship between two classes now
enables us to create a software of the design patterns. We have constructed the basic building
blocks a they can by used for more complicated diagrams. Let us consider the following diagram
(the Decorator pattern):
Figure 7. The UML diagram of the Decorator with an interface
We have defined the basic rules above for the constructing of the basic diagrams and it means in
the C# language the code reads
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
25
using System;
class Program {
interface IComponent {
string Operation();
}
class Component : IComponent {
public string Operation() {
return "I am walking";
}
}
class Decorator : IComponent {
IComponent component;
public Decorator(IComponent c) {
component = c;
}
public string Operation() {
string s = component.Operation();
s += " and listening my music";
return s;
}
public string AddedBehavior() { }
}
static void Main() {
IComponent component = new Component();
IComponent c = new Decorator(component);
Console.WriteLine(c.Operation());
Console.ReadLine();
}
}
Listing 5: The Decorator pattern
3. CONCLUSIONS
We have shown that if we define the programs for the basic relationships between two classes, it
is possible to achieve more accurate software implementations of the UML diagram. We can also
create diagrams for the designed software, which allow us to keep the software in a graphic form
in the documents. Really, we can more exactly make the program implementation from designed
the UML diagrams [6,7], and after further filled some elements in the diagrams this state could be
still improved.
REFERENCES
[1] E. Gamma., R. Helm, R. Johnson, and J. O. Vlissides, Design Patterns: Elements of Reusable Object-
Oriented Software, M. A. Addison-Wesley, Boston, 1995.
[2] J. Rumbaugh, I. Jacobson, G. Booch, The Unified Modeling Language Reference Manual, Addison-
Wesley Longman, Inc., 1999.
[3] M. Fowler, UML destilled, 3th ed., Addison-Wesley, Pearson Education, Inc., 2004.
[4] J. Arlow, and I. Neustadt, UML and the Unified Process, Pearson Education Limited, 2002.
[5] J. Bishop, C# 3.0 Design Patterns, O’Reilly Media, Inc., 2007.
[6] Ch. G. Lasater, Design Patterns, Wordware Publishing, Inc., 2007.
[7] McC. J. Smith, Elemental Design Patterns, Person Education, Inc., 2012.
International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014
26
AUTHOR
Viliam Malcher born in Bratislava, Slovak Republic. He graduated from the Faculty of
Mathematics, Physics and Informatics, Comenius University, Bratislava, in 1981. From
1983 he was engaged in the industry as a researcher. After he received PhD degree in
1995 worked in Computer Centre at Comenius University and from 2001 in Analytical
Laboratories as IT worker. In this time he joined the Faculty of Management,
Department of Information Systems at Comenius University. He is now a teacher and an
associate professor. His research interests include programming, mainly on the .NET
platform, object oriented analysis, and quantum computing.

More Related Content

What's hot

Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
Dr Anjan Krishnamurthy
 
Uml lecture
Uml lectureUml lecture
Uml lecture
Inocentshuja Ahmad
 
An integration of uml use case diagram and activity diagram with Z language f...
An integration of uml use case diagram and activity diagram with Z language f...An integration of uml use case diagram and activity diagram with Z language f...
An integration of uml use case diagram and activity diagram with Z language f...
IJECEIAES
 
Towards a semantic for uml activity diagram based on institution theory for i...
Towards a semantic for uml activity diagram based on institution theory for i...Towards a semantic for uml activity diagram based on institution theory for i...
Towards a semantic for uml activity diagram based on institution theory for i...
csandit
 
Uml basics
Uml basicsUml basics
Uml basics
NageswaraRao k
 
OO Development 4 - Object Concepts
OO Development 4 - Object ConceptsOO Development 4 - Object Concepts
OO Development 4 - Object Concepts
Randy Connolly
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
mekhap
 
UML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework HelpUML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework Help
Jacob William
 
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELINGPYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
ijseajournal
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
mewaseem
 
Unified Modeling Language
Unified Modeling LanguageUnified Modeling Language
Unified Modeling Language
surana college
 
Csc1100 elements of programming (revised july 2014) 120lh-2-student
Csc1100 elements of  programming (revised july 2014) 120lh-2-studentCsc1100 elements of  programming (revised july 2014) 120lh-2-student
Csc1100 elements of programming (revised july 2014) 120lh-2-student
IIUM
 
UML Class Diagram Notation
UML Class Diagram NotationUML Class Diagram Notation
UML Class Diagram Notation
adnan12345678
 
Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UML
artgreen
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
Richa Gupta
 
class diagram
class diagramclass diagram
class diagram
Shohan Ean
 
Uml Diagrams for Web Developers
Uml Diagrams for Web DevelopersUml Diagrams for Web Developers
Uml Diagrams for Web Developers
Dave Kelleher
 
Uml class Diagram
Uml class DiagramUml class Diagram
Uml class Diagram
Satyamevjayte Haxor
 
Uml Tutorial
Uml TutorialUml Tutorial
Uml Tutorial
AkramWaseem
 

What's hot (19)

Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
 
Uml lecture
Uml lectureUml lecture
Uml lecture
 
An integration of uml use case diagram and activity diagram with Z language f...
An integration of uml use case diagram and activity diagram with Z language f...An integration of uml use case diagram and activity diagram with Z language f...
An integration of uml use case diagram and activity diagram with Z language f...
 
Towards a semantic for uml activity diagram based on institution theory for i...
Towards a semantic for uml activity diagram based on institution theory for i...Towards a semantic for uml activity diagram based on institution theory for i...
Towards a semantic for uml activity diagram based on institution theory for i...
 
Uml basics
Uml basicsUml basics
Uml basics
 
OO Development 4 - Object Concepts
OO Development 4 - Object ConceptsOO Development 4 - Object Concepts
OO Development 4 - Object Concepts
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
 
UML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework HelpUML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework Help
 
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELINGPYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
PYFML- A TEXTUAL LANGUAGE FOR FEATURE MODELING
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
 
Unified Modeling Language
Unified Modeling LanguageUnified Modeling Language
Unified Modeling Language
 
Csc1100 elements of programming (revised july 2014) 120lh-2-student
Csc1100 elements of  programming (revised july 2014) 120lh-2-studentCsc1100 elements of  programming (revised july 2014) 120lh-2-student
Csc1100 elements of programming (revised july 2014) 120lh-2-student
 
UML Class Diagram Notation
UML Class Diagram NotationUML Class Diagram Notation
UML Class Diagram Notation
 
Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UML
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
class diagram
class diagramclass diagram
class diagram
 
Uml Diagrams for Web Developers
Uml Diagrams for Web DevelopersUml Diagrams for Web Developers
Uml Diagrams for Web Developers
 
Uml class Diagram
Uml class DiagramUml class Diagram
Uml class Diagram
 
Uml Tutorial
Uml TutorialUml Tutorial
Uml Tutorial
 

Viewers also liked

Integrated report-banner
Integrated report-bannerIntegrated report-banner
Integrated report-banner
Faruque Hossain Mozumder
 
Tổ ấm Sunview town
Tổ ấm Sunview townTổ ấm Sunview town
Tổ ấm Sunview town
NTNTuyen
 
Erick Mol livro digital
Erick Mol livro digitalErick Mol livro digital
Erick Mol livro digital
Erick Roberto Mol
 
Institucionalizando la empresa familiar
Institucionalizando la empresa familiarInstitucionalizando la empresa familiar
Institucionalizando la empresa familiar
FamiliasEmprendedoras
 
Ejercicios capitulo 6
Ejercicios capitulo 6Ejercicios capitulo 6
Ejercicios capitulo 6
Marilyn Jaramillo
 
Salud Reproductivae Enf. Transmision Sexual
Salud Reproductivae Enf. Transmision SexualSalud Reproductivae Enf. Transmision Sexual
Salud Reproductivae Enf. Transmision Sexual
abrahamjair
 
Fines, autonomía y descentralizacion municipal
Fines, autonomía y descentralizacion municipalFines, autonomía y descentralizacion municipal
Fines, autonomía y descentralizacion municipal
franksvdt
 
Radio broadcasting process
Radio broadcasting processRadio broadcasting process
Radio broadcasting process
Harish Awasthi
 
Ruang 8- Kasus 1 Modul Penurunan Kesadaran
Ruang 8- Kasus 1 Modul Penurunan KesadaranRuang 8- Kasus 1 Modul Penurunan Kesadaran
Ruang 8- Kasus 1 Modul Penurunan KesadaranAmelia Manatar
 
Stoa: a Web social na universidade
Stoa: a Web social na universidadeStoa: a Web social na universidade
Stoa: a Web social na universidade
Everton Zanella Alvarenga
 
mangcoban_k07406taminhchau
mangcoban_k07406taminhchaumangcoban_k07406taminhchau
mangcoban_k07406taminhchauVo Oanh
 
Hyatt Airport Exterior Ii
Hyatt Airport Exterior IiHyatt Airport Exterior Ii
Hyatt Airport Exterior Ii
mcbaldwin
 
Denuncia penal
Denuncia penal Denuncia penal
Denuncia penal
José Antonio Artusi
 
Finance and Valuation Basics
Finance and Valuation BasicsFinance and Valuation Basics
Finance and Valuation Basics
Flevy.com Best Practices
 
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...CarmenMarinMartinez
 
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
UNESCO Venice Office
 
Building Highly Scalable and Flexible SaaS Solutions
Building Highly Scalable and Flexible SaaS SolutionsBuilding Highly Scalable and Flexible SaaS Solutions
Building Highly Scalable and Flexible SaaS Solutions
Impetus Technologies
 
Alternatif Değerlendirme Teknikleri
Alternatif Değerlendirme TeknikleriAlternatif Değerlendirme Teknikleri
Alternatif Değerlendirme Teknikleri
huregitim
 
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
Modern Data Stack France
 

Viewers also liked (20)

Integrated report-banner
Integrated report-bannerIntegrated report-banner
Integrated report-banner
 
Tổ ấm Sunview town
Tổ ấm Sunview townTổ ấm Sunview town
Tổ ấm Sunview town
 
Erick Mol livro digital
Erick Mol livro digitalErick Mol livro digital
Erick Mol livro digital
 
Institucionalizando la empresa familiar
Institucionalizando la empresa familiarInstitucionalizando la empresa familiar
Institucionalizando la empresa familiar
 
Ejercicios capitulo 6
Ejercicios capitulo 6Ejercicios capitulo 6
Ejercicios capitulo 6
 
Salud Reproductivae Enf. Transmision Sexual
Salud Reproductivae Enf. Transmision SexualSalud Reproductivae Enf. Transmision Sexual
Salud Reproductivae Enf. Transmision Sexual
 
Fines, autonomía y descentralizacion municipal
Fines, autonomía y descentralizacion municipalFines, autonomía y descentralizacion municipal
Fines, autonomía y descentralizacion municipal
 
Radio broadcasting process
Radio broadcasting processRadio broadcasting process
Radio broadcasting process
 
Ruang 8- Kasus 1 Modul Penurunan Kesadaran
Ruang 8- Kasus 1 Modul Penurunan KesadaranRuang 8- Kasus 1 Modul Penurunan Kesadaran
Ruang 8- Kasus 1 Modul Penurunan Kesadaran
 
Stoa: a Web social na universidade
Stoa: a Web social na universidadeStoa: a Web social na universidade
Stoa: a Web social na universidade
 
mangcoban_k07406taminhchau
mangcoban_k07406taminhchaumangcoban_k07406taminhchau
mangcoban_k07406taminhchau
 
Hyatt Airport Exterior Ii
Hyatt Airport Exterior IiHyatt Airport Exterior Ii
Hyatt Airport Exterior Ii
 
Denuncia penal
Denuncia penal Denuncia penal
Denuncia penal
 
Finance and Valuation Basics
Finance and Valuation BasicsFinance and Valuation Basics
Finance and Valuation Basics
 
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...
El Lissitzky. The experience of totality. MART-Museo di Arte Moderna e Contem...
 
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
Education and Outreach: towards Whom and at What Level? [Djafer Benachour, Un...
 
sisvsp2012_sessione3_da valle_faustini_tessitore_valentini
sisvsp2012_sessione3_da valle_faustini_tessitore_valentinisisvsp2012_sessione3_da valle_faustini_tessitore_valentini
sisvsp2012_sessione3_da valle_faustini_tessitore_valentini
 
Building Highly Scalable and Flexible SaaS Solutions
Building Highly Scalable and Flexible SaaS SolutionsBuilding Highly Scalable and Flexible SaaS Solutions
Building Highly Scalable and Flexible SaaS Solutions
 
Alternatif Değerlendirme Teknikleri
Alternatif Değerlendirme TeknikleriAlternatif Değerlendirme Teknikleri
Alternatif Değerlendirme Teknikleri
 
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
Hug france - Administration Hadoop et retour d’expérience BI avec Impala, lim...
 

Similar to Exact implementation of design patterns in

Design patterns in_c_sharp
Design patterns in_c_sharpDesign patterns in_c_sharp
Design patterns in_c_sharp
Cao Tuan
 
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
ijseajournal
 
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
ijseajournal
 
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
journalBEEI
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
Michael Heron
 
event driven programing course for all.pdf
event driven programing course for all.pdfevent driven programing course for all.pdf
event driven programing course for all.pdf
addisu67
 
Andy Bulka Pattern Automation
Andy Bulka Pattern AutomationAndy Bulka Pattern Automation
Andy Bulka Pattern Automation
tcab22
 
Apostila UML
Apostila UMLApostila UML
Apostila UML
landergustavo
 
UML Design.pptx
UML Design.pptxUML Design.pptx
UML Design.pptx
Md. Nazmus Saqib Khan
 
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docxPhase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
randymartin91030
 
Object Oriented Database
Object Oriented DatabaseObject Oriented Database
Object Oriented Database
Megan Espinoza
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
Abefo
 
Systems variability modeling a textual model mixing class and feature concepts
Systems variability modeling a textual model mixing class and feature conceptsSystems variability modeling a textual model mixing class and feature concepts
Systems variability modeling a textual model mixing class and feature concepts
ijcsit
 
Diagramming the Class Diagram: Toward a Unified Modeling Methodology
Diagramming the Class Diagram: Toward a Unified Modeling Methodology Diagramming the Class Diagram: Toward a Unified Modeling Methodology
Diagramming the Class Diagram: Toward a Unified Modeling Methodology
IJCSIS Research Publications
 
Model versioning in context of living
Model versioning in context of livingModel versioning in context of living
Model versioning in context of living
ijseajournal
 
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
IJCSEA Journal
 
Uml
UmlUml
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
IJCSEA Journal
 
A natural language requirements engineering approach for mda
A natural language requirements engineering approach for mdaA natural language requirements engineering approach for mda
A natural language requirements engineering approach for mda
IJCSEA Journal
 
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
IJCSEA Journal
 

Similar to Exact implementation of design patterns in (20)

Design patterns in_c_sharp
Design patterns in_c_sharpDesign patterns in_c_sharp
Design patterns in_c_sharp
 
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
DOOML: A NEW DATABASE & OBJECT-ORIENTED MODELING LANGUAGE FOR DATABASE-DRIVEN...
 
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
DOOML: A New Database & Object-Oriented Modeling Language for Database-Driven...
 
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
Improving Consistency of UML Diagrams and Its Implementation Using Reverse En...
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
event driven programing course for all.pdf
event driven programing course for all.pdfevent driven programing course for all.pdf
event driven programing course for all.pdf
 
Andy Bulka Pattern Automation
Andy Bulka Pattern AutomationAndy Bulka Pattern Automation
Andy Bulka Pattern Automation
 
Apostila UML
Apostila UMLApostila UML
Apostila UML
 
UML Design.pptx
UML Design.pptxUML Design.pptx
UML Design.pptx
 
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docxPhase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
Phase 2 - Task 1Task TypeDiscussion BoardDeliverable Length.docx
 
Object Oriented Database
Object Oriented DatabaseObject Oriented Database
Object Oriented Database
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
 
Systems variability modeling a textual model mixing class and feature concepts
Systems variability modeling a textual model mixing class and feature conceptsSystems variability modeling a textual model mixing class and feature concepts
Systems variability modeling a textual model mixing class and feature concepts
 
Diagramming the Class Diagram: Toward a Unified Modeling Methodology
Diagramming the Class Diagram: Toward a Unified Modeling Methodology Diagramming the Class Diagram: Toward a Unified Modeling Methodology
Diagramming the Class Diagram: Toward a Unified Modeling Methodology
 
Model versioning in context of living
Model versioning in context of livingModel versioning in context of living
Model versioning in context of living
 
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
 
Uml
UmlUml
Uml
 
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
 
A natural language requirements engineering approach for mda
A natural language requirements engineering approach for mdaA natural language requirements engineering approach for mda
A natural language requirements engineering approach for mda
 
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
A NATURAL LANGUAGE REQUIREMENTS ENGINEERING APPROACH FOR MDA
 

Recently uploaded

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 

Recently uploaded (20)

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 

Exact implementation of design patterns in

  • 1. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 DOI : 10.5121/ijait.2014.4602 19 EXACT IMPLEMENTATION OF DESIGN PATTERNS IN C# LANGUAGE Viliam Malcher Faculty of Management, Department of Information Systems, Comenius University 820 05 Bratislava 25, Odbojárov 10, P.O. Box 95, Slovak Republic, Europe ABSTRACT A design pattern is a general solution to a commonly occurring problem in software design. It is a template to solve a problem that can be used in many different situations. Patterns formalize best practices that the programmer can use to solve common problems when designing an application or systems. In this article we have focused our attention on it, how the proposed UML diagrams can be implemented in C# language and whether it is possible to make the diagram implementation in the program code with the greatest possible precision. . KEYWORDS Design patterns, UML diagrams, C# language, Implementation of design patterns 1. INTRODUCTION Written program could be flexible, easily maintainable, and reusable, it means might be elegant. How we know that a program is elegant as it can be? The answer is that a successful programmer has two primary tools − a good programming language and design patterns. Design patterns represent some templates to create a program that we can use for some group of similar tasks. For example, let us consider a picture. We want to add borders and captions to the picture. Or let us to consider a user and an admin (administrator) type of rights. What do these things have in common? At a first view it seems that nothing. However, with picture frame and labels, the picture can be seen as that, which is "decorated" with frames and labels. Similarly, admin rights can be seen as the user rights, and some rights more. So, the admin rights we do not have to program from the basic state, it is enough to create admin rights by specifying of the user – admin rights will be a decoration of user rights. For these types of tasks is proposed a model called the Decorator [1]. In this paper we discuss how for proposed UML diagrams [2-4] of design patterns can be implemented programs in C# language exactly as it could be. For some patterns were set up differently the UML diagrams [5] if we compare it with the GoF [1]. For the pattern represented by the UML diagram does not exist sufficiently accurate software implementation, so that we can meet with different implementations of the patterns sometimes. This can reduce their understanding. Our aim is to show how this can be improved.
  • 2. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 20 2. DESIGN PATTERNS AND UML DIAGRAMS In the original work of the GoF group [1] were introduced the 23 design patterns, which are considered as basic patterns. Every design pattern has a corresponding UML diagram. However, even for same patterns were established different UML diagrams [5]. Then we have two problems. The first problem is to determine the UML diagram for the pattern. Most programs are based on the proposal, which did GoF. The second problem is how make sufficiently accurately software implementation of the UML diagrams for the design patterns. Take as an example the Decorator pattern. The GoF have proposed for this pattern following diagram [1]: Figure 1. The UML diagram proposed by the GoF group [1] In the book [1] was given a fragment of code in C++ language, how it could be programmatically implemented the UML diagram shown in Figure 1. J. Bishop has proposed a slightly modified the UML diagram for the implementation of the Decorator [5] shown in Figure 2 Fig. 2. The UML diagram for Decorator proposed in the book [5]
  • 3. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 21 It also were implemented the program code in C# language based on the diagram (Figure 2). Some parts of the code are problematic in terms of the exact implementation. In the book [5] it had not been established software implementing of association, aggregation, composition, and other relations between the classes. Our task is therefore to implement software for the basic relationships between two classes in C# and based on them to create a C# code of design patterns. We do it for the Decorator pattern as an example. The UML diagrams are not often an exact copy of the program. In the diagram are shown important elements. Accessibility of all attributes and operations are appropriately marked (private (-), protected (#), public (+)), attributes are usually private and methods are public. Types associated with the operations are usually not mentioned. If however the types are important, they can be inserted after the colon. The same procedure is applied for parameters of the methods. Designing an application using object-oriented programming provides inheritance, polymorphism, encapsulation, etc. Apart from these concepts, it is very important to understand some logical concepts along with technical concepts. In this article, we will be discussing some of the concepts, which we use in most of the classes. Association. Association is defined as a structural relationship, which conceptually means that the two classes are linked to each other. In this relationship one class instance uses the other class instance or vice-versa, or both may be using each other. But the main point is, that the lifetime of the instances of two classes are independent of each other and there is no ownership between two classes. Consider an example of Student-Teacher relationship. Conceptually speaking, each student can be associated to multiple teachers and each teacher can associate to multiple students. We have two classes Student and Teacher having the association relationship. Both classes are on an equal level, there is no ownership. This means that it is not possible to create an object instance of the class in the second class. On the other hand, the Student class can call the methods, which are present in the class Teacher, this reflects the direction of the arrow in the diagram. The class Teacher will not call the method created in the Student class. We make an implementation of this relationship in C# language as follows: using System; class Program { class Teacher { public void MethodT() { } } class Student { public Student(Teacher t) { t.MethodT(); } } static void Main() { Teacher t = new Teacher(); Student s = new Student(t); Console.ReadLine(); } } Listing 1: The association relation between classes
  • 4. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 22 The diagram for the association is shown in Figure 3 Figure 3. The UML diagram for the association The constructors, properties, and void in methods we will not showed in the diagram. Aggregation. In the case of aggregation each object has its own life cycle. The diagram that represents the type of aggregation relationship shows a line at the end of which is empty diamond. Let us consider an example of two classes Person and Address, that are related the aggregation. We propose for it the following structural code in C#: using System; class Program { class Address { } class Person { Address address; public Person(Address a) { address = a; } } static void Main() { Address address = new Address(); Person person = new Person(address); Console.ReadLine(); } } Listing 2: The aggregation relation between classes The design of diagram for the aggregation reads: Figure 4. The UML diagram for the aggregation It should be noted here that the address object is created outside of the class Person. Composition. In the case of the composition a child object has no its life cycle, and if its parent object is removed, the child object will also be deleted. Let us take an example of the relationship between a house and a room. The house can contain multiple rooms, there is no independent living room and each room can not belong to two different houses. If we delete the house, the room will be automatically removed. Thus, this object will be canceled if canceled an object of house type. The implementation of the composition by C# language is as follows
  • 5. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 23 using System; using System.Collections; class Program { class Room { string roomType; public Room(string roomType) { this.roomType = roomType; } public string RoomType { get { return roomType; } } } class House { ArrayList roomList = new ArrayList(); public void CreateRoom(string roomType){ Room r = new Room(roomType); roomList.Add(r.RoomType); } } static void Main() { House myHouse = new House(); myHouse.CreateRoom("dining Room"); myHouse.CreateRoom("bathroom"); Console.ReadLine(); } } Listing 3: The composition relation between classes The diagram design for the composition reads: Figure 5. The UML diagram for the composition If you take as an example of house and room, it would make sense to say that the room is part of house; the room life is designed lifetime of the house. If the house is destroyed, the rooms are destroyed along with it. Dependency. This relationship exists between two classes if a change in the definition of one may cause change to the other. The relationship is display by a dashed line with an open arrow: Figure 6. The UML diagram for the dependency
  • 6. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 24 The implementation of this diagram for the dependency could be as follows: using System; class Program { class B { public string MethodB() { return "MethodB is called"; } } class A { public B MethodA() { return new B(); } } static void Main() { B b; A a = new A(); b = a.MethodA(); Console.WriteLine(b.MethodB()); Console.ReadKey(); } } Listing 4: The example of the dependency The above implementation in C# language of the basic relationship between two classes now enables us to create a software of the design patterns. We have constructed the basic building blocks a they can by used for more complicated diagrams. Let us consider the following diagram (the Decorator pattern): Figure 7. The UML diagram of the Decorator with an interface We have defined the basic rules above for the constructing of the basic diagrams and it means in the C# language the code reads
  • 7. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 25 using System; class Program { interface IComponent { string Operation(); } class Component : IComponent { public string Operation() { return "I am walking"; } } class Decorator : IComponent { IComponent component; public Decorator(IComponent c) { component = c; } public string Operation() { string s = component.Operation(); s += " and listening my music"; return s; } public string AddedBehavior() { } } static void Main() { IComponent component = new Component(); IComponent c = new Decorator(component); Console.WriteLine(c.Operation()); Console.ReadLine(); } } Listing 5: The Decorator pattern 3. CONCLUSIONS We have shown that if we define the programs for the basic relationships between two classes, it is possible to achieve more accurate software implementations of the UML diagram. We can also create diagrams for the designed software, which allow us to keep the software in a graphic form in the documents. Really, we can more exactly make the program implementation from designed the UML diagrams [6,7], and after further filled some elements in the diagrams this state could be still improved. REFERENCES [1] E. Gamma., R. Helm, R. Johnson, and J. O. Vlissides, Design Patterns: Elements of Reusable Object- Oriented Software, M. A. Addison-Wesley, Boston, 1995. [2] J. Rumbaugh, I. Jacobson, G. Booch, The Unified Modeling Language Reference Manual, Addison- Wesley Longman, Inc., 1999. [3] M. Fowler, UML destilled, 3th ed., Addison-Wesley, Pearson Education, Inc., 2004. [4] J. Arlow, and I. Neustadt, UML and the Unified Process, Pearson Education Limited, 2002. [5] J. Bishop, C# 3.0 Design Patterns, O’Reilly Media, Inc., 2007. [6] Ch. G. Lasater, Design Patterns, Wordware Publishing, Inc., 2007. [7] McC. J. Smith, Elemental Design Patterns, Person Education, Inc., 2012.
  • 8. International Journal of Advanced Information Technology (IJAIT) Vol. 4, No. 6, December 2014 26 AUTHOR Viliam Malcher born in Bratislava, Slovak Republic. He graduated from the Faculty of Mathematics, Physics and Informatics, Comenius University, Bratislava, in 1981. From 1983 he was engaged in the industry as a researcher. After he received PhD degree in 1995 worked in Computer Centre at Comenius University and from 2001 in Analytical Laboratories as IT worker. In this time he joined the Faculty of Management, Department of Information Systems at Comenius University. He is now a teacher and an associate professor. His research interests include programming, mainly on the .NET platform, object oriented analysis, and quantum computing.