Patterns For Software Design

This blog will focus on reflecting on how l have understood my patterns lectures and any other reading material

Saturday, April 22, 2006

Creational Patterns

We did creational patterns in the first two weeks of the course i would say i understood them better than all the othe pattern types .The following are websites that can be visted for furthur reading.

Head First Design Patterns by Eric Freeman And Elizabeth Freeman
www.Dofactory.com
http://home.earthlink.net/~huston2/dp/patterns.html

Wednesday, April 19, 2006

What is UML and The Relationship between Patterns and UML

Definition :UML stands for Unified Modelling Language this is a technique which is used to illustrate or model software systems and help document the system needs as the project is being developed in an easy to understand concept. It is used in Object Oriented Programming .[1]

For other good definitions of UML see:
http://www.netclico.com/support%20glossary/u.html [2]
http://krypton.mnsu.edu/~spiral/eta/glosaary/indexGlossOOxml.html[3]
http://intentsoft.com/technology/glossary/html[4]

When developing software modelling or designing a system before coding and implementation is useful to the developers and users, it allows users to view the design and interaction of the system and make any changes before and during the development of the system. Developers can capture and document requirements needed to develop the system and enable flexible and robust systems to be developed .Designs also help developers to check on the progress and interaction of the system on the documentation and amend the requirements accordingly .[1]

Evolution of UML

1970`s – 1980 :The Object Oriented Languages emerged , developers used the variety of languages in analysis and design though there were several different outcomes for each project .In the late 80`s new languages continuously increased . [5]

