Professional Documents
Culture Documents
07:46 AM • SAD
OO concepts from a structured point Persistence
of view Coupling
Abstraction, Encapsulation, and
Cohesion
information hiding
Polymorphism
Inheritance
Interfaces
Association
Components
Aggregation
Patterns
Collaboration
07:46 AM • SAD
OO concepts from a structured point of view
• Focuses on capturing the structure and behavior of information systems into small modules that
combine both data and process.
• To improve the quality and productivity of system analysis and design so as to make it more
usable.
• It performs well in situations where systems are undergoing continuous design, adaption, and
maintenance.
• It identifies the objects in the problem domain, classifying them in terms of data and behavior.
07:46 AM • SAD
OO concepts from a structured point of view
07:46 AM • SAD
OO concepts from a structured point of view
07:46 AM • SAD
OO concepts from a structured point of view
07:46 AM • SAD
OO concepts from a structured point of view
07:46 AM • SAD
OO concepts from a structured point of view
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Abstraction:- is a process of hiding the implementation details and showing only functionality to
the user.
• It is a feature of OOPs.
• It is used to hide unnecessary information or data from the user but shows the essential data that is
useful for the user.
• It can be achieved by using the interface and the abstract class.
• In interfaces, only the methods are exposed to the end user.
• The best example of abstraction is a TV remote. The user only interacts with the outer
interface which is nothing but keys.
• The user only knows which key to press for what function.
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Abstraction:- is a process of hiding the implementation details and showing only functionality to
the user.
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Encapsulation:- binding data and corresponding methods (behavior) together into a single unit.
» is a programming technique that binds the class members (variables and methods)
together and prevents them from being accessed by other classes.
» Thereby, we can keep variables and methods safes from outside interference and
misuse.
» In the encapsulation technique, we declare fields as private in the class to prevent
other classes from accessing them directly.
» The required encapsulated data can be accessed by using the public Java getter
and setter method.
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Encapsulation:-
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Encapsulation:-
Realtime Example 1:
» School bag is one of the most real examples of Encapsulation. School bags can keep our
books, pens, etc.
Realtime Example 2:
» When you log into your email accounts such as Gmail, Yahoo Mail, or Rediff Mail, there
are a lot of internal processes taking place in the backend and you have no control over it.
» When you enter the password for logging, they are retrieved in an encrypted form and
verified, and then you are given access to your account.
» You do not have control over it that how the password has been verified. Thus, it keeps our
account safe from being misused.
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Encapsulation:-
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
• Data/Information Hiding:- ensure the security of members of a class from illegal access.
» protects the data members from being changed or hacked.
• Eg: Suppose you declared a CheckAccount class and you have a data member balance
inside that class. Here, the balance of an account is sensitive information. You may allow
an outside application to check the balance inside of an account but, you won’t allow an
outside application to alter the balance attribute. Thus declaring the balance attribute
private would restrict access to balance from an outside application.
07:46 AM • SAD
Abstraction, Encapsulation, and information hiding
Data hiding focuses on restricting the use of data, intending to assure data security.
07:46 AM • SAD
Inheritance
07:46 AM • SAD
Inheritance
07:46 AM • SAD
Association
• Association relationship
Example:
1) A single teacher has multiple students.
07:46 AM • SAD
Association
• Association relationship
Common items to model for an association:
1. Directionality: The open arrowheads indicate the directionality of the association. When there is one
arrowhead the association is unidirectional: it can be traversed in one direction only (in the direction of the
arrow). When there are either zero or two arrowheads the association is bi-directional: it can be traversed in
both directions. Although you should indicate both arrowheads it is common practice to drop the
arrowheads from bi-directional associations.
2. Label: The label, which is optional, is typically one or two words describing the association. Reading one
class, the label, and then the other class should produce a sentence fragment that describes the relationship,
e.g., Professor teaches Seminars. Avoid generic labels like ―has‖ or ―communicates with‖ as much as
possible.
07:46 AM • SAD
Association
• Association relationship
3. Multiplicity: The multiplicity of the association is labeled on either end of the line, with one
multiplicity indicator for each direction
07:46 AM • SAD
Aggregation
Eg: Here we are considering a car and a wheel example. A car cannot move without a wheel.
But the wheel can be independently used with the bike, scooter, cycle, or any other vehicle.
The wheel object can exist without the car object, which proves to be an aggregation
relationship.
07:46 AM • SAD
Aggregation
• Aggregation:
07:46 AM • SAD
Composition
• The composition: depicts dependency between a composite (parent) and its parts (children),
which means that if the composite is discarded, so will its parts get deleted. It exists between
similar objects.
• As you can see from the example given below, the composition association relationship connects
the Person class with the Brain class, Heart class, and Legs class. If the person is destroyed, the
brain, heart, and legs will also get discarded.
07:46 AM • SAD
Collaboration
• Classes often need to work together to fulfill their responsibilities.
• Collaboration occurs between objects when one object asks another for information or to do something.
For example, an airplane collaborates with its engines to fly. For the plane to go faster, the engines must
go faster. When the plane needs to slow down, the engines must slow down.
If the airplane did not collaborate with its engines, it would be unable to fly.
Objects collaborate with one another by sending each other messages. A message is either a request to do
something or a request for information. Messages are modeled in sequence and collaboration diagrams.
07:46 AM • SAD
Collaboration
07:46 AM • SAD
Persistence
• Persistence focuses on the issue of how to make objects available for future use of your software.
• In other words, how to save objects for permanent storage. To make an object persistent, you must
save the values of its attributes to permanent storage (such as a relational database or a file) as
well as any information needed to maintain the relationships (aggregation, inheritance, and
association) with which it is involved.
• In other words you need to save the appropriate properties to permanent storage. In addition to
saving objects, persistence is also concerned with their retrieval and deletion.
07:46 AM • SAD
Coupling
• Coupling is a measure of how two items, such as classes or methods, are interrelated. When one
class depends on another class, we say they are coupled.
• When one class interacts with another class, but does not know any of the implementation details
of the other class, we say they are loosely coupled. When one class relies on the implementation
(that is, it directly accesses the data attributes of the other), we say they are tightly coupled.
07:46 AM • SAD
Cohesion
• Cohesion defines how effectively elements within a Module or object work together to fulfill a
single well-defined purpose. A high level of cohesion means that elements within a module are
tightly integrated and working together to achieve the desired functionality.
07:46 AM • SAD
Polymorphism
07:46 AM • SAD
Interfaces
// interface
interface Animal {
public void animalSound(); // interface method (does not have a body)
public void run(); // interface method (does not have a body)
}
Eg:
07:46 AM • SAD
Patterns
• A pattern is a solution to a common problem taking relevant forces into account, effectively
supporting the reuse of proven techniques and approaches of other developers. Several flavors of
patterns exist, including analysis patterns, design patterns, and process patterns.
• Analysis patterns describe a solution to common problems found in the analysis/business domain of
an application,
• design patterns describe a solution to common problems found in the design of systems, and process
patterns address software process related issues.
• Design Patterns are reusable solutions to commonly occurring problems(in the context of software
design).
• Design patterns were started as best practices that were applied again and again to similar problems
encountered in different contexts.
07:46 AM • SAD
07:46 AM • SAD