1. OOSD Flashcards
OOAD
Object oriented analysis and development
A technical approach for analysing, designing an application, system, or a business by applying the object oriented paradigm and visual modelling throughout the development lifecycle for better communication product quality
Orthogonal view of software
Two approaches:
traditional approach
object oriented approach
traditional approach
Algorithms + data structures = programs
Software system is a set of mechanisms for performing certain actions on certain data
oosd methodology
- everything is an obj And each object is responsible for itself
- Object orientation systems are easier to adapt to changing requirements. Easier to maintain more robust and promote greater design and code reuse
diff b/w Traditional and oo approach
– in mam’s doc
object basics
obj:
Combination of data and logic that represents some real world entity
- Each object is instance of class
clses:
Specification of
-structures (instance variables)
-behaviour (methods)
-inheritance for objects
Classes are important mechanisms for classifying objects. A method or behaviour of an obj Defined by its class
Dynamic and static binding
dynamic binding-
Process of determining whic function to invoke and runtime
static binding
process of determining which function to invoke earlier itself
persistence
obj have lifetime.
Features of OOD:
-
Higher level of abstraction
Top down approach supports abstraction at functional level, whereas oo approach supports abstraction and object level so it encapsulates both data (attributes) And functions (methods) -
Seamless transition among different phases of software development
In trad app, s/w dev Requires different styles and methodologies for each step of the process -
Encouragement of good programming techniques
OO Systems carefully indicates The position between its interfaces(What class can do) and implementation of that interface(how class can do that) -
Promotion of reusability
Because their model directly out of real world problem domain
Object properties
Object Methods
Object Properties
State of an object represent property
eg: Object car has properties like cost colour model
Object methods
In object model object behaviour is described in methods or procedures
- Implements behaviour of object
- Capabilities of objects are determined by the methods defined for it
- Methods conceptually are equivalent to function definitions used in procedural languages
Messages
- Objects perform operations in response to messages
- Non specific function calls can respond to Message in different ways (different from subroutine call.)
- Methods are similar to functions procedures or subroutine in more traditional programming languages, such as Cobal, Basic, or C
Encapsulation or information hiding
- Principle of concealing internal data and procedures of an object and providing an interface to each object in such a way to reveal as little as possible about its inner working to the user.
- This means users can use the object by calling the objects methods, but cannot see inside of the object capsule
- Is the design goal of OO system
- Rather than Allowing an object access another objects data directly A message is sent to the target object requesting information
Inheritence
- Property of oo sys, that allows obj to be built from other obj
- Inheritance relationship between classes where one Class is the parent(base class or super class) of the another class(derived or child class)
dynamic inheritence
- Technique where inheritance relationships between classes can change at runtime, rather than being fixed at the compile time
- The change can be the relationship between parent and child classes, or flexibility to Add delete or change objects In parent or child at the runtime or even change the parent itself
Techniques to implement:
1. Delegation
Rather than class inheriting methods directly, it delegates the responsibility to another object that can change at the runtime
2. prototypes
Some languages like javascript use prototype based inheritance where objects can change their prototypes(parents) at runtime
3. composition
Rather than delegation, you can mimic dynamic inheritance behaviour
4. dynamic class modification
In some advanced scenarios languages like python allow modifying the base class of an object during runtime, thus changing the inheritance structure can be easy
multiple inh
Some OO systems permit a class to inherit its states (attributes) and behaviours from more than one super class or parent
polymorphism
- Poly means many and morph means form
- Object that can take on many different forms
- polymorphism means that same operation may behave differently on different classes
- According to Booch, Polymorphism is a relationship of objects of many different classes by some common super class
obj relationship
-
generalization (parent-child relationship)
- Used for abstracting details in several layers -
Association (rel^nship b/w objs/clses)
- Can be bidirectional(Can be traversed in both directions perhaps with different connotations)
i. aggregation(whole/ part of relationship)
Each object has an identity One object can refer to other objects
ii. composition(strong form of aggregation)
generalization
parent class
▲(open)
│
child cls
- parent/ child rel^nshp among related clses
- used for abstracting details on several lyrs
association
- Represents relationship between objects and classes, Instance of one class is related with the instance of another class
- Associations are bidirectional They can be traversed in both directions perhaps with different cannotations(<—->).
- Forward direction
- inverse direction
- Important issue in association is cardinality, Which specifies how many instances of one class may relate to single instance of an associated class.
There are two types of Associations:
1. Aggregation
2. Composition
Aggregation
-Whole - part relationship Wear one glasses made up of multiple objects from another class
- It indicates that one class (whole) is composed of one or more instances of another class (part) but parts can exist independently of whole.
—-<>
Composition
Strong former association that represents whole part relationship where part cannot exist independently of whole
- Parts are tightly bound to the lifecycle of the whole. And if hole is destroyed, the parts are also destroyed
—-◆
diff b/w aggr and composition
Aggregation (empty diamond): The parts can exist without the whole. For example, Players can exist without being part of a Team.
Composition (filled diamond): The parts cannot exist without the whole. For example, Rooms cannot exist without a House.
object Identity
Special feature of oo system is That every object has its own unique and immutable identity
- This comes into being when an object is created and continues to represent that object from then on
- This identity never is confused with another object, even if the original object has been deleted
- In object system object identity often is implemented through some kind of object identifier (OID) or unique identifier (UID)
static and dynamic binding
static binding(early binding)
process of determining which functions to invoke at the compile time
characteristics:
1. Faster than dynamic binding
2. Once method is bound, cannot be changed at runtime
3. Applicable to private static and final methods
4. Polymorphism is not supported
dynamic binding(late binding)
Process of determining which functions to invoke at runtime
characteristics:
1. Flexibility (supports polymorphism)
2. Time taking
3. Applicable to overridden methods in subclasses.