SlideShare a Scribd company logo
UNIT IV DESIGN PATTERNS
Presented By R.Krishna Prakash,
Assistant Professor/CSE,
Kongunadu College Of Engineering And Technology.
KONGUNADU COLLEGE OF ENGINEERING
AND TECHNOLOGY
(AUTONOMOUS)
UNIT IV DESIGN
PATTERNS
Design Patterns
• It’s typical solutions to common problems in software design.
• Each pattern is like a blueprint that you can customize to solve a
particular design problem in your code
Designing objects with responsibilities
• GRASP-General responsibility assignment software patterns
- GRASP is a tool that helps to master the basics of OOD and
understanding responsibilities
- A learning aid that helps to understand for OO design with
responsibilities
• RDD -Responsibility Driven Design
It’s thinking about object oriented design
Doing responsibility- creating action, initializing, controlling
and coordinating activities
Knowing responsibilities- includes knowing about private
and related data
Applying Grasp to Object Design
There are nine different GRASP patterns:
(i) Creator
(ii) Information expert
(iii) Low coupling
(iv) Controller
(v) High cohesion
(vi) Polymorphism
(vii) Pure fabrication
(viii) Indirection
(ix) Protected variations
Creator
• Its one of the common activities in object oriented system
is creation of object
• General principle is applied for the assignment of creation
responsibilities.
If B is a creator of A objects then atleast one of the following
must be true.
• B contains A
• B compositely aggregates A
• B records A
• B closely uses A
INFORMATION EXPERT
•Designing objects, interaction between objects are defined
about assigning responsibilities to software classes
This makes the software easier to
• Maintain
• Understand
• Extend
LOW COUPLING
Coupling is the measure of less strongly one element is
connected to the other elements.
Types of coupling
There are 2 types of coupling
1) Low coupling or weak coupling
2) High coupling or strong coupling
• Low coupling
An element if does not depend on too many other elements like
classes, subsystems systems it is having low coupling
• High coupling
A class with high coupling relies on many other classes.
The problems of high coupling are
• Harder to understand
• Harder to reuse
Example
Benefits for LOW Coupling
•Not affected by changes in other components
•Simple to understand
•Convenient to reuse
HIGH COHESION
•Strongly related and focused responsibilities of an
element. An element has high cohesion if it,
•Difficulties of low cohesion are
•Hard to comprehend
•Hard to reuse
•Hard to maintain
Functional Cohesion
(1) Very low cohesion
• A class is solely responsible for many things in different functional areas.
(2) Low cohesion
• A class has sole responsibility for a complex task in one functional area.
(3) High cohesion
• A class has moderate responsibilities in one functional area and
collaborates with others.
(4) Moderate cohesion
• A class has light weight. It is responsible for different areas logically
related to the class concept but not to each other
High cohesion is
• Easy to maintain
• Understand
• Reuse
Benefits of high cohesion are
•Clarity
•Ease of comprehension
CONTROLLER
•A controller is defined as the first object beyond the user interface
(UI) layer that is responsible for the receiving or handling a system
operation message.
Design patterns
Designing for visibility:
• One object to have reference of another is called visibility
Ex: getProductDescription message sent from a Register to a
product catalog means that ProductCatalog instance is
visible to register.
Ways of visibility: from Object A to Object B
Attribute visibility – B is an attribute of A
Parameter visibility – B is a parameter of a method of A
Local visibility – B is a local object in a method of A
Global visibility – B is globally visible in some way
Attribute visibility
Parameter visibility
Local visibility
Factory Method
•Factory Method is a creational design pattern that provides
an interface for creating objects in a superclass, allows
subclasses to alter the type of objects that will be created.
Factory Method pattern
PROBLEM:
◦ A framework with abstract application classes and application-
specific subclasses to instantiate to realize different
implementations
SOLUTION:
◦ The Factory Method pattern encapsulates the knowledge of which
subclass to create and moves this knowledge out of the framework
Bridge pattern
The Bridge pattern is designed to separate a class's interface from its
implementation
so you can vary or replace the implementation without changing the
client code.
•Decouple an abstraction from its implementation
•Allows different implementations of an interface to be decided upon
dynamically.
•Also known as Handle/Body pattern
•Avoid a permanent binding between an abstraction and its
implementation
•Both the abstractions and their implementation should be extensible
by subclass
•Changes in the implementation of an abstraction do not impact the
clients
•Share an implementation among multi objects and this facts should
be hidden from the client
•E.g: Windows, program
Structure
Solution using Bridge
Adapter
• The adapter pattern is adapting between classes and
objects.
• Like any adapter in the real world it is used to be an
interface, a bridge between two objects.
• EX :Camera memory
Variations in Adapters
•Class Adapters
Use multiple inheritance to compose classes
•Object Adapters
Object adapters use a compositional technique to adapt
one interface to another.
Variations in Adapters
• Name : Adapter
• Problem : If similar components have different
interfaces then how to resolve incompatible interfaces.
• Solution : Using an intermediate adapter object,
convert original interface of a component to another
interface.
Object Pattern
adaptee
Use of Adapter
•Tax calculators
•Credit authorization services
•Accounting systems etc
SINGLETON
•Singleton is a class that allows only a single instance of itself
to be created and gives access to that created instance.
•It contains static variables that can accommodate unique
and private instances of itself.
Implementation of singleton
• Singleton is implemented with a ‘1‘ in the top right corner
of name compartment.
• Class X defines a static method getInstance‘ that provides
single instance of X
Class
public class Register
{
public void initialize ( )
{
… do some work…
//accessing singleton factory in a getInstance call accounting
Adapter =
ServicesFactory.getInstance().getAccountingAdapter( );
… do some work…
} //other methods…
}//end of class
Design Issues in implementation
public static synchronized ServiceFactory getInstance ( )
{
if (instance ==null)
{
instance = newServicesFactory ( );
}
return instance;
}
Eager initialization
public class servicesFactory
{
private static servicesFactory instance = new ServicesFactory ( );
public static servicesFactory getInstance ( )
{
Return instance;
}
// other methods…
}
Observer pattern
•To extend the solution found for changing data, add the ability for a
GUI window to refresh its sale.
•The Observer design pattern, or more accurately some
implementation of this pattern, is used to assure consistency
between different objects
Subject & Observer
Subject
◦The object which will frequently change its state and
upon which other objects depend
Observer
◦The object which depends on a subject and updates
according to its subject's state.
Observer Pattern - Example
a b c
60
y
x
5030
30
20
10
z 801010 a b c
a
b
c
a = 50%
b = 30%
c = 20%
change notification
requests, modifications
Subject
GOF(Gang of four) design patterns
1. Adapter pattern
2. Factory method
3. Singleton
4. Strategy
MAPPING DESIGN TO CODE
•The implementation Model, the UML artifacts
created during the code generation is used as input.
•The implementation artifacts consists of source code,
database definitions, JSP/XML/HTML pages
•Java
•C#
•Visual Basic
•C++
•Small talk
•Python
Defining a class with method signatures
and attributes
Creating Methods from Interaction
Diagrams
Message
public void enterItem (itemID, int qty)
ProductDescription desc = catalog.getProductDescription (itemID);
CurrentSale.makeLineItem (desc, qty);
Exceptions and Error Handling
•Applications development consider large – scale exception handling
strategies during design modeling.
•Indicated in the property strings of messages and operation
declarations
Exceptions and Error Handling
• Exceptions are indicated in the property strings of
messages and operation declarations.
Collection Classes in Code
• There are many one to many relationships.
• These are implemented with the collection object such as
List or Map or array
Order of Implementation
Order of Implementation

