220 likes | 344 Views
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. Objectives. Define an object Explain in your own words the three pillars of object oriented programming
E N D
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
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
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)
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
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 • Problems with this approach included: • data and procedures were separated • Limits code reuse
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
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
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
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)
OOP Cont’d Activity • What are some of the characteristics and behaviours of a vehicle?
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
OOP Cont’d • The three pillars of OOP are: • Encapsulation • Inheritance • Polymorphism
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
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
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
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)
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
Use Cases • Use cases allow users to documents the requirements of a system • For an excellent treatment of use cases see Sendal & Strohmeier (2001)
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 Sintes, A., “SAMS Teach yourself Object Oriented Programming in 21 days”, Second Edition, SAMS, 2002