SlideShare a Scribd company logo
Composite Design Pattern ,[object Object],[object Object],[object Object]
Design Patterns All  well-structured object-oriented systems  are  full of patterns . If the common collaborations among the objects of a complex object-oriented system is paid careful and sufficient attention, it can yield an architecture that is smaller, simpler and far more understandable Creational Structural Behavioral Abstract Factory Builder Prototype Singleton etc. Adapter Bridge Composite Decorator Façade Proxy etc. Command Iterator Observer Strategy Interpreter Mediator etc.
Structural  Design  Patterns ,[object Object],[object Object],May 23, 2007
What are Composite Objects ?? ,[object Object],[object Object],[object Object],[object Object],May 23, 2007
Problems handling primitives and composites ,[object Object],[object Object],[object Object],May 23, 2007
Why Composite Design Pattern ?? ,[object Object],[object Object],May 23, 2007
Why Composite Design Pattern ?? (cont.) ,[object Object],[object Object],May 23, 2007
Composite Pattern - Formal Definition ,[object Object],[object Object],May 23, 2007
A simple example May 23, 2007 Arithmetic expressions  are Composites. An arithmetic expression consists of an operand,  an operator ( +, -, *, / ) and another operand.  The operand can be a number, or another arithmetic expression . Thus, 2 + 3 and (2 + 3) + (4 * 6) are both valid expressions.
Composite Pattern – Class Diagram May 23, 2007
Collaborations May 23, 2007 The clients handle a component through its  general interface . A leaf directly executes the operations required, whereas a composite transfers the requests to its children.
An Example : File System ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],May 23, 2007
Example Continued… May 23, 2007 public void ls() { System.out.println(mName + “  ” ); for (int i=0; i<mFiles.size(); i++) { Object obj = mFiles.get(i); /* **** Recover the type of this object ****** */ if (obj.getClass().getName().equals( &quot;Directory&quot; )) ((Directory) obj).ls(); else ((File) obj).ls(); } } /* -- Some other methods here including add() -- */  } So here, we had to query the  &quot;type&quot;  of each object before attempting to process it, but it is  not desirable .
Can we use Composite Pattern here ?? May 23, 2007 The key to this composite pattern is an  interface  (AbstractFile) that represents both primitives(File) and composites (Directory).
Using Composite Pattern… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],May 23, 2007
Using Composite Pattern… (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],May 23, 2007
Another Example – Graphics Drawing May 23, 2007 In graphics applications, the user can group components to form larger components
Some more examples ,[object Object],[object Object],[object Object],May 23, 2007
Benefits ,[object Object],[object Object],[object Object],May 23, 2007
Some Implementation Issues ,[object Object],[object Object],May 23, 2007
Some Implementation Issues (cont.) ,[object Object],[object Object],May 23, 2007
Some Implementation Issues (cont.) ,[object Object],May 23, 2007
Thank You

More Related Content

What's hot

Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
Anjan Kumar Bollam
 
Design patterns
Design patternsDesign patterns
Design patterns
Luis Goldster
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
Chetan Gole
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL
 
Interface
InterfaceInterface
Interface
kamal kotecha
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Builder design pattern
Builder design patternBuilder design pattern
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Pipes & Filters Architectural Pattern
Pipes & Filters Architectural PatternPipes & Filters Architectural Pattern
Pipes & Filters Architectural Pattern
Fredrik Kivi
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
paramisoft
 
Design pattern
Design patternDesign pattern
Design pattern
Thibaut De Broca
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programmingAbzetdin Adamov
 
Creational pattern
Creational patternCreational pattern
Creational pattern
Himanshu
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
Kuppusamy P
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
wajrcs
 

What's hot (20)

Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Interface
InterfaceInterface
Interface
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Builder design pattern
Builder design patternBuilder design pattern
Builder design pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Pipes & Filters Architectural Pattern
Pipes & Filters Architectural PatternPipes & Filters Architectural Pattern
Pipes & Filters Architectural Pattern
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Design pattern
Design patternDesign pattern
Design pattern
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programming
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 

Viewers also liked

Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
eprafulla
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)
Sameer Rathoud
 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
Somenath Mukhopadhyay
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
Akshat Vig
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - AdapterManoj Kumar
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
guy_davis
 

Viewers also liked (6)

Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)Decorator design pattern (A Gift Wrapper)
Decorator design pattern (A Gift Wrapper)
 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 

