[go: up one dir, main page]

0% found this document useful (0 votes)
33 views184 pages

Se 3

The document discusses Object-Oriented Programming (OOP) concepts, including classes, inheritance, encapsulation, and polymorphism, highlighting their advantages in software development and maintainability. It also covers design patterns, categorizing them into creational, structural, and behavioral types, along with the concept of anti-patterns that identify common flawed practices in software development. The document emphasizes the importance of design patterns in providing reusable solutions and improving communication among developers.

Uploaded by

pssafvan97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views184 pages

Se 3

The document discusses Object-Oriented Programming (OOP) concepts, including classes, inheritance, encapsulation, and polymorphism, highlighting their advantages in software development and maintainability. It also covers design patterns, categorizing them into creational, structural, and behavioral types, along with the concept of anti-patterns that identify common flawed practices in software development. The document emphasizes the importance of design patterns in providing reusable solutions and improving communication among developers.

Uploaded by

pssafvan97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 184

Module 3

OOP Concepts
• Object Oriented is a popular design approach for

analyzing and designing an application

• Most of the languages like C++, Java, .net are use object

oriented design concept

• Object-oriented concepts are used in the design methods

such as classes, objects, polymorphism, encapsulation,

inheritance, dynamic binding, information hiding,


• The main advantage of object oriented design is that improving the

software development and maintainability

• Another advantage is that faster and low cost development, and

creates a high quality software

• The disadvantage of the object-oriented design is that larger program

size and it is not suitable for all types of program


• The different terms related to object design are:
 Class :

 A class is a collection of method and variables

 It is a blueprint that defines the data and behavior of a type

 Let’s take HumanBeing as a class

 A class is a blueprint for any functional entity which defines its

properties and its functions

 Like HumanBeing, having body parts, performing various actions


 Inheritance :

 Inheritance is a feature of object-oriented programming that allows code

reusability when a class includes property of another class

 Considering HumanBeing a class, which has properties like hands, legs,

eyes, mouth, etc, and functions like walk, talk, eat, see, etc.

 Man and Woman are also classes, but most of the properties and

functions are included in HumanBeing

 Hence, they can inherit everything from class HumanBeing using the

concept of Inheritance
 Objects :

 My name is Akhil, and I am an instance/object of class Man

 Abstraction :

 Abstraction means, showcasing only the required things to the

outside world while hiding the details

 Continuing our example, HumanBeing’s can talk, walk, hear, eat, but

the details of the muscles mechanism and their connections to the

brain are hidden from the outside world


 Encapsulation :

 Encapsulation means that we want to hide unnecessary details from

the user

 For example, when we call from our mobile phone, we select the

number and press call button

 But the entire process of calling or what happens from the moment we

press or touch the call button to the moment we start having a phone

conversation is hidden from us


 Polymorphism :
 Polymorphism is a feature of object-oriented programming
languages that allows a specific routine to use variables of
different types at different times
 Design classes

• A set of design classes refined the analysis class by providing design


details
• There are five different types of design classes and each type
represents the layer of the design architecture these are as follows:
1) User interface classes :
 These classes are designed for Human Computer Interaction(HCI)

2) Business domain classes :


 These classes are required to implement the elements of the
business domain
3) Process classes :
 Which is needed to completely manage the business domain
class
4) Persistence classes :
 It shows data stores that will persist behind the execution of the
software

5) System Classes :
 System classes implement software management and control
functions
 Design class characteristics

 Complete and sufficient

 Primitiveness : Fulfill one service for the class


 High cohesion : A cohesion design class has a small and focused set
of responsibilities
 Low-coupling : The minimum acceptable of collaboration must be
kept in the model. If a design model is highly coupled then the
system is difficult to implement, to test and to maintain over time
DESIGN PATTERNS
Index

 Basic concepts of Design patterns


 How to select a design pattern
 Creational patterns
 Structural patterns
 Behavioral patterns
 Concept of Anti-patterns
 Basic concepts of Design patterns

 In software engineering, a design pattern is a general repeatable

solution to a commonly occurring problem in software design

 A design pattern isn’t a finished design

 It is a description or template for how to solve a problem that can be

used in many different situations


 Each design pattern systematically names, explains, and evaluates an

important and recurring design in object-oriented systems

 Our goal is to capture design experience in a form that people can use

effectively

 To this end we have documented some of the most important design

patterns and present them as a catalog


 In general, a pattern has four essential elements:
1) Pattern name
2) Problem
3) Solution
4) Consequences
 Pattern name
 Use to describe a design problem, its solutions, and consequences
in a word or two
 Naming a pattern immediately increases our design vocabulary
 It makes it easier to think about designs and communicate to others
 Finding good names has been one of the hardest part
 Problem
 Describes when to apply the pattern
 It explains the problem and its context
 Solution
 The solution doesn't describe a particular concrete design or
implementation
 Because a pattern is like a template that can be applied in many
different situations
 Describes the elements that make up the design, their
relationships, responsibilities, and collaborations
 Consequences
 They are the results and trade-offs of applying the pattern
 Design patterns can speed up the development process by providing

tested, proven development paradigms

 Reusing design patterns helps to prevent subtle issues that can cause

major problems

 Improves code readability for coders and architects familiar with the

patterns
 Often, people only understand how to apply certain software design
techniques to certain problems
 These techniques are difficult to apply to a broader range of problems
 Design patterns provide general solutions, documented in a format
that doesn't require specifics tied to a particular problem
 In addition, patterns allow developers to communicate using well-
