Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.

Similar presentations


Presentation on theme: "© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University."— Presentation transcript:

1 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University of the West Indies Session 1 – An Introduction to Object Oriented Analysis and Design Summer 2008

2 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Objectives  Define an object  Explain in your own words the three pillars of object oriented programming  Analyse the requirements of a system and document them using use cases  Design a system using design patterns  Construct UML diagrams for a system

3 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Motivation

4 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Early Days (Sintes 2002)  In the early days of programming, programming languages that were used included: Machine language  Instructions represented as binary numbers Assembly language  Mnemonics used (e.g. LDA #65, which loads the value 65 into a CPU register)

5 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Early Days Cont’d  These earlier languages were error prone  In addition, gathering and documenting requirements has been a challenge Earlier methods included the use of “shall” statements

6 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Early Days Cont’d  A new breed of languages based on procedures were developed, e.g. Fortran A procedure is “a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code “ http://en.wikipedia.org/wiki/Procedure_%28programming%29 http://en.wikipedia.org/wiki/Procedure_%28programming%29  Problems with this approach included: data and procedures were separated Limits code reuse

7 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott The Early Days Cont’d  In order to help to mitigate the problems with procedural languages, modular programming was introduced Programs are decomposed into modules which encapsulate data and procedures An interface allows external programs to access the internal data of the module  The values or meanings of this internal data (variables) define the state of the module

8 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Object Oriented Programming (Sintes 2002)  Object oriented programming (OOP) simply adds inheritance and polymorphism to modular programming  In OOP the problem space is sub-divided into objects Entities with characteristics and behaviours  High level objects then interact by sending messages between each other

9 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d An Example  A simple queue can be represented by an object  This queue will have characteristics and behaviour Is the queue empty? This is a characteristic “Push an item onto the queue” is a behaviour

10 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott An object is an instance of a class

11 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d  “A class defines all the characteristics common to a type of object (Sintes 2002)”  A class is used to instantiate an object  Attributes are characteristics  Behaviour are actions objects perform when passed a message (a method is called)

12 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d Activity  What are some of the characteristics and behaviours of a vehicle?

13 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d  Classes have: Constructors – which initialises an object when it is instantiated Accessors – give access to internal data Mutators – change the state of an object

14 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d  The three pillars of OOP are: Encapsulation Inheritance Polymorphism

15 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d Encapsulation  Uses modules to: Hide implementation details Allow programmers to view software as a black box Publish an interface that lists the services provided by the black box  Encapsulation allows the implementation to be changed without affecting the interface

16 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d Inheritance  Allows a class to be based on another class The new class inherits attributes, behaviours and implementation New attributes and behaviours may be added OR, attributes and behaviours may be overridden  The “Is-a” test – is the inherited class of the same type – tells us whether to use inheritance  If you can not inherit use composition – simply create an instance of the class inside the new class

17 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott OOP Cont’d Polymorphism  This means the state of having many forms A single name can express different behaviours For example using the same method name, many different behaviours are exhibited

18 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Unified Modeling Language (Fowler 2004)  Unified modeling language (UML) is a graphical design notation: Used to communicate and enhance understanding of (OO) systems Provides a high level of abstraction Is an open standard Controlled by the Object Management Group (OMG)

19 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Unified Modeling Language Cont’d  UML has a number of diagram types:  Activity diagram – procedural and parallel behaviour  Class diagram – Class features, relationships  Sequence diagram – Interaction between objects  Use case – user interactions with the system

20 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott Use Cases  Use cases allow users to documents the requirements of a system  For an excellent treatment of use cases see Sendal & Strohmeier (2001) Sendal & Strohmeier (2001)

21 © 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott References Fowler, M., “UML Distilled: A brief guide to the standard object modeling language”, Third Edition, 2004 Sendall, S. & Strohmeier, “Requirements Analysis with Use Cases”, Swiss Federal Institute of Technology in Lausanne, 2001. Available online at http://lgl.epfl.ch/research/use_cases/RE-A2-theory.pdf http://lgl.epfl.ch/research/use_cases/RE-A2-theory.pdf Sintes, A., “SAMS Teach yourself Object Oriented Programming in 21 days”, Second Edition, SAMS, 2002


Download ppt "© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University."

Similar presentations


Ads by Google