Similar to Composite Design Pattern

Sda 9
Sda   9Sda   9
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
Sangharsh agarwal
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design PatternsDang Tuan
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
Michael Heron
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
 
UML
UMLUML
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
SyedUmairAli9
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
SajalFayyaz
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
bonej010
 
Mapping objects to_relational_databases
Mapping objects to_relational_databasesMapping objects to_relational_databases
Mapping objects to_relational_databasesIvan Paredes
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Bill Buchan
 
Slides chapter 11
Slides chapter 11Slides chapter 11
Slides chapter 11
Priyanka Shetty
 
Object Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesObject Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesRoman Agaev
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
Naga Muruga
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
DIVYANSHU KUMAR
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Bill Buchan
 

Similar to Composite Design Pattern (20)

Sda 9
Sda   9Sda   9
Sda 9
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design Patterns
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
UML
UMLUML
UML
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
Bp301
Bp301Bp301
Bp301
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Mapping objects to_relational_databases
Mapping objects to_relational_databasesMapping objects to_relational_databases
Mapping objects to_relational_databases
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
 
Slides chapter 11
Slides chapter 11Slides chapter 11
Slides chapter 11
 
Object Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesObject Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel Boundaries
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 

More from Ferdous Mahmud Shaon

Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
Ferdous Mahmud Shaon
 
Tips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering CareerTips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering Career
Ferdous Mahmud Shaon
 
Business Communcation
Business CommuncationBusiness Communcation
Business Communcation
Ferdous Mahmud Shaon
 
Effective Java - Override clone() method judiciously
Effective Java - Override clone() method judiciouslyEffective Java - Override clone() method judiciously
Effective Java - Override clone() method judiciously Ferdous Mahmud Shaon
 
Effective Java - Always override toString() method
Effective Java - Always override toString() methodEffective Java - Always override toString() method
Effective Java - Always override toString() methodFerdous Mahmud Shaon
 

More from Ferdous Mahmud Shaon (6)

Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Tips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering CareerTips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering Career
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Business Communcation
Business CommuncationBusiness Communcation
Business Communcation
 
Effective Java - Override clone() method judiciously
Effective Java - Override clone() method judiciouslyEffective Java - Override clone() method judiciously
Effective Java - Override clone() method judiciously
 
Effective Java - Always override toString() method
Effective Java - Always override toString() methodEffective Java - Always override toString() method
Effective Java - Always override toString() method
 

Recently uploaded

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 

Recently uploaded (20)

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 

Composite Design Pattern

  • 1.
  • 2. Design Patterns All well-structured object-oriented systems are full of patterns . If the common collaborations among the objects of a complex object-oriented system is paid careful and sufficient attention, it can yield an architecture that is smaller, simpler and far more understandable Creational Structural Behavioral Abstract Factory Builder Prototype Singleton etc. Adapter Bridge Composite Decorator Façade Proxy etc. Command Iterator Observer Strategy Interpreter Mediator etc.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. A simple example May 23, 2007 Arithmetic expressions are Composites. An arithmetic expression consists of an operand, an operator ( +, -, *, / ) and another operand. The operand can be a number, or another arithmetic expression . Thus, 2 + 3 and (2 + 3) + (4 * 6) are both valid expressions.
  • 10. Composite Pattern – Class Diagram May 23, 2007
  • 11. Collaborations May 23, 2007 The clients handle a component through its general interface . A leaf directly executes the operations required, whereas a composite transfers the requests to its children.
  • 12.
  • 13. Example Continued… May 23, 2007 public void ls() { System.out.println(mName + “ ” ); for (int i=0; i<mFiles.size(); i++) { Object obj = mFiles.get(i); /* **** Recover the type of this object ****** */ if (obj.getClass().getName().equals( &quot;Directory&quot; )) ((Directory) obj).ls(); else ((File) obj).ls(); } } /* -- Some other methods here including add() -- */ } So here, we had to query the &quot;type&quot; of each object before attempting to process it, but it is not desirable .
  • 14. Can we use Composite Pattern here ?? May 23, 2007 The key to this composite pattern is an interface (AbstractFile) that represents both primitives(File) and composites (Directory).
  • 15.
  • 16.
  • 17. Another Example – Graphics Drawing May 23, 2007 In graphics applications, the user can group components to form larger components
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.