SlideShare a Scribd company logo
1 of 5
Download to read offline
1 ថនសារិ
Review OOP and OOD
I. QCM
 CLASS
 Class is a blueprint for an object. In fact, classes describe the type of objects, while objects are usable instances
of classes.
 We use Class because:
 They provide useful abstraction and structure
 They help you think about the application you are building
 Class name are nouns, not verbs
 Good: Expense Claim, Employee, Printer
 Bad: Ordering, Personnel, System
 Don’t Overdo inheritance………
 How We use Class:
A class is a user defined blueprint or prototype from which objects are created. It represents the set of
properties or methods that are common to all objects of one type. In general, class declarations can
include these components, in order:
Modifiers : A class can be public or has default access (Refer this for details).
Class name: The name should begin with a initial letter (capitalized by convention).
Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword
extends. A class can only extend (subclass) one parent.
Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any, preceded
by the keyword implements. A class can implement more than one interface.
Body: The class body surrounded by braces, { }.
Constructors are used for initializing new objects. Fields are variables that provides the state of the class
and its objects, and methods are used to implement the behavior of the class and its objects.
There are various types of classes that are used in real time applications such as nested
classes, anonymous classes, lambda expressions.
 Abstract Class
 Abstract Class are classes that contain one or more abstract methods.
 We use Abstract Class Because:
An abstract class is a special kind of class that cannot be instantiated. So the question is why we need
a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other
words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it
enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all
the subclasses to carry on the same hierarchies or standards.
 How we use Class:
An abstract class is a class that is declared abstract—it may or may not include abstract
methods. Abstract classes cannot be instantiated, but they can be subclassed.
An abstract method is a method that is declared without an implementation (without braces, and
followed by a semicolon), like this:
abstract void moveTo(double deltaX, double deltaY);
If a class includes abstract methods, then the class itself must be declared abstract, as in:
public abstract class GraphicObject {
// declare fields
// declare nonabstract methods
abstract void draw();
}
2 ថនសារិ
When an abstract class is subclassed, the subclass usually provides implementations for all of the
abstract methods in its parent class. However, if it does not, then the subclass must also be
declared abstract.
 Inheritance
 inheritance is the concept that when a class of objects is defined, any subclass that is defined can inherit the
definitions of one or more general classes.
 We use inheritance because:
Inheritance is a term for reusing code by a mechanism of passing down information and behavior from a
parent class to a child or sub class. It’s pretty easy to understand really. Just like a child can inherit various
mannerisms and behaviors from his or her biological parents, in software this same concept holds true. By
leveraging the power of inheritance and creating child classes that extend their parent, we can make sub
classes with super powers that have everything their parent has and more. Let’s take a look at how
inheritance works in PHP.
II. Question
 Singleton Vs Factory Method
 Singleton
 A singleton pattern ensures that you always get back the same instance of
whatever type you are retrieving, whereas the factory pattern generally gives you a
different instance of each type.
 The purpose of the singleton is where you want all calls to go through the same
instance. An example of this might be a class that manages a disk cache, or gets
data from a static dictionary; wherever it is important only one known instance
interacts with the resource. This does make it less scalable.
 Factory Method:
 Object creation without exposing in to client
 Refer to newly created objects through interface
 Define the interface for creating an object
 The purpose of the factory is to create and return new instances. Often, these won’t
actually be the same type at all, but they will be implementations of the same base
class. However, there may be many instances of each type
 Creational Vs Structural
 Creational
These design patterns provide ways to create objects while hiding the creation logic, instead of
instantiating objects directly using the newoperator. This gives the program more flexibility in deciding
which objects need to be created for a given use case.
 Structural
 These design patterns deal with class and object composition. The concept of inheritance is used to
compose interfaces and define ways to compose objects to obtain new functionality.
 Structural Vs Behavioral
 Structural
Structural modelling refers to that type of modelling in which we simply interconnect the components by
mapping there ports by seeing the rtl diagram whereas
 Behavioral
Behavioral modelling uses sequential statement inside the process statement ,in it we implement the logic
directly and this modelling is preferred and is the highest level of abstraction
3 ថនសារិ
 Strategy vs Command
 Strategy
Strategy, in contrasst, is used to customize an algorithm. A strategy might have a number of methods
specific to the algorithm. Most often strategies will be instanciated immediately before executing the
algorithm, and discarded afterwards.
 Command
Command encapsulates a single action. It therefore tends to have a single method with a rather generic
signature. It often is intended to be stored for a longer time and to be executed later - or it is used to
provide undo functionality (in which case it will have at least two methods, of course).
 What is the benefit of
 Singleton
 Ensures only one instance of class is ever created
 Can get access to data in this class from anywhere
 Acts like global variables
 Can cause methods to have unintended side-effects due to data sharing via state in the Singleton
 Factory
 Allows the sub-classes to choose the type of objects to create
 Promoted the loose –coupling by eliminating the need to bind application-specific classes into the code