Early 1990`s :Due to the problems faced by the developers of not being able to document or desing a system using one uniform Object Oriented Language a suggestion to merge the languages was put forward .[5]

1994 -1997: The decision was approved after the efforts of three men was published and feed back received , on improvements which could be made and incorporated .This helped the software development community to develop a standardised way of representing systems. After feedback and additional research the first version UML1.0 was established ,further research and responses from various companies gave rise to the revised UML 1.1 .The tool has improved continuously up to the present versions being used thus VERSION 1.5 UML and 2.0 UML.[5]

Why Developers Use UML

UML is a tool used to design systems before they are actually developed and coded , it helps software developers to plan for the duration of each task to be done and determine the milestones to be set and when they are to be achieved .The developers can also determine the effort needed in the development of a system thus the number of developers and their skills to complete the system.[2]

Usefulness of UML

· Describes the organisation and relationships of classes and objects in a system.
· When a plan or guide is followed when developing a system it is easy to follow and complete task by task and integrate them .
· High quality software systems are produced when there is an organised pattern to incorporate and follow .[2]
· UML analyses code that has been previously generated and converts it into UML models .
· Templates increase the flexibility in the software development hence the use of UML \diagrams help reduce maintenance cost and manage complexity .
· Standardise communication between (sw)developers .[2]
· It incorporates most of the Object Oriented Languages used to solve design problems hence produces a better solution than using one Object Oriented Language .[2]
· It can be used with any Object Oriented Language thus it is not language specific .

Diagrams Used in UML

Uses different diagrams to represent the same system thus Class , Ucase and Interactive diagrams though they vary in detail.

All these diagrams can be used to design and document a system though am are going to concentrate on Class diagrams .Class diagrams are used in relation with pasterns . The patterns that are used to develop software systems can be described in UML diagrams.
[3]

Notation and Key
Customer
CreditRating()
name: String
address: String
Class Name
Attributes
Operations

Class Diagram Example

Remind()
billForMonth ()
contanctName:String
CreditRating :String Operation
Credit Limit : Double

Cooperate Customer
dispatch()
close Properties
dataRecived : Date
isPrepaid :Boolean
number :string
price: money


Order
name: String
address : String
Creating Ratings
n Multiplicity
1

Customer
Personal customers
Creditcard #:Long integer

Reference:[3] Please Click Reference three to view diagrams

Class Diagrams : Show the relationships and collaboration of classes ,packages and
objects in a system.

Class diagrams describe the following perspective
1. Conceptual – abstract idea
2. Specification –a detailed description of performance
3. Implementation – something used to achieve a purpose

Reference:

1. Applying UML and Patterns : An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition) (Hardcover
2. http://www.netclico.com/support%20glossary/u.html
3. http://atlas.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/history_of_uml.htm
4. http://krypton.mnsu.edu/~spiral/eta/glosaary/indexGlossOOxml.html
5. http://intentsoft.com/technology/glossary/html

Tuesday, April 18, 2006

COMPARISON OF OTHER REUSABLE TOOLS TO PATTERNS

Reusable Components

Looking back at all the lectures we had I have noticed the key element that makes patterns useful in their reusability .There are reusable tools which might be mistaken for patterns though they are just reusable tools, the following paragraphs will briefly explain the differences.

Patterns vs. Business Objects
Patterns

Support modularity in developing software hence system integration is easily done.
Used to illustrate complex projects in a simplified model.
It is a template that is adjusted to suit the developer’s needs.

Business Objects
The majority of objects reused in business applications are native to the development tool and designed by tool manufacturers, not application programmers. If developers confine a project's scope to these native business objects, they can achieve rapid programming and implementation, even for large applications, with quality adequate to meet clear and specific business needs. [3]

They help with the integration of the system. [1]

Patterns vs. Framework

They are a presentation of good design that has been tried, tested and documented.
Patterns are a reusable tool
Patterns are less specialised [2]

Frame work
A frame work is a collection of interacting classes that make up a reusable design for a specific class of software. [2]
The framework facilitates and promotes the reuse of detailed design and code.

Patterns vs. Algorithm
Patterns make use of java code when illustrating the function and collaboration of classes, the illustration can also be done using algorithms. Patterns are not specific on the type of software development problem that they solve. [2]

Algorithms
Algorithms solve mathematical computing problems such as searching and sorting, the sorting and search methods are the same though produce different result when applied to particular problems.

References:

1. Analysis Patterns and Business Objects by Martin Fowler.
2. Patterns and Software Essential Concepts and Technology by Brad Application.
3. Implementing Reuse with RAD Tools' Native Objects John C. Zubeck
4. A Introduction to Patterns Lecture note : Week one

Monday, April 17, 2006

Comparison of Patterns with Packages

One of the tasks we had to do in groups was to establish the differences between other reusable tools and Patterns .The groups were allocated a reusable tool to research on and we had to research on Packages .

I have previously discussed what a pattern is in the previous posting hence will start with discussing Packages .

Definitions :

A packages is self –contained unit of user-defined variable and subroutines ,which can be reused over and over again .

A package is a collection of related types providing access protection and name space management .Note that types refers to classes , interfaces, enumerators and annotations .

A package is a unique named collection of classes .The purpose of grouping the classes is a package with a unique name is to make it easy to add any or all of the classes in a package into your program .

Packages are grouped according to their functionality and usability and all packages should be thought of as independent of one another (They need to be imported into a program to be used).


Uses of Packages

- Importing date and time formats to the program.
- Managing and implementation of networks .
- Producing a variation of graphic user interfaces and images .
- Provides classes and interfaces relating to fonts [1].
- Provides for system input and output through data streams, serialization and the file system[1] .

- Provides the classes and interfaces for the security framework [1].

For detailed explanation on the uses of packages visit the following website it describes different java package extensions and what they are used for. [1]


Advantages of packages

- Easy to maintain as they are a collection of related files put into one directory.
- Easy organises files in a package as a unique naming system is used to name and organise files with same names .
- Help prevent naming conflicts when the same class name for other classes .
- Reliability easy to locate and use class files
- Packages promote collaboration among developers as they are standardised
- Packages are reusable and save time as they reduce the potential number of bugs that might need elimination when programming is redone.

Disadvantages

Once written they can’t be modified where patterns are extensible. [2]

Patterns Vs Packages

A pattern is a concept

package : It`s a piece of software and code

patterns: The concept can be used in any object oriented programming language

Packages are normally written to suit a specific programming language e.g. Java Packages

Patterns are used in the design phase of the Software development life cycle .

To use packages in a particular language one has to be knowledgeable in that language.

Patterns enable programmers to communicate novices to learn and relate as the walkthrough
programs.

Packages can only be imported into the programs but can not be modified by the developers.

Patterns are flexible thus they can be modified with ease.

Patterns are templates or guides as they outline the best possible solution .

Packages are used in the coding phase of the Software development life cycle .

Reference:

[1]

http://java.sun.com/j2se/1.3/docs/api/overview-summary.html


[2]

http://etude.uwaterloo.ca/~swsiu/thesis/node44.html#SECTION007310000000


[3]

Design Patterns Elements of Reusable Object –Oriented Software

NB: Note the next posting is a continuation of the comparison of reusable tools and patterns