known, well understood names for software interactions
 Common design patterns can be improved over time
 How to select a design pattern

 With more than 20 design patterns in the catalog to choose from, it

might be hard to find the one that addresses a particular design

problem, especially if the catalog is new and unfamiliar to you

 Here are several different approaches to finding the design pattern

that's right for your problem:


 Consider how design patterns solve design problems
 Find appropriate objects, determine object granularity, specify
object interfaces, and several other ways in which design patterns
solve design problems
 Scan Intent sections
 Read through each pattern's intent to find one or more that sound
relevant to your problem
 Study how patterns interrelate
 Studying these relationships between design patterns graphically
can help direct you to the right pattern or group of patterns
 Study patterns of like purpose
 Study the similarities and differences between creational patterns,
structural patterns and behavioral patterns
 Examine a cause of redesign
 Look at the patterns that help you avoid the causes of redesign
 Eg : Algorithmic dependencies
 Algorithms are often extended, optimized, and replaced during development and
reuse
 Objects that depend on an algorithm will have to change when the algorithm
changes
 Therefore algorithms that are likely to change should be isolated
 Design patterns: Builder, Iterator, Strategy, Template, Method, Visitor
Consider what should be variable in your design

 Consider what you want to be able to change without redesign

 The focus here is on encapsulating the concept that varies

 Design aspect(s) (eg : steps of an algorithm) of design patterns can

vary independently, thereby letting you change them without

redesign
 Organizing the Catalog
 There are many design patterns, we need a way to organize them
 We classify design patterns by two criteria (Table1.1)
 The first criterion, called purpose, reflects what a pattern does
 Patterns can have either creational, structural, or behavioral
purpose
 Creational patterns concern the process of object creation
 Structural patterns deal with the composition of classes or objects
 Behavioral patterns characterize the ways in which classes or objects
interact and distribute responsibility
 The second criterion, called scope, specifies whether the pattern
applies primarily to classes or to objects
 Class patterns deal with relationships between classes and their
subclasses
 These relationships are established through inheritance, so they are
static (fixed at compile-time)
 Object patterns deal with object relationships, which can be changed
at run-time and are more dynamic
 Only patterns labeled "class patterns" are those that focus on class
relationships
 Note that most patterns are in the Object scope
 Creational class patterns defer some part of object creation to

subclasses, while Creational object patterns defer it to another object

 The Structural class patterns use inheritance to compose classes, while

the Structural object patterns describe ways to assemble objects

 The Behavioral class patterns use inheritance to describe algorithms and

flow of control, whereas the Behavioral object patterns describe how a

group of objects cooperate to perform a task that no single object can

carry out alone


Creational
Patterns
 Creational design patterns abstract the instantiation process
 They help make a system independent of how its objects are created,
composed, and represented
 This pattern can be further divided into class-creation patterns and
object-creational patterns
 While class-creation patterns use inheritance effectively in the
instantiation process
 Object-creation patterns use delegation effectively to get the job done
 Abstract Factory

 Object Creational
 Builder

 Object Creational
 Factory Method
 Class Creational
 Prototype

 Object Creational
 Singleton

 Object Creational
Structural
Patterns
 These design patterns are all about Class and Object composition

 Structural class patterns use inheritance to compose interfaces

 Structural object-patterns define ways to compose objects to obtain

new functionality
 Adapter

 Class, Object Structural


 Bridge

 Object Structural
 Composite

 Object Structural
 Decorator

 Object Structural
 Facade

 Object Structural
 Flyweight

 Object Structural
 Proxy

 Object Structural
Behavioral
Patterns
 Behavioral patterns are concerned with algorithms and the assignment of

responsibilities between objects

 Behavioral patterns describe not just patterns of objects or classesbut also

the patterns of communication between them

 Behavioral class patterns use inheritance to distribute behavior between

classes

 Behavioral object patterns use object composition rather than inheritance


 Chain of Responsibility

 Object Behavioral
 Command

 Object Behavioral
 Interpreter

 Class Behavioral
 Iterator

 Object Behavioral
 Mediator

 Object Behavioral
 Memento

 Object Behavioral
 Observer

 Object Behavioral
 State

 Object Behavioral
 Strategy

 Object Behavioral
 Template Method

 Class Behavioral
 Visitor

 Object Behavioral
Concept of
Anti-patterns
 AntiPatterns, like their design pattern counterparts, define an industry
vocabulary for the common defective processes and implementations
within organizations
 A higher-level vocabulary simplifies communication between software
practitioners and enables concise description of higher-level concepts
 Describes a commonly occurring solution to a problem that generates
decidedly negative consequences
 The AntiPattern may be the result of a manager or developer not
knowing any better, not having sufficient knowledge or experience in
solving a particular type of problem, or having applied a perfectly good
pattern in the wrong context
 Recognizing recurring problems in the software industry
 Provide a detailed remedy for the most common predicaments
 Highlight the most common problems that face the software industry and
provide the tools to enable you to recognize these problems and to
determine their underlying causes
 Implementing productive solutions
 Improve the developing of applications, the designing of software systems
 Effective management of software projects
 Software Development AntiPatterns
 A key goal of development AntiPatterns is to describe useful forms of
software refactoring
 Software refactoring is a form of code modification, used to improve the
software structure in support of subsequent extension and long-term
maintenance

 Software Architecture AntiPatterns


 Architecture AntiPatterns focus on the system-level and enterprise-
level structure of applications and components
 Project Management AntiPatterns

 In the modern engineering profession, more than half of the job


involves human communication and resolving people issues
 The management AntiPatterns identify some of the key scenarios in
which these issues are destructive to software processes

You might also like