.That mean the code interacts solely with the resultant interface or abstract class,so that it will work
with any classes that implement that interface or that extends that abstract class.
 Usage:
1. When a class doesn’t know what the sub-classes will be required to create
2. When a class want that it’s sub-classes specify the object to be created
3. When the parent class choose the creation of objects to its sub-classes
 Strategy
 Forces organizations to look ahead
 Improved fit with the environment
 Better use of resources
 Provides a direction/vision
 Helps monitor progress
 Ensures goal congruence
 Command
 It decouples the classes that invoke the operation from the object that knows how to execute the
operation
 It allow you to create a sequence of command by providing a queue system
 Extensions to add a new command is easy and can be done without changing the existing code
 You can also define a rollback system with the command pattern.
4 ថនសារិ
III. Coding
 Factory Method
 Strategy
5 ថនសារិ
 Command

More Related Content

What's hot

Chapter 5 declaring classes & oop
Chapter 5 declaring classes  & oopChapter 5 declaring classes  & oop
Chapter 5 declaring classes & oop
sshhzap
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
sotlsoc
 

What's hot (20)

Abstract method
Abstract methodAbstract method
Abstract method
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1 Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
 
Hemajava
HemajavaHemajava
Hemajava
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classes
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation java
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Chapter 5 declaring classes & oop
Chapter 5 declaring classes  & oopChapter 5 declaring classes  & oop
Chapter 5 declaring classes & oop
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
 
Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
 
Chapter 7 java
Chapter 7 javaChapter 7 java
Chapter 7 java
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Class properties
Class propertiesClass properties
Class properties
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
 

Similar to Review oop and ood

oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
vamshimahi
 

Similar to Review oop and ood (20)

Oops
OopsOops
Oops
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
C#
C#C#
C#
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java basics
Java basicsJava basics
Java basics
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
C# program structure
C# program structureC# program structure
C# program structure
 
01. design pattern
01. design pattern01. design pattern
01. design pattern
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Java mcq
Java mcqJava mcq
Java mcq
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 

More from than sare

More from than sare (20)

Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
 
Project Management_Review_2018
Project Management_Review_2018Project Management_Review_2018
Project Management_Review_2018
 
Android review_for final Semester II of Year4
Android review_for final Semester II of Year4Android review_for final Semester II of Year4
Android review_for final Semester II of Year4
 
Importain questions e_commerce_preview questions
Importain questions e_commerce_preview questionsImportain questions e_commerce_preview questions
Importain questions e_commerce_preview questions
 
E commerce preview questions23 jul-2018
E commerce preview questions23 jul-2018E commerce preview questions23 jul-2018
E commerce preview questions23 jul-2018
 
Physic 12-2
Physic 12-2Physic 12-2
Physic 12-2
 
Physic grade-12
Physic grade-12Physic grade-12
Physic grade-12
 
Business plan
Business planBusiness plan
Business plan
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
 
Share point answer the question
Share point answer the questionShare point answer the question
Share point answer the question
 
Judging rubric
Judging rubricJudging rubric
Judging rubric
 
Smartphone v ideo editing manual-ios(Tech By Ms.THAN Sare)
Smartphone v ideo  editing manual-ios(Tech By Ms.THAN Sare)Smartphone v ideo  editing manual-ios(Tech By Ms.THAN Sare)
Smartphone v ideo editing manual-ios(Tech By Ms.THAN Sare)
 
Database(db sql) review
Database(db sql) reviewDatabase(db sql) review
Database(db sql) review
 
Mid term & final- preparation- student-review(Oracle)
Mid term & final- preparation- student-review(Oracle)Mid term & final- preparation- student-review(Oracle)
Mid term & final- preparation- student-review(Oracle)
 
Answer ado.net pre-exam2018
Answer ado.net pre-exam2018Answer ado.net pre-exam2018
Answer ado.net pre-exam2018
 
Technovation week6 planning_yourcode
Technovation week6 planning_yourcodeTechnovation week6 planning_yourcode
Technovation week6 planning_yourcode
 
Sen sors(technovation) week6_thansare
Sen sors(technovation) week6_thansareSen sors(technovation) week6_thansare
Sen sors(technovation) week6_thansare
 
Week5(technovation)-Teach by Mr.than Sare
Week5(technovation)-Teach by Mr.than SareWeek5(technovation)-Teach by Mr.than Sare
Week5(technovation)-Teach by Mr.than Sare
 
App inventor week4(technovation)
App inventor week4(technovation)App inventor week4(technovation)
App inventor week4(technovation)
 