Wednesday, April 12, 2006

  • Are Patterns Useful In Software Development

    Refined Definition : A design pattern describes a family of solutions to a software design problem .It consists of one or several software design elements such as modules ,interfaces ,classes ,objects ,methods ,functions ,threads relationships among the elements and a behavioural description .

    Patterns are useful in software development (SD) as they act as templates; they give an outline of solutions on how to solve a recurring problem in a particular context. The major reason of patterns being useful in (SD) would be their reusable characteristic .Patterns are reusable problem solving techniques which have been well tried ,tested and documented as working solutions .Patterns can be used to solve similar problems when they arise in various software development projects.

    In (SD) time management and the effort input are critical elements which need to be monitored to be able to produce software solutions of high quality and on time .As patterns are reusable time and effort are saved and minimised respectively , when developing software the use of sample codes and code snippets help reduce the time spent by developers writing code and debugging it .The testing of the patterns and the documentation will result in developers having reference material of how to apply the patterns when the need arises.

    The effort needed in developing the software could be an increase in the number of developers required in an effort to complete the work on time , the use of patterns will reduce the number of developers needed for a particular task as most tasks are done and documented .

    The use of patterns in (SD) has benefits to both experienced programmers and novices. Patterns are named and organised under 3 different categories in the pattern catalogue, this will facilitate ease of communication between programmers as they use standard names in the programming field .Programmers are able to understand other developers incomplete work that needs finishing by reading through and identifying patterns being used .The use of pattern names is an advantage to novice programmers as they enable them to learn, relate and follow through a program with ease.

    The use of patterns facilitates the development of flexible and easy to maintain software. As patterns also support modularity changes made in module (A) will not affect module (B) hence changes can be done continuously until the software is complete. Flexibility of the software will also determine the ease of maintenance and costs incurred, if the software is flexible and changes can be done before implementation costs of maintenance will be less. The use of sample codes will also reduce the complexity of the work improve quality and overall performance .

    Concluding on the usefulness of patterns not all patterns efficiently address their target problems some situations may require more than one pattern to provide the best solution to a problem. (This is illustrated in the example of building a porch it involves several different patterns hence the same can be concluded for the patterns when developing software).

    Advantages of Patterns in Point Form

    - Reusable solutions that can be used to solve similar problems over and over again.
    - Time and effort saving
    - Work as templates and guides
    - Well tried, tested and documented for ease reference
    - Novice programmers and Programmers are able to learn and follow through a program by using pattern names.
    - Programmers are able to communicate their work through use of pattern names
    - Helps to develop flexible software and lower maintenance costs
    - Reduces complexity of work
    - Can be used with other patterns to solve different problems




Patterns Catalogue Lecture Review

In order for me to understand the vocabulary used in patterns and be able to relate to it instantly , using the general dictionary definitions first has made it a lot easier .

Catalogue Definition

A complete usually alphabetical list of items ,often with a note giving details e.g. Departmental or clothing stores such as Next have a clothing catalogue which show pictures of various items , gives a brief description of the product such as prices and sizes.

Software Design Catalogue

The pattern catalogue shows the number of patterns there are in the book the names and the category that they are classified under .There are 23 software design patterns and they are classified under three categories .The following table shows the different patterns and the categories they are classified under .

Creational Patterns
1. Abstract Factory
2. Builder
3. Factory Method
4. Prototype
5. Singleton

Structural Patterns

6. Adapter
7. Bridge
8. Composite
9. Decorator
10. Façade
11. Flyweight
12. Proxy
Behavioral Patterns

13. Chain Responsibility
14. Command
15. Interpreter
16. Iterator
17. Mediator
18. Memento
19. Observer
20. State
21. Strategy
22.Template Method
23.Visitor


How to Use A Pattern Catalogue (As illustrated by Alexander Christopher)

The following is an example by Alexander Christopher of how to use patterns in the real world . The example used by Alexander looks at how to build a porch applying a combination of different patterns to come up with the best porch . The number of different patterns used or in cooperated to build a porch as illustrated in (The Timeless Way of Building ) by Alexander Christopher clearly shows that a design problem does not always have an accurate solution, but a guide of solving it .


In relation to software development the above example shows that when developing a solution to a problem one design pattern may not solve the entire problem or scenario but it could be used in conjunction with other patterns to produce a the final solution ,though the patterns have to be arranged in a particular sequence and have relationships created that will enable communication between object and classes and solve problem.

Using a Pattern Language (Task by Jane Chandler)

The task which was assigned to us was meant to show us how to use and reference the pattern catalogue , it required us to build a student residential hall using the patterns in Alexander Christopher book (The Timeless Way of Building ).

1. Write Up A paragraph describing the requirements of a small Student Hall of residence .

2.Thinking about the design of the student hall of residence work through Alexander’s instructions on choosing patterns (attached )using his pattern catalogue.

Task 1

A small student hall of residence should have a number of 3 or 4 storey apartments which would house the students and a main entrance or reception as the main access to the hall for security reasons. A dining hall is essential where the students can have all their main meals . A garden would be an essential outdoor space for relaxing .Cycling and pedestrian paths should be networked to allow easy access to the different parts of the building . Finally the student hall should be built in an area that has a good network of public transport to allow students travel to and from college with much ease .

