800 likes | 965 Views
OBJECT ORIENTED CONCEPTS. OO CONCEPTS Gregory Bors - Tel Aviv Systems Inc. OO Analysis & Design using UML 6/2001. OO Analysis and Design Using UML Subjects. Object Oriented Concepts Modeling & UML Use Case Modeling
E N D
OBJECT ORIENTED CONCEPTS OO CONCEPTSGregory Bors - Tel Aviv Systems Inc. OO Analysis & Design using UML 6/2001
OO Analysis and Design Using UML Subjects • Object Oriented Concepts • Modeling & UML • Use Case Modeling • Responsibility Driven Design & CRC • The Static Model • Behavioral Modeling • Design Principles • Architecture
OO - Concepts • History, Bibliography • OO - Challenges • Object • Class • Encapsulation • Messages • Inheritance • Polymorphism
Milestones in SoftwareDevelopment Technologies Structured Programming 1970 Structured Design 1975 Structured Analysis 1978-1980 Data Modeling 1978-1980 4GL 1980 OOP 1986 CASE 1986 OOAD 1990 OOAD with UML 1997
The Disadvantages of theStructured Technologies Focus onFunctions HighMaintenanceCosts HighDevelopmentCosts RigidArchitecture RippleEffect Very LittleReuse TechnicalCenteredand NotUser Centered No ContinuityAmongAnalysisDesignProgrammingTesting
Bibliography • Object-Oriented Software Construction (second edition): Bertrand Meyer. (Prentice Hall) 1997 • The Unified Modeling Language User Guide: Grady Booch, James Rumbaugh, Ivar Jacobson (Addison Weley) 1998 • Designing Object-Oriented Software: Rebecca Wirfs-Brock, Brian Wilkerson, Lauren Wiener. (Prentice Hall) 1990 • Object-Oriented Modeling and Design: James Rumbough, Michael Blaha, William Permerlani, Frederick Eddy, William Lorensen. (Prentice Hall) 1991 • Object-Oriented Software Engineering - A Use Case Driven Approach: Ivar Jacobson, Magnus Christerson, Patrik Jonsson, Gunnar Overgaard. (Addison Wesley) 1992 • Applying UML and Patterns (second edition): Craig Larman (Prentice Hall) 2001 • Design Patterns - Elements of Reusable Object-Oriented Software: Erich Gamma, Richard Helm, Ralph Johnson, Johan Vlissides.(Addison-Wesley) 1994 • Analysis Patterns: Martin Fowler (Addison-Wesley) 1997 • Internet News Group: comp.object
OO - Concepts • History, Bibliography • OO - Challenges • Object • Class • Encapsulation • Messages • Inheritance • Polymorphism
Maintainability = Harmony of Cause and Effect • Small Change in RequirementsSmall Change in the Software • Small Change in the SoftwareSmall Test to Verify it • Local MishapLocal Effect
To Understand the User • What does he/she really need now? • What is reasonable to expect he/shewill need in the future?
Reuse • Reusing analysis and design concepts • Reusing implementations
Seamless Development • Object orientation enables a smooth and continuous transition among all the development phases
OO - Concepts • History, Bibliography • OO - Challenges • Object • Class • Encapsulation • Messages • Inheritance • Polymorphism
ObjectExample • This glass is an object • It can be • Broken • Filled • Emptied • Its height is 20 cm • It has a leg • It is half full
ObjectExample (cont'd) • This cat is an object • It can • Jump • Run • Say: "meow” • Its color is gray • Its weight is 8 kg • It is a male
ObjectExample (cont'd) • This watch is an object • It can • Display time • Set time • Sound alarm • Set alarm • Its weight is 50 gr. • It is water resistant • Its color is gold
Operation / Behavior • It can • Jump • Run • Say: "meow” • It can be • Broken • Filled • Emptied • It can • Display time • Set time • Sound alarm • Set alarm
Operation/Behavior Operation • What the object can do or what can be done to the object • An operation is one of the featuresof an object Behavior • The behavior of an object: all its operations
Attribute • Its color is . . . • Its weight is . . . • It is a male or female • Its height is . . . • It has / has not a leg • It is x % full . • Its weight is . . . • It is / it is not water resistant • Its color is . . .
Attribute • An attribute of an object describes one of the characteristics of the object • Attributes are features of an object
Value/State • Its color is gray • Its weight is 8 kg • It is a male • Its height is 20 cm • It has a leg • It is half full • Its weight is 50 gr. • It is water resistant • Its color is gold
Value/State • For a particular object, at a specific time,every attribute has a uniquevalue • The state of an object: the values of itsattributes at a given time
An Object - The Whole Story • An object has • Attributes and values of attributes = state • Operations = behavior • An object is characterized by • Its state and behavior
An Object - The Whole Story (cont’d) X A Window _ Behavior MoveSize Minimize MaximizeClose
An Object - The Whole Story (cont’d) Behavior PointLeft ClickLeft Double-ClickRight Click
Kinds of Objects • There are different kinds of objects • Concrete • Conceptual • Event and State
Concrete Objects • These are solid, tangible kinds of objects, things you can grab hold of (be careful how you do that with people objects!) • Concrete objects are easily understood by both analysts and users
Conceptual Objects • These are intangible and often far more difficult to grasp or understand
Event and State Objects These are also highly abstract in nature They are related; an event of significance causes state changes A state can be regarded as a condition or a situation
Object Identity • Every object has an identity • An object’s identity has no meaning beyond the fact that it identifies the object (it is not a name, it is not a key) • Another name for it: a handle • An object’s identity is not a function of its state • If two objects have the same state, they are nevertheless, two objects having two identities
Created State 1 State 2 State 3 Destroyed Object Lifecycle
OO - Concepts • History, Bibliography • OO - Challenges • Object • Class • Encapsulation • Messages • Inheritance • Polymorphism
Class • Class • A group of objects with the same attributes and the same behavior • A class has a name • Class • The abstraction of similar objects • Classification • A process of assigning objects to classes
Examples • Employee Class • Employment Class • Customer Class • Project Class • Strategy Class • Usage Record Class
Object and Class • Every object of a class has the same attributes and the same behavior • But, every object has its own identity and,at a particular moment, is in a state specific to it • An object may be thought of as an instanceof a class
The Class-Object Relationship • A class is a model of its objects • The object uses the functions and the definitions of the class • A class is a Software Factory
Representing Classes and Objects in Software • The whole Software Developmment Life Cycle • We use classes & objects during all the phases of the system development life cycle • A class is a module which defines a specific set of data (attributes) and functions (behavior) • An object is an instance and concrete expression of a class, with a particular state (values of the attributes) at any given moment • There are objects whose existence is limited to that of the lifetime of a transaction (transient objects) and there are objects which are saved in files (persistent objects)
OO-ConceptsQuestions About Objects and Classes • Identify 2 classes that define concrete objectsand 2 classes that define conceptual objectsfrom the domain worlds of your projects • Choose one of the above classes that defineconcrete objects and write down some of itsattributes and some of its operations • Find 2-3 objects of this class and describe their state
OO-ConceptsQuestions About Objects and Classes (cont’d) • Choose one of the classes you identified earlier that defines conceptual objects and write down some of its attributes and some of its operations • Find 2-3 objects of this class and describe their state • Is it possible that a particular class has, as one of its characteristics, only one object? If so, give an example and describe the difference between the class and the object
OO- Concepts • History, Bibliography • OO - Challenges • Object • Class • Encapsulation • Messages • Inheritance • Polymorphism
Encapsulation • Information hiding • All information regarding a module must be private, unless explicitly declared otherwise • Encapsulation • Implementation of information hiding in the world of objects • It is one of the central conceptsof the theory of object orientation
ClassEmployee UpdateAddress Pay IDFirst Name Last NameAddressSalary UpdateSalary Hire Promote Retrieve Fire
Encapsulation • Absolute separation of the implementation (which is hidden) and the interface, i.e. the rules of usage (which is public) • The environment is only aware of the interface
Object Definition An object is an encapsulation of data and processes in such a way that mimics the real world
Encapsulation of Operations Method Operations / Services
Encapsulation of Operations (cont'd) • Operation = Service • Known to the surroundings • Expresses what the object can do for its clients(which may be other objects or human clients) • Method • The implementation of the service • Expresses how the object carries out the service • Note • An object in software is “wiser” than an object in reality • In software it can actively do things relating to itself, which in reality it only passively endures(in software, a glass can fill itself)
Encapsulation of Data Attributes
Encapsulation of Data (cont'd) • The representation of the attributes is hidden • There is no direct access to data,only via operations • Clients of the object’s services only know the signature of the service: the syntax and the semantics of the interface
OO-ConceptsQuestions About Encapsulation • Write down at least 3 advantages of encapsulation • Identify disadvantages and some problems • I have a class: Date • One of the services of this class: Show day in year • This service shows the date in the following format: yyddd • In what format does the class save the datein the database?
OO-ConceptsQuestions About Encapsulation (cont’d) • One of the components of our software is a class named HumanResources • It has persistent objects, each one of them with data about the employees of the company • I was asked to produce an urgent report for management regarding the number of employees below the age of 25 • The class has no service which can provide such an answer • The programmer in charge of the class is on vacation in Damascus • I found out the layout of the employees‘ file and wrote a little program of 15 instructions which reads the file sequentially and by looking at the date-of-birth of each employee produced the report for management • Am I OK? • Should I be promoted or fired?