More Related Content

Similar to UNIT IV DESIGN PATTERNS.pptx

Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
Julie Iskander
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane2
 
Object oriented programming
Object oriented programmingObject oriented programming
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
sukumarraju6
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
Priyanka Pradhan
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
bonej010
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
Hiệp Tiến
 
Patterns
PatternsPatterns
Patterns
Amith Tiwari
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10
Kuwait10
 
Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandt
mfrancis
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
CSEC5
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Luis Valencia
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
Michael Heron
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptx
NajibMuhammad16
 

Similar to UNIT IV DESIGN PATTERNS.pptx (20)

Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Design pattern
Design patternDesign pattern
Design pattern
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Patterns
PatternsPatterns
Patterns
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10
 
Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandt
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptx
 

Recently uploaded

ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 

Recently uploaded (20)

ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 

UNIT IV DESIGN PATTERNS.pptx

  • 1. UNIT IV DESIGN PATTERNS Presented By R.Krishna Prakash, Assistant Professor/CSE, Kongunadu College Of Engineering And Technology. KONGUNADU COLLEGE OF ENGINEERING AND TECHNOLOGY (AUTONOMOUS)
  • 3. Design Patterns • It’s typical solutions to common problems in software design. • Each pattern is like a blueprint that you can customize to solve a particular design problem in your code
  • 4. Designing objects with responsibilities • GRASP-General responsibility assignment software patterns - GRASP is a tool that helps to master the basics of OOD and understanding responsibilities - A learning aid that helps to understand for OO design with responsibilities
  • 5. • RDD -Responsibility Driven Design It’s thinking about object oriented design Doing responsibility- creating action, initializing, controlling and coordinating activities Knowing responsibilities- includes knowing about private and related data
  • 6. Applying Grasp to Object Design There are nine different GRASP patterns: (i) Creator (ii) Information expert (iii) Low coupling (iv) Controller (v) High cohesion (vi) Polymorphism (vii) Pure fabrication (viii) Indirection (ix) Protected variations
  • 7. Creator • Its one of the common activities in object oriented system is creation of object • General principle is applied for the assignment of creation responsibilities.
  • 8. If B is a creator of A objects then atleast one of the following must be true. • B contains A • B compositely aggregates A • B records A • B closely uses A
  • 9.
  • 10. INFORMATION EXPERT •Designing objects, interaction between objects are defined about assigning responsibilities to software classes This makes the software easier to • Maintain • Understand • Extend
  • 11.
  • 12.
  • 13.
  • 14. LOW COUPLING Coupling is the measure of less strongly one element is connected to the other elements. Types of coupling There are 2 types of coupling 1) Low coupling or weak coupling 2) High coupling or strong coupling
  • 15. • Low coupling An element if does not depend on too many other elements like classes, subsystems systems it is having low coupling • High coupling A class with high coupling relies on many other classes. The problems of high coupling are • Harder to understand • Harder to reuse
  • 17. Benefits for LOW Coupling •Not affected by changes in other components •Simple to understand •Convenient to reuse
  • 18. HIGH COHESION •Strongly related and focused responsibilities of an element. An element has high cohesion if it, •Difficulties of low cohesion are •Hard to comprehend •Hard to reuse •Hard to maintain
  • 19.
  • 20. Functional Cohesion (1) Very low cohesion • A class is solely responsible for many things in different functional areas. (2) Low cohesion • A class has sole responsibility for a complex task in one functional area. (3) High cohesion • A class has moderate responsibilities in one functional area and collaborates with others. (4) Moderate cohesion • A class has light weight. It is responsible for different areas logically related to the class concept but not to each other
  • 21. High cohesion is • Easy to maintain • Understand • Reuse Benefits of high cohesion are •Clarity •Ease of comprehension
  • 22. CONTROLLER •A controller is defined as the first object beyond the user interface (UI) layer that is responsible for the receiving or handling a system operation message.
  • 23.
  • 24. Design patterns Designing for visibility: • One object to have reference of another is called visibility Ex: getProductDescription message sent from a Register to a product catalog means that ProductCatalog instance is visible to register.
  • 25.
  • 26. Ways of visibility: from Object A to Object B Attribute visibility – B is an attribute of A Parameter visibility – B is a parameter of a method of A Local visibility – B is a local object in a method of A Global visibility – B is globally visible in some way
  • 30. Factory Method •Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, allows subclasses to alter the type of objects that will be created.
  • 31. Factory Method pattern PROBLEM: ◦ A framework with abstract application classes and application- specific subclasses to instantiate to realize different implementations SOLUTION: ◦ The Factory Method pattern encapsulates the knowledge of which subclass to create and moves this knowledge out of the framework
  • 32. Bridge pattern The Bridge pattern is designed to separate a class's interface from its implementation so you can vary or replace the implementation without changing the client code.
  • 33. •Decouple an abstraction from its implementation •Allows different implementations of an interface to be decided upon dynamically. •Also known as Handle/Body pattern
  • 34. •Avoid a permanent binding between an abstraction and its implementation •Both the abstractions and their implementation should be extensible by subclass •Changes in the implementation of an abstraction do not impact the clients •Share an implementation among multi objects and this facts should be hidden from the client •E.g: Windows, program
  • 37. Adapter • The adapter pattern is adapting between classes and objects. • Like any adapter in the real world it is used to be an interface, a bridge between two objects. • EX :Camera memory
  • 38. Variations in Adapters •Class Adapters Use multiple inheritance to compose classes •Object Adapters Object adapters use a compositional technique to adapt one interface to another.
  • 39. Variations in Adapters • Name : Adapter • Problem : If similar components have different interfaces then how to resolve incompatible interfaces. • Solution : Using an intermediate adapter object, convert original interface of a component to another interface.
  • 41. Use of Adapter •Tax calculators •Credit authorization services •Accounting systems etc
  • 42. SINGLETON •Singleton is a class that allows only a single instance of itself to be created and gives access to that created instance. •It contains static variables that can accommodate unique and private instances of itself.
  • 43. Implementation of singleton • Singleton is implemented with a ‘1‘ in the top right corner of name compartment. • Class X defines a static method getInstance‘ that provides single instance of X
  • 44. Class public class Register { public void initialize ( ) { … do some work… //accessing singleton factory in a getInstance call accounting Adapter = ServicesFactory.getInstance().getAccountingAdapter( ); … do some work… } //other methods… }//end of class
  • 45.
  • 46. Design Issues in implementation public static synchronized ServiceFactory getInstance ( ) { if (instance ==null) { instance = newServicesFactory ( ); } return instance; }
  • 47. Eager initialization public class servicesFactory { private static servicesFactory instance = new ServicesFactory ( ); public static servicesFactory getInstance ( ) { Return instance; } // other methods… }
  • 48. Observer pattern •To extend the solution found for changing data, add the ability for a GUI window to refresh its sale. •The Observer design pattern, or more accurately some implementation of this pattern, is used to assure consistency between different objects
  • 49. Subject & Observer Subject ◦The object which will frequently change its state and upon which other objects depend Observer ◦The object which depends on a subject and updates according to its subject's state.
  • 50. Observer Pattern - Example a b c 60 y x 5030 30 20 10 z 801010 a b c a b c a = 50% b = 30% c = 20% change notification requests, modifications Subject
  • 51. GOF(Gang of four) design patterns 1. Adapter pattern 2. Factory method 3. Singleton 4. Strategy
  • 52. MAPPING DESIGN TO CODE •The implementation Model, the UML artifacts created during the code generation is used as input. •The implementation artifacts consists of source code, database definitions, JSP/XML/HTML pages
  • 54. Defining a class with method signatures and attributes
  • 55. Creating Methods from Interaction Diagrams
  • 56. Message public void enterItem (itemID, int qty) ProductDescription desc = catalog.getProductDescription (itemID); CurrentSale.makeLineItem (desc, qty);
  • 57.
  • 58. Exceptions and Error Handling •Applications development consider large – scale exception handling strategies during design modeling. •Indicated in the property strings of messages and operation declarations
  • 59. Exceptions and Error Handling • Exceptions are indicated in the property strings of messages and operation declarations. Collection Classes in Code • There are many one to many relationships. • These are implemented with the collection object such as List or Map or array