Algorithm week2(technovation)
Algorithm week2(technovation)Algorithm week2(technovation)
Algorithm week2(technovation)
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Recently uploaded (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 

Review oop and ood

  • 1. 1 ថនសារិ Review OOP and OOD I. QCM  CLASS  Class is a blueprint for an object. In fact, classes describe the type of objects, while objects are usable instances of classes.  We use Class because:  They provide useful abstraction and structure  They help you think about the application you are building  Class name are nouns, not verbs  Good: Expense Claim, Employee, Printer  Bad: Ordering, Personnel, System  Don’t Overdo inheritance………  How We use Class: A class is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type. In general, class declarations can include these components, in order: Modifiers : A class can be public or has default access (Refer this for details). Class name: The name should begin with a initial letter (capitalized by convention). Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends. A class can only extend (subclass) one parent. Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements. A class can implement more than one interface. Body: The class body surrounded by braces, { }. Constructors are used for initializing new objects. Fields are variables that provides the state of the class and its objects, and methods are used to implement the behavior of the class and its objects. There are various types of classes that are used in real time applications such as nested classes, anonymous classes, lambda expressions.  Abstract Class  Abstract Class are classes that contain one or more abstract methods.  We use Abstract Class Because: An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.  How we use Class: An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this: abstract void moveTo(double deltaX, double deltaY); If a class includes abstract methods, then the class itself must be declared abstract, as in: public abstract class GraphicObject { // declare fields // declare nonabstract methods abstract void draw(); }
  • 2. 2 ថនសារិ When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract.  Inheritance  inheritance is the concept that when a class of objects is defined, any subclass that is defined can inherit the definitions of one or more general classes.  We use inheritance because: Inheritance is a term for reusing code by a mechanism of passing down information and behavior from a parent class to a child or sub class. It’s pretty easy to understand really. Just like a child can inherit various mannerisms and behaviors from his or her biological parents, in software this same concept holds true. By leveraging the power of inheritance and creating child classes that extend their parent, we can make sub classes with super powers that have everything their parent has and more. Let’s take a look at how inheritance works in PHP. II. Question  Singleton Vs Factory Method  Singleton  A singleton pattern ensures that you always get back the same instance of whatever type you are retrieving, whereas the factory pattern generally gives you a different instance of each type.  The purpose of the singleton is where you want all calls to go through the same instance. An example of this might be a class that manages a disk cache, or gets data from a static dictionary; wherever it is important only one known instance interacts with the resource. This does make it less scalable.  Factory Method:  Object creation without exposing in to client  Refer to newly created objects through interface  Define the interface for creating an object  The purpose of the factory is to create and return new instances. Often, these won’t actually be the same type at all, but they will be implementations of the same base class. However, there may be many instances of each type  Creational Vs Structural  Creational These design patterns provide ways to create objects while hiding the creation logic, instead of instantiating objects directly using the newoperator. This gives the program more flexibility in deciding which objects need to be created for a given use case.  Structural  These design patterns deal with class and object composition. The concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionality.  Structural Vs Behavioral  Structural Structural modelling refers to that type of modelling in which we simply interconnect the components by mapping there ports by seeing the rtl diagram whereas  Behavioral Behavioral modelling uses sequential statement inside the process statement ,in it we implement the logic directly and this modelling is preferred and is the highest level of abstraction
  • 3. 3 ថនសារិ  Strategy vs Command  Strategy Strategy, in contrasst, is used to customize an algorithm. A strategy might have a number of methods specific to the algorithm. Most often strategies will be instanciated immediately before executing the algorithm, and discarded afterwards.  Command Command encapsulates a single action. It therefore tends to have a single method with a rather generic signature. It often is intended to be stored for a longer time and to be executed later - or it is used to provide undo functionality (in which case it will have at least two methods, of course).  What is the benefit of  Singleton  Ensures only one instance of class is ever created  Can get access to data in this class from anywhere  Acts like global variables  Can cause methods to have unintended side-effects due to data sharing via state in the Singleton  Factory  Allows the sub-classes to choose the type of objects to create  Promoted the loose –coupling by eliminating the need to bind application-specific classes into the code .That mean the code interacts solely with the resultant interface or abstract class,so that it will work with any classes that implement that interface or that extends that abstract class.  Usage: 1. When a class doesn’t know what the sub-classes will be required to create 2. When a class want that it’s sub-classes specify the object to be created 3. When the parent class choose the creation of objects to its sub-classes  Strategy  Forces organizations to look ahead  Improved fit with the environment  Better use of resources  Provides a direction/vision  Helps monitor progress  Ensures goal congruence  Command  It decouples the classes that invoke the operation from the object that knows how to execute the operation  It allow you to create a sequence of command by providing a queue system  Extensions to add a new command is easy and can be done without changing the existing code  You can also define a rollback system with the command pattern.
  • 4. 4 ថនសារិ III. Coding  Factory Method  Strategy