OBJECT ORIENTED CONCEPTS

OBJECT edit Master subtitle style Click to ORIENTED ANALYSIS AND DESIGN

4/5/12

Why Use OOP?

Programs became harder to maintain. Existing functionality was hard to alter without adversely affecting all of the system’s functionality. New programs were essentially built from scratch. Consequently, there was little return on the investment of previous efforts.
4/5/12

Programming was not conducive to

Advantages of Object Oriented
• • • • • •

Simplicity Reusability Increase quality Faster development Maintainability Modifiability
4/5/12

OO Principles • • • • 1) abstraction 2) encapsulation 3) modularity 4) hierarchy 4/5/12 .

Abstraction allows us to manage complexity by concentrating on essential aspects making an entity different from others. • 4/5/12 .Principle 1: Abstraction • A process allowing to focus on most important aspects while ignoring less important details.

Principle 2: Encapsulation • Encapsulation separates implementation from users/clients. A client depends on the interface • 4/5/12 .

2. like detail of a Mobile Phone.Inner Implementation  Outer Look of a Mobile Phone. 3.Inner layout. Abstraction lets you focus on 3.Outer layout. used in terms of implementation. how 4/5/12 it has a display screen and keypad keypad button and Display Screen . Encapsulation means hiding the what the object does instead of how internal details or mechanics of how it does it an object does something. Encapsulation means hiding the unwanted data and giving relevant code and data into a single unit to data. protect the data from outside world. Encapsulation solves the problem the design level. Encapsulation. For Example:For Example:. Abstraction.Abstraction Difference between Abstraction and Encapsulation  Encapsulation 1. 4. in the implementation level. Abstraction is used for hiding the 2. used 4. Abstraction solves the problem in 1. in terms of design.

4/5/12 .Principle 3: Modularity • Modularity breaks up complex systems into small. selfcontained pieces that can be managed independently.

4/5/12 .Principle 4: Hierarchy • Ordering of abstractions into a treelike structure.

Attribute 12. Composition • 4/5/12 .Object Oriented Concepts • • • • • • • 9. OperationClass 13. Interface Class 14. Association 15. Aggregation 16. Class 11.Discriminator 6.Concrete 5.Sub-Class 3. Object 10.Super-Class 2.Generalization 1.Polymorphism 7.Abstract 4.Realization 8.

Concept 1: Objects • What is an object? – 1) any abstraction that models a single thing 2) a representation of a specific entity in the real world 3) may be tangible (physical entity) or intangible Examples: specific citizen. job. location. agency. – – – 4/5/12 . etc. order.

Examples of Objects 4/5/12 .

Object Definition • Two aspects: – Information: • • • 1) has a unique identity 2) has a description of its structure 3) has a state representing its current condition – Behaviour: • • 1) what can an object do? 2) what can be done to it? 4/5/12 .

Object Definition Example 4/5/12 .

car. – 4/5/12 . etc. citizen.Concept 2: Class • What is a class? – 1) any uniquely identified abstraction of a set of logically related instances that share similar characteristics Examples: agency.

Class Example 4/5/12 .

– 4/5/12 . Only the object is able to change the values of its own attributes.Concept 3: Attribute • Definition – Attribute is a named property of a class describing a range of values that instances of the class may hold for that property.

Attribute Examples 4/5/12 .

An operation could be: • – 1. a command – may change the values of the attributes • 4/5/12 .does not change the values of the attributes 2.Concept 4: Operation • Definition – Operation is the implementation of a service that can be requested from any object of a given class. a question .

Operation Example 4/5/12 .

Concept 5: Interface • 1) minimum information required to use an object 2) allows users to access the object’s knowledge 3) must be exposed • • 4/5/12 .

Relations and Links • Relationships: – • between classes (relations) • between objects (links) – • Three kinds of relations between classes: – 1) association 2) aggregation 3) composition – – 4/5/12 .

one object is aware of the existence of another object • • 4/5/12 . peer-to-peer relations 3.Concept 6: Association • 1. the simplest form of relation between classes 2.

Association 4/5/12 .

objects are assembled to create a more complex object 3. a restrictive form of “part-of” association 2. defines a single point of control for participating objects 4/5/12 • • • • 5.Concept 7: Aggregation • 1. assembly may be physical or logical 4. the aggregate object coordinates .

monitor and keyboard are assembled to create a computer. devices.Aggregation A CPU is part of a computer. CPU. 4/5/12 .

parts cannot exist on their own 4. a stricter form of aggregation 2. there is a create-delete dependency of the parts to the whole 4/5/12 • • . lifespan of individual objects depend on the on lifespan of the aggregate object 3.Concept 8: Composition • • 1.

If a paragraph is removed. 4/5/12 .Composition A word cannot exist if it is not part of a line. and all words belonging to that lines are removed. all lines of the paragraph are removed.

Concept 9: Generalization • a process of organizing the features of different kinds of objects that share the same purpose generalization enables inheritance specialization is the opposite of generalization not an association 4/5/12 • • • .

FrontOfficeEmployee and BackOfficeEmployee inherit them.Generalization Common features are defined in User. 4/5/12 .

A super-class is similar to a superset.Concept 10: Super-Class • Definition – Super-Class is a class that contains the features common to two or more classes.g. agency-staff. – – 4/5/12 . e.

– – – 4/5/12 . management-staff. A class may be a sub-class and a superclass at the same time. e.Concept 11: Sub-Class • Definition – Sub-Class is a class that contains at least the features of its super-class(es).g.

Super/Sub-Class Example 4/5/12 .

Concept 12: Abstract Class • 1. a class that lacks a complete implementation – provides operations without implementing some methods 2. cannot be used to create objects. a concrete sub-class must provide methods for unimplemented operations 4/5/12 • • . cannot be instantiated 3.

can be instantiated 3.Concept 13: Concrete Class • • • 1. has methods for all operations 2. methods may be: – a) defined in the class or b) inherited from a super-class – 4/5/12 .

Concept 14: Discriminator • Discriminator – an attribute that defines sub-classes Example: “status” of agency staff is a possible discriminator to derive “management”. • 4/5/12 . “senior” and “junior” sub-classes.

facilitated by encapsulation and generalization: – • a) encapsulation – • separation of interface from implementation – a) generalization – • 4/5/12 organizing information such that the shared features reside in one class and unique . ability to dynamically choose the method for an operation at run-time or service-time 2.Concept 15: Polymorphism • 1.

Polymorphism Example • • Many ways of doing the same thing! Example: management-staff and agency-staff can apply for leave. but possibly in different ways. 4/5/12 .

only inherits operations 3.Concept 16: Realization • 1. • • attributes or associations 4/5/12 . allows a class to inherit from an interface class without being a subclass of the interface class 2. cannot inherit methods.

Sign up to vote on this title
UsefulNot useful