Though the above requirements are summarised they can be further simplified to look at specific details such as bathrooms , lighting of the rooms and storage shelves . The patterns shown in Task 2 below are the one’s my group identified as essential when building the Student Hall of Residence.

Task 2

Pattern Number Pattern Name

16. WEB OF PUBLIC TRANSACTION
21. FOUR STOREY LIMIT
30. ACTIVITY NODES
33. NIGHT LIFE
56. BIKE PATHS AND RACKS
69. PUBLIC OUTDOOR ROOM
88. STREET CAFÉ
89. CORNER GROCERY
92. BUS STOP
103. SMALL PARKING LOTS
106. POSITIVE OUTDOOR SPACE
110. MAIN ENTRANCE
147. COMMUNAL EATING
200. OPEN SHELVES

NB: The next posting will be on how useful are patterns in the development of
software

Tuesday, April 11, 2006

What is a Pattern ?

General Definition

An arrangement of repeated or corresponding parts it could also be referred to as a plan or diagram used to guide in making something using a standard way .
(Collins English dictionary )

Design Patterns Or Software Patterns

Evolution of Design Patterns

Alexander Christopher was a well know town planner who developed construction and building patterns Alexander noticed certain building problems that occurred repeatedly in various building and studied the problematic elements to derive solutions .The solution for each of the identified problem would have a guide or a template of how to solve it though the end results of the use of the solution on different problems would vary .

The Gang of four adapted the principles used by Alexander to solve the construction problems using templates and guides to solve problems in object oriented design .The solutions in solving object oriented designs unlike construction is based on objects ,classes and interface relationships and collaboration .The relationship of classes ,objects and interfaces enables software developers to solve specific problems .

What is a Design Pattern ?

The following are definitions from different website that explain what patterns are .

3 Definitions of A Pattern

Pattern
In software development, a pattern (or design pattern) is a written document that describes a general solution to a design problem that recurs repeatedly in many projects. Software designers adapt the pattern solution to their specific project. Patterns use a formal approach to describing a design problem, its proposed solution, and any other factors that might affect the problem or the solution. A successful pattern should have established itself as leading to a good solution in three previous projects or situations.
In object-oriented programming, a pattern can contain the description of certain objects and object classes to be used, along with their attributes and dependencies, and the general approach to how to solve the problem. Often, programmers can use more than one pattern to address a specific problem. A collection of patterns is called a pattern framework.

(Reference : http://whatis.techtarget.com/definition/0,,sid9_gci214606,00.html)

Pattern

Describes characteristics
Of a recurring problem
And a successful solution
Provides a template to implement the solution
Simple, elegant, reusable, extensible solutions
Patterns define the interaction between objects
Extensible: “No code before its time” Bill J 1996

(Reference: http://www.dotnetcolumbiasc.org/files/Patterns_101.pps)

A "Pattern" is ...

· An abstraction from a concrete form which keeps recurring in specific, non-arbitrary contexts. [generic definition]

· A recurring solution to a common problem in a given context and system of forces. [Alexander]

· A named "nugget" of instructive insight, conveying the essence of a proven solution to a recurring problem in a given context amidst competing concerns.

· A successfully recurring "best practice" that has proven itself in the "trenches".

· A literary format for capturing the wisdom and experience of expert designers, and communicating it to novices .

(Reference : http://www.cmcrossroads.com/bradapp/docs/patterns-nutshell.html#Patterns_What)


Conclusive Pattern Definition

A Pattern describes a family of solutions to a software design problem . It consists of one or more software design elements such as modules ,interfaces ,classes ,objects ,methods ,functions ,processes ,thread relationships among the elements and behavioural description . A pattern will describe how best to solve a problem and provide the consequences it produces or results obtained .


Four Main Elements in a Pattern

The following are descriptions of the four most important elements that make up a pattern and how I understood them.

Pattern Name: The name of a pattern should facilitate ease of communicating solutions between software developers as it would be standard . Pattern names enable good documentation of software solutions .

Problem: This is a description of the situation or problem that needs to be solved in a particular context. The problem that’s occurring will help determine where and how to apply a particular pattern to solve the problem.

Solution: The solution is an organised template, which might consist ,classes ,objects
,interfaces and their relationships . The solution does not solve the problem completely but gives the developer an outline to follow and the rest of the required coding or amendments are
done by the programmer .


Consequences: These are the results or the outcome of applying a pattern to solving a problem. The consequences should be considered an important element as they identify the effectiveness of a pattern in solving a problem .It can give rise to considering in cooperating other related patterns to produce a better result for solving a problem.