Object Oriented Programming

Object Web
Bapayya Choudhary Maganti
2-2-647/182/J, C. E. Colony, New Nallakunta, Hyderabad - 500 013. Phone: +91-(0)40-27406781, E-mail:

Course Contents
Object Oriented Background Object Oriented Programming Concepts Analysis
Use Case Modeling

Object Modeling
CRC Class Diagrams

Dynamic Modeling
Sequence Diagram Collaboration Diagram State Diagrams Activity Diagrams

Component Diagram Deployment Diagram

Case Study – Drawing Editor Problem


Object Web
Bapayya Choudhary Maganti
2-2-647/182/J, C. E. Colony, New Nallakunta, Hyderabad - 500 013. Phone: +91-(0)40-27406781, E-mail:

Encapsulation. A language is object oriented if supports the following four proprieties: Abstraction.What Is Object Orientation? Term ‘Object-Orientation’ means. . Polymorphism. Everything here is object and process is sending a message to objects. Inheritance. The organization of software as a collection of discrete objects that incorporate both data structure and behavior. A new technology based on objects and classes. Use of objects and classes in analysis.

. Object-oriented programming refers to the objects with inheritance and polymorphism.Object-based Vs Object-oriented Object-based programming usually refers to objects without inheritance and hence without polymorphism. which provide inheritance and polymorphism. These languages support abstract data types and not classes.

Objects. Simula 67 the first Object Oriented Language. Objects. 1969. 1967. First Graphics Environment. Dynamic Typing. Classes.xerox. Inheritance. . Classes. First Use of Mouse in Programming Environment.com. Inheritance. Form Parc of Xerox Corporation. Dynamic Typing. For more info look at parc. Introduced first Multi Threaded Environment. Talk about the Behavior Centric not Data Centric.What Is the Background? Arrived from Process. Smalltalk first Pure Object Oriented Language.

Objects Type Defined.OO Programming Languages Statically-typed: Memory allocation at compile time No Runtime Class. Object Runtime Inheritance No Data types Example: Smalltalk Both: Example: Java . Example: C++ Dynamically-typed: Memory Allocation at Run-time Runtime Classes.

Statically-Typed: C++ Classic-Ada Dragoon Emerald/Jade Object Pascal Trellis/Owl .

Dynamically-Typed: Actors Language C+@ Flavors Python Self Smalltalk .

Both: Actor Ada95 BETA C++ (With RTTI) Cecil CLOS Eiffel Java Modula-3 Objective-C Sather .

allowing objects to be passed freely between machines. . sometimes all the way down to to the machine.Object-Oriented Operating Systems Object-Oriented Operating Systems provide resources through objects. These are almost always distributed systems (DOS or DPOS).

Peace.Object-Oriented Operating Systems Some of the Object-Oriented Operating Systems: Apertos. Mach. Choices. GEOS. NachOS. Spring. Chorus Micro-kernel. . Ouverture Project.

or object-id and because of support for methods and inheritance.Object-Oriented Databases Object-oriented databases are databases that support objects and classes. . They are different from the more traditional relational databases because they allow structured sub objects. each object has its own identity.

an equivalence that would be lost if an alternative were chosen. OODBs allow all the benefits of objectorientation. . as with a purely relational database.Object-oriented Databases It is also possible to provide relational operations on an object-oriented database. as well as the ability to have a strong equivalence with object-oriented programs.

Objectivity ObjectStore Ontos Odapter/OpenODB program (HP) Unisys Universal Repository Versant VisualWorks OOFILE Phyla. POET Statice UniSQL . Matisse NeoAccess OBST+ O2.List of Object-oriented Databases: Research Systems AVANCE CLOSQL ConceptBase* COOL/COCOON Encore* Exodus* Machiavelli MOOD4-PC* OBST/STONE* Ode* Oggetto Orion OTGen PLOB VODAK Commercial Systems ArtBASE. EasyDB GemStone ITASCA.

Object-oriented Methodologies List of Methodologies: Bernard BON Booch Coad/Yourdon Colbert de Champeaux Embley EVB Rebecca Wirf’s FUSION HOOD IBM Jacobson Martin/Odell Ooram Room Rumbaugh Shlaer and Mellor Open UML Wasserman Wirfs-Brock .

UML Collection of concepts from various methodologies. Started in 1995. RUMBAUGH. Can be adapted for any application. . Current Version 1. From: BOOCH. JACOBSON.3. Adapted by OMG.

9/96 UML 1.UML. Stepping ahead Booch OMT OOSE Others Unified Method 0.8 Start 1/95.9.91 6/96. 0.? Expected Shortly OMG Feedback OMG/RTF Revisions .0 OMG Submission 1/97 Others UML Partners Expertise UML 1.3 RTF report 4/99 UML 1. OOPSLA 10/95 UML 0.1 OMG Revision 9/97 Adoption 11/97 UML 1.

com . New Nallakunta. Phone: +9140-7422414.500 013.Fundamentals Object Web Bapayya Choudhary Maganti 2-2-647/185.objweb. E. C. Web: www. Colony. E-mail: info@objweb. Hyderabad .com.Object Oriented Programming Concepts .

Physical Object An object may be invisible to the human eye but having some basic form of intelligence.What is an Object? The entity which represents something Objects is having a concrete physical form as well as intelligence. Conceptual Object . because we not only perceive them but also make them do something.

SBI/K Object have State. y=50 isFirstQuadrantPoint ( ) Point Object at memory AF00 Knowledge . Identity and Knowledge about Other Objects State is attributes Behavior is methods Identity is uniqness Knowledge is message sent between to objects. State Behaviour Identity x=50. Behavior.

An object is a reality and it is an entity which exists in time and space. We are able to identify it as an object because of its IDENTITY. Identity is that property of an object that distinguishes it from all other objects. We see a lion as a lion and not a horse because of its identity.Identity Each Object is different form other. This is true for all objects in the real world. All Objects Have Identity. (Booch). .

but the are different. the possible outer look may be same but there may be lot of difference between them. two identical twins are nothing but two distinct objects.Identity If we look at any two similar object. . My be two pens are appearing same. Similarly.

.Objects Know Each Other Objects can't behave independently Like humans objects need to know about other objects in the system. Objects are not in isolation We share the world around us with other objects. All objects are intelligent We give them levels of intelligence we would normally associate with humans.

There are two types of communications between objects. The indirect communication. The direct communication.Objects Communicate With Each Other. When a object receives the messages and if the object cannot understand the information then it searches for the object which can understand this and send this message to the other object. . Objects live in a dynamic world where they exchange information and communicate with a number of objects getting certain things done.

The term property denotes attributes. which means that they do not change over a period of time. .Behavior By communication an operation was achieved. Both property and attribute may be used interchangeably. A property is gives uniqueness to Object. The operation placed a certain RESPONSIBILITY. Properties are usually static.

) Unlike objects. data values have no identity. It is important to note here that ATTRIBUTE SHOULD BE A PURE DATA VALUE NOT AN OBJECT. . (Not valid for pure object oriented programming languages.Behavior Attributes have values. An attribute is a data value held by the objects in a grouping of similar objects.

the current state of any object depends on: Preceding State. . Which may cause the properties to undergo changes Current Status = Inherent Properties + Preceding State + Stimulus received + Argument Passed with Stimulus. Therefore.State Preceding each of these state . Object's inherent properties (or attributes). Stimulus received by the object.change is a stimulus (Booch) or event (Rumbaugh) or action (Booch).

its internal properties. .State The State of an object may be defined as: The state of an object at any given instance is determined by the combination of its precedent status. The fact that every object has a state implies that every object takes up some amount of space (either in the physical world or in computer memory). Instance Object Class Object -> -> Instance. the current values of these properties and the stimulus it receives. Now we can define Behavior of an object as: Behavior is how an object acts or reacts in terms of its state changes and message passing. Colloquially the word object is also used to indicate a group of similar objects. Class.

An object is characterized by what it is used for and by the information that is attached to it. by the operation that it can offer to other object in its environment.e. . i..Important Aspects An object with the same name may occur in completely different domains. Use of an object is captured by its behavior. i.e.. attributes. Ex: Customer.

Client Object Server Object . The requirements placed on the server object may have several responsibilities depending upon its use.Client Server Nature of Objects An object uses another object for performing an operation by sending a stimulus. Each stimulus has an unique name that clearly determines the operation to be performed.

The combination of all such signatures of an object is called the objects protocol. therefore will have different 'signatures'. and. Remember an object can perform different operations depending upon usage.Client Server Nature of Objects When a client objects sends a stimuli to a server object. The client knows only the name of the operation to be performed by the server which is sent as the stimuli along with various types of information each operation needs in order to perform the task. The names and types of information are called the operations 'signature'. . the only information that is available to the client object is the type of operation that can be performed by the server object.

which shows how others can use the object and the responsibilities the objects has towards others.Object Description An object can be described in two different. This is also sometimes called the objects specification. This description contains only the objects protocol (how it can be used). but related ways. The external description. . This description is called the objects implementation. The internal description specifies the objects various attributes and how each operation is realized.

More importantly.According to Booch Without this conception framework. but your design is going to smell like a FORTRAN. Eiffel. Pascal or C application. you may be programming in a language such as Smalltalk. You will have missed out on or otherwise abused the expressive power of the objectoriented language you are using for implementation. . you are not likely to have mastered the complexity of the problem at hand. Ada. CLOS. object Pascal. C++.

Polymorphism.Related Concepts: Important concepts & Related Topics: Abstraction. Encapsulation. Generalization. Multi-layer Architecture. . Delegation. Concurrence. Factorization. Composition. Persistence. Refinement.

Abstraction View of the Object Object Web. Bapayya Choudhary Maganti .

processes. Break down large problems into manageable level. Let us consider an example of how 'human beings' may be viewed in different domains.Abstraction One of the two ways humans cope with complex problems to spot Similarities between objects. Domain Viewer Abstraction Biology Biologist Species Politics Politician Vote Bank Industries Manager Resource Food habits Man-eater Food . situations. A viewer abstracts objects in relation to the problem perspective.

There are four metrics to ensure the design of class hierarchy and relations are: Coupling Cohesion Sufficiency Completeness .Abstraction Abstraction is a phenomenon By which a viewer is able to identify unique features or characteristics of an object which separate the object from all other objects in a given problem domain.

Coupling is a measure of the strength of association between two classes. A strong coupling tends to complicate the system in the sense that it will be difficult to modify or change it easily. This complexity can be reduced by designing systems with weakest possible coupling between classes.


Cohesion measures the extent of connectivity among the elements of a single object or class. The most desirable form of cohesion is the FUNCTIONAL COHESION.
i.e. We check if elements comprising an abstraction are truly representative of the behaviors.

You can't abstract an animal and a vehicle if they don't serve the same semantic purpose.
Both animal and vehicle may be abstracted in the class “LoadCarrier” but cannot be abstracted together if we are looking at a race horse and a passenger car.

This means that the class captures in its abstraction all the expected behavior of the class for meaningful interaction. For example
if we are designing a class 'UpdateItem', it makes sense to include an operation that will add an item or remove an item or modify an item. Though this may sound very routine, it has been noticed that many times we neglect or miss out to include all the operations.

Extension of generalization The class should have implemented all the expected abstract or virtual functions of the super class. . In other words the interface should be such that it covers all aspects of the abstraction.Completeness This has two forms Extension of sufficiency A complete class or module is one whose interface is general enough to be commonly usable to any client. The class hierarchy is considered to complete when all the sub classes are defined and the sub-classes are defined as per the minimum expectations of the super class.

Neither too high nor too low. The identification of abstractions involves Knowledge of the problem domain Discovery Invention. We study the problem domain Identify objects which may seem disparate in the beginning Identify their relationship and group them in different classes based on their common characteristics.The Process of Abstraction Booch says Classes and objects should be at the right level of abstraction. The process of abstraction. is incremental and iterative. .

Encapsulation Hide for right Abstraction & Coupling Object Web. Bapayya Choudhary Maganti .

A capsule means something held in a covering.Encapsulation Encapsulation actually means to capsulate. Public Private Protected . What is inside can not be seen. Enclose something or Encapsulate something inside the object.

All objects have two parts The abstracted visible part .e..e.INTERFACE The encapsulated hidden ... the attributes and the implementation details.. the various operations it can perform Encapsulation takes care of how it does it i.IMPLEMENTATION . Encapsulation Abstraction takes care of what an object can do i..

Intelligent encapsulation localizes design decisions that are likely to change.What Is Achieved by Encapsulation? Encapsulation is the process of hiding the representation of an abstraction that make up the structure of a class of objects and their behavior. According to Booch. If the implementation is modified we continue to use the object without any modifications to the interface. .

This may not be possible always. .Refactoring In Refactoring is the process of changing the object without changing the Interface. Refactoring minimizes the changes on other object. Interface is public method defined in Class Note: If an Object need implementation to be modified without changing the interface it is terms ad Refactoring. This process ensures that the classes have right level of coupling and will have minimum/no impact on the collaborating classes.

public inheritance. It is only documentation process to achieve private methods. Java.Achieving Encapsulation Smalltalk. Can define inner classes. which have class scope. Variables and methods can be declared as private public and protected. Variables and methods can be declared as private. . Can have private. C++. Can have package level access modifiers and can mark classes as private to package. By default all attributes are private and methods are public. protected. public and protected.

Different levels of Encapsulation Collaboration level Inheritance level Package level .Why Public. Protected and Private Attributes of class Make sure that all attributes are declared as private and give protected or public access modifiers (get and set methods) Methods of class Make sure that all methods are declared as protected (never private) and only those required as public.

Package level Classes can be defined as public or private to package and this should minimize the coupling between the packages. . Inheritance level Sub class is extension to the existing behavior of the super class and it should be able to access all the behavior of the super class.Level of Encapsulation Collaboration level Between two classes there exists public and private methods where the collaborating class can access only the public behavior of other class but not the private behavior.

Inheritance Specialization & Generalization Object Web. Bapayya Choudhary Maganti .

Generalization and Inheritance. Each individual object in a class is called an INSTANCE of its class. FourWheeler The terms 'instance' and 'object' are interchangeable (for C++) Car Van . Generalization and Specialization are important aspects of Object Orientation which give rise to the concepts of HIERARCHY and INHERITANCE.

Each subclass not only inherits all the features of its superior class. It may augment or restrict the existing structure and behavior of a super-class. Generalization An instance of a subclass is simultaneously an instance of all its ancestor classes.. Classes are related to one another via inheritance relationships.. .. but adds its own specific attributes and operations as well.

. Only the leaf class (or concrete class) will have instances. .. The base class and other intermediary classes usually do not have any instances. The most generalized class is known as the base class. Generalization The most specialized class in a hierarchy is known as the leaf class.. The leaf classes are also known as concrete classes.

. Abstract classes are written with the expectation that its subclasses will add to its structure the behavior which implements methods. Single inheritance means each subclass has exactly one super-class... Generalization Abstract classes are not expected to have instances of their own. . Multiple inheritance means each such class has more than one super-class.

. Generalization The terms Generalization. and are many a time used interchangeably... Inheritance and Specialization refer to the same underlying idea.. Generalization is used while modeling and implementation. It facilitates modeling by structuring classes and capturing what is similar and what is different amongst classes.

Identify the behavior of different classes Magnitude Point Number Character Integer Float ShortInteger LongInteger .

>=. -. <.Solution Magnitude Abstract Methods: +. *. -. /. <. /. LongInteger . -. <=. == Character Concrete: +. <. -. == Integer Float Concrete: +. != Abstract: *. <. == Concrete Method: >. == ShortInteger factorial ( ). *. / Point Number Concrete Methods: +.

. Ellipse. stop point. Has start point.Problem Build the hierarchy/classes for the following. stop point. Identify the major responsibilities of the classes. minor radius. Circle. For a drawing editor problem define the elements. Identify all classes in a coordinate system. the diagnoll opposite corners Line. Rectangle. major radius. Has start point. Has center and radius. Has center.

Solution Shape Line Rectangle Ellipse Point Shape Point Line Rectangle Ellipse .

Sign up to vote on this title
UsefulNot useful