SlideShare une entreprise Scribd logo
1  sur  39
Prakash Sathiyamoorthy
Presentation Overview
 Introduction to Patterns
 Patterns are not only for C.Sc.
 Earliest Patterns.
 Patterns in C.Sc. To real life.
Patterns - What are they?
 Natural human thought process
 Helps to solve problems effectively
 Easy to recognize
 Has been in use for thousands of years
 We come across them everyday
Patterns - Not a C.Sc Subject
 Computer Science has adopted a version of Design
  Patterns.
 Design patterns are for everyone.
Earliest Patterns - 1
 Astronomical constellations
Earliest Patterns - 2
 Rangolis
If only C.Sc used Patterns 

Shortest path
connecting the dots !
Earliest Patterns - 3
 Periodic table of elements
Patterns in Nature - OOPS
 OOPS –

   Separation of responsibilities.
   Nothing much 
Example - OOPS
Imagine if you are a single person :

         building your own house,
         manufacturing your own car,
         cooking your own food,
         farming your own crops,
         stitching your own dresses,
         doing laundry,
         running your own transport,
         making your own televisions,
         running your own channels, etc. etc. etc….
OOPS !!! (literally) missed

making your own software !
Patterns in Nature - Singleton
 Problem: Controlling traffic in a road junction.
 Imagine having a police for every direction.

 Solution: Place one at the center.


 Example: Traffic police in junctions.


                                                Pic follows
Patterns in Nature - Factory
 Problem: Imagine visiting every brand’s showroom
 separately i.e. Reebok, Peter England, etc.

 Solution: Keep every brand under one roof so it is
 easy to find everything in the same place.

 Example: Brand factory
Patterns in Nature - Builder
 Problem: A guy that’s wants to own a house most of
 the times cannot build himself/herself.

 Solution: Handover the responsibility of building the
 house to a builder who specializes in that.

 Example: Construction builder
Patterns in Nature - Prototype
 Problem: Imagine writing lecture notes laboriously
 during the lecture in college.

 Solution (Easy) : Take photocopies from the front row
 guys 

 Example: Xerox copies
Patterns in Nature - Pool
 Problem: Everyone wants to pick up the same book the
  subject lecturer announces. You cannot have infinite copies
  of a title. Even if you do, not all would be required.

 Solution: Have finite set of copies and keep circulating
  that.

 Examples:
    Lending books from library
    Cabs servicing customers
Patterns in Nature - Flyweight
 Problem: Making ice for every color is not only costly
  but also unnecessary.

 Solution: Have ice separately so it is easy to mix the
  essence which differs among orders.

 Example: ice gola (Pic follows)
Patterns in Nature - Composite
 Some patterns are hard to explain and this is one of
 them, so lets skip 
Patterns in Nature - Adapter
 Problem: You reach US and try to connect your
 Laptop you purchased in India and end up in trouble.

 Solution: You get a India-US plug adapter that can
 connect your plug to the wall socket.
Patterns in Nature - Decorator
 Problem: Well, there are no problems here actually.


 Solution: A solution is not required when there is no
 problem  So a decorator just adds up to the beauty of
 the original. May be having undecorated could be
 scary 

 Example: suspense here, next slide
And he is the
“Decorator”
Patterns in Nature - Proxy
 Problem: Original may be presented later until
  absolutely required.

 Solution: Place a substitute for time being.


 Example:
    Proxy attendance, reserving bus seat with kerchief
     (could be any piece of cloth actually )
Bus seat reservation with kerchief
Patterns in Nature - Bridge
 Remember, some patterns cannot be explained so
 easily? This is the second one, so we’ll skip.
Patterns in Nature - Facade
 Problem: Hide the complexity and expose a much
 simpler and a easy to understand look.

 Solution: Cover the complex portion with a thing that
 looks simpler and beautiful.

 Example: A modern building’s façade


                                            Pic follows
Patterns in Nature - COR
 Problem: One person/entity is burdened with all the
  responsibilities.

 Solution: Delegate the individual responsibilities so that
  one person/entity is not burdened with all the work.

 Examples:

    A typical hotel scenario – biller -> Server -> Cook
    A government office – extended COR 
Patterns in Nature - Template
 Problem: Making commonly used patterns is time consuming

 Solution: Avoid commonly used but time consuming work by
  having a ready made shape that can be used as a reference to
  make the intended one easily

 Examples:
    Stencils in school
    Painting templates


   Do you realize how early you
   started applying design patterns?
Patterns in Nature - Interpreter
 Problem: Need a dedicated way of handling a small
 domain related work.

 Solution: Define a domain specific language, the
 grammar, rules for interpretation, etc.

 Example: Language used in avatar (Na'vi) : Define a
 domain’s own language and the interpretation rules.
Patterns in Nature - Command
 Problem: Need a command in between that will
 shorten things up. Imagine every customer of hotel
 talking to the cook directly !

 Solution: Have a person/thing in between who can
 take the command and delegate the request and
 handle it back.

 Example: A server in hotel – One who takes the
 request is not the one that does the actual work.
Patterns in Nature - Iterator
 Problem: Need a easy way to visit every member of a
 group.

 Solution: Have a representation of the collection so it
 is easy to callout each person.

 Example: An attendance register.
Patterns in Nature - Mediator
 Problem: Need to mediate things so that the
 individual entities can have easy and effective
 communication.

 Solution: Place a mediator who will mediate between
 the things. In our example, quikrr or ebay mediates
 between buyers and sellers.

 Example: Quikrrrrrrrrrrr, ebay
Patterns in Nature - Memento
 Problem: Need to keep a memory for every occasion
 so it is easy to recollect later.

 Solution: Have a memento for every occasion.


 Example: from Ramayana, next slide.
Aaranya Kand
                              1. Sita asks Rama to fetch the deer for her




2. Maricha (the daemon) shouts in the voice of
Rama asking for Lakshmana for help.
3. Lakshman draws the restricted boundary line
                              for Sita.




4.Ravana makes Sita to cross the line so that he can
abduct her.




                              5. Ravana succeeds in abducting Sita
Sita is in deep trouble

Now comes the “Memento” design pattern to Sita’s
rescue.


                                        6. Sita keeps throwing her
                                        ornaments (mementos) for
                                        Rama to trace the route to find
                                        her !




No computer program would have applied this pattern before Sita did 
Conclusion

•So, Design Patterns are definitely not invented for
Computer Science !

•We see, hear, experience and come across many patterns
in our daily life.

•Gang-Of-Four patterns are not the complete list of
patterns.
Thank You !
Prakash.sathiyamoorthy@gmail.com

Contenu connexe

En vedette

Patterns number and geometric
Patterns  number and geometricPatterns  number and geometric
Patterns number and geometricamdzubinski
 
Repeating and growing patterns
Repeating and growing patternsRepeating and growing patterns
Repeating and growing patternsJessica Weesies
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

En vedette (8)

Patterns number and geometric
Patterns  number and geometricPatterns  number and geometric
Patterns number and geometric
 
Repeating and growing patterns
Repeating and growing patternsRepeating and growing patterns
Repeating and growing patterns
 
Nature of sociology
Nature of sociologyNature of sociology
Nature of sociology
 
Types Of Flower
Types Of  FlowerTypes Of  Flower
Types Of Flower
 
Math in nature
Math in natureMath in nature
Math in nature
 
Flowers
FlowersFlowers
Flowers
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similaire à Design Patterns - Inspirations From Nature

Shape borrowing sec 1 2010
Shape borrowing  sec 1 2010Shape borrowing  sec 1 2010
Shape borrowing sec 1 2010anil2531
 
Design Patterns Story
Design Patterns StoryDesign Patterns Story
Design Patterns StoryArun A
 
Objects for modeling world
Objects for modeling worldObjects for modeling world
Objects for modeling worldEswaran P
 
Stories2patterns
Stories2patternsStories2patterns
Stories2patternsYishay Mor
 
Improving Software Languages: usage patterns to the rescue
Improving Software Languages: usage patterns to the rescueImproving Software Languages: usage patterns to the rescue
Improving Software Languages: usage patterns to the rescueJordi Cabot
 
planet-handheldlearning08
planet-handheldlearning08planet-handheldlearning08
planet-handheldlearning08Yishay Mor
 
Problem solving and experiments
Problem solving and experimentsProblem solving and experiments
Problem solving and experimentsOliverColeman12345
 
What is creative thinking, why do we need it and how do we learn it
What is creative thinking, why do we need it and how do we learn itWhat is creative thinking, why do we need it and how do we learn it
What is creative thinking, why do we need it and how do we learn ith20ho
 
Digital Practices Portfolio
Digital Practices PortfolioDigital Practices Portfolio
Digital Practices PortfolioLibbynolan
 
Design Thinking by Mark Uraine
Design Thinking by Mark UraineDesign Thinking by Mark Uraine
Design Thinking by Mark UraineMark Uraine
 
UX London Redux - Dan Saffer
UX London Redux - Dan SafferUX London Redux - Dan Saffer
UX London Redux - Dan Saffercpetzny
 
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)Miami University
 
A Timeless Way of Communicating: Alexandrian Pattern Languages
A Timeless Way of Communicating: Alexandrian Pattern LanguagesA Timeless Way of Communicating: Alexandrian Pattern Languages
A Timeless Way of Communicating: Alexandrian Pattern LanguagesJoshua Kerievsky
 
Soylent: A Word Processor with a Crowd Inside
Soylent: A Word Processor with a Crowd InsideSoylent: A Word Processor with a Crowd Inside
Soylent: A Word Processor with a Crowd InsideMichael Bernstein
 
Verbs - English Grammar Lesson 1 by Slidesgo.pptx
Verbs - English Grammar Lesson 1 by Slidesgo.pptxVerbs - English Grammar Lesson 1 by Slidesgo.pptx
Verbs - English Grammar Lesson 1 by Slidesgo.pptxProfessorJooHlio
 
3 solving problems
3 solving problems3 solving problems
3 solving problemshccit
 
Visual Rhetoric, August 28th
Visual Rhetoric, August 28thVisual Rhetoric, August 28th
Visual Rhetoric, August 28thMiami University
 

Similaire à Design Patterns - Inspirations From Nature (20)

Shape borrowing sec 1 2010
Shape borrowing  sec 1 2010Shape borrowing  sec 1 2010
Shape borrowing sec 1 2010
 
January 29th PowerPoint
January 29th PowerPointJanuary 29th PowerPoint
January 29th PowerPoint
 
Design Patterns Story
Design Patterns StoryDesign Patterns Story
Design Patterns Story
 
Objects for modeling world
Objects for modeling worldObjects for modeling world
Objects for modeling world
 
Stories2patterns
Stories2patternsStories2patterns
Stories2patterns
 
Improving Software Languages: usage patterns to the rescue
Improving Software Languages: usage patterns to the rescueImproving Software Languages: usage patterns to the rescue
Improving Software Languages: usage patterns to the rescue
 
Yishay Mor
Yishay MorYishay Mor
Yishay Mor
 
planet-handheldlearning08
planet-handheldlearning08planet-handheldlearning08
planet-handheldlearning08
 
Problem solving and experiments
Problem solving and experimentsProblem solving and experiments
Problem solving and experiments
 
What is creative thinking, why do we need it and how do we learn it
What is creative thinking, why do we need it and how do we learn itWhat is creative thinking, why do we need it and how do we learn it
What is creative thinking, why do we need it and how do we learn it
 
Digital Practices Portfolio
Digital Practices PortfolioDigital Practices Portfolio
Digital Practices Portfolio
 
Design Thinking by Mark Uraine
Design Thinking by Mark UraineDesign Thinking by Mark Uraine
Design Thinking by Mark Uraine
 
UX London Redux - Dan Saffer
UX London Redux - Dan SafferUX London Redux - Dan Saffer
UX London Redux - Dan Saffer
 
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)
Visual Rhetoric, Feb 3rd, Late Show (with snow day make-up)
 
A Timeless Way of Communicating: Alexandrian Pattern Languages
A Timeless Way of Communicating: Alexandrian Pattern LanguagesA Timeless Way of Communicating: Alexandrian Pattern Languages
A Timeless Way of Communicating: Alexandrian Pattern Languages
 
Soylent: A Word Processor with a Crowd Inside
Soylent: A Word Processor with a Crowd InsideSoylent: A Word Processor with a Crowd Inside
Soylent: A Word Processor with a Crowd Inside
 
The Modlet Pattern
The Modlet PatternThe Modlet Pattern
The Modlet Pattern
 
Verbs - English Grammar Lesson 1 by Slidesgo.pptx
Verbs - English Grammar Lesson 1 by Slidesgo.pptxVerbs - English Grammar Lesson 1 by Slidesgo.pptx
Verbs - English Grammar Lesson 1 by Slidesgo.pptx
 
3 solving problems
3 solving problems3 solving problems
3 solving problems
 
Visual Rhetoric, August 28th
Visual Rhetoric, August 28thVisual Rhetoric, August 28th
Visual Rhetoric, August 28th
 

Dernier

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
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.pptxDenish Jangid
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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 . pdfQucHHunhnh
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Dernier (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Design Patterns - Inspirations From Nature

  • 2. Presentation Overview  Introduction to Patterns  Patterns are not only for C.Sc.  Earliest Patterns.  Patterns in C.Sc. To real life.
  • 3. Patterns - What are they?  Natural human thought process  Helps to solve problems effectively  Easy to recognize  Has been in use for thousands of years  We come across them everyday
  • 4. Patterns - Not a C.Sc Subject  Computer Science has adopted a version of Design Patterns.  Design patterns are for everyone.
  • 5. Earliest Patterns - 1  Astronomical constellations
  • 6. Earliest Patterns - 2  Rangolis
  • 7. If only C.Sc used Patterns  Shortest path connecting the dots !
  • 8. Earliest Patterns - 3  Periodic table of elements
  • 9. Patterns in Nature - OOPS  OOPS –  Separation of responsibilities.  Nothing much 
  • 10. Example - OOPS Imagine if you are a single person : building your own house, manufacturing your own car, cooking your own food, farming your own crops, stitching your own dresses, doing laundry, running your own transport, making your own televisions, running your own channels, etc. etc. etc….
  • 11. OOPS !!! (literally) missed making your own software !
  • 12. Patterns in Nature - Singleton  Problem: Controlling traffic in a road junction. Imagine having a police for every direction.  Solution: Place one at the center.  Example: Traffic police in junctions. Pic follows
  • 13.
  • 14. Patterns in Nature - Factory  Problem: Imagine visiting every brand’s showroom separately i.e. Reebok, Peter England, etc.  Solution: Keep every brand under one roof so it is easy to find everything in the same place.  Example: Brand factory
  • 15. Patterns in Nature - Builder  Problem: A guy that’s wants to own a house most of the times cannot build himself/herself.  Solution: Handover the responsibility of building the house to a builder who specializes in that.  Example: Construction builder
  • 16. Patterns in Nature - Prototype  Problem: Imagine writing lecture notes laboriously during the lecture in college.  Solution (Easy) : Take photocopies from the front row guys   Example: Xerox copies
  • 17. Patterns in Nature - Pool  Problem: Everyone wants to pick up the same book the subject lecturer announces. You cannot have infinite copies of a title. Even if you do, not all would be required.  Solution: Have finite set of copies and keep circulating that.  Examples:  Lending books from library  Cabs servicing customers
  • 18. Patterns in Nature - Flyweight  Problem: Making ice for every color is not only costly but also unnecessary.  Solution: Have ice separately so it is easy to mix the essence which differs among orders.  Example: ice gola (Pic follows)
  • 19.
  • 20. Patterns in Nature - Composite  Some patterns are hard to explain and this is one of them, so lets skip 
  • 21. Patterns in Nature - Adapter  Problem: You reach US and try to connect your Laptop you purchased in India and end up in trouble.  Solution: You get a India-US plug adapter that can connect your plug to the wall socket.
  • 22. Patterns in Nature - Decorator  Problem: Well, there are no problems here actually.  Solution: A solution is not required when there is no problem  So a decorator just adds up to the beauty of the original. May be having undecorated could be scary   Example: suspense here, next slide
  • 23. And he is the “Decorator”
  • 24. Patterns in Nature - Proxy  Problem: Original may be presented later until absolutely required.  Solution: Place a substitute for time being.  Example:  Proxy attendance, reserving bus seat with kerchief (could be any piece of cloth actually ) Bus seat reservation with kerchief
  • 25. Patterns in Nature - Bridge  Remember, some patterns cannot be explained so easily? This is the second one, so we’ll skip.
  • 26. Patterns in Nature - Facade  Problem: Hide the complexity and expose a much simpler and a easy to understand look.  Solution: Cover the complex portion with a thing that looks simpler and beautiful.  Example: A modern building’s façade Pic follows
  • 27.
  • 28. Patterns in Nature - COR  Problem: One person/entity is burdened with all the responsibilities.  Solution: Delegate the individual responsibilities so that one person/entity is not burdened with all the work.  Examples:  A typical hotel scenario – biller -> Server -> Cook  A government office – extended COR 
  • 29. Patterns in Nature - Template  Problem: Making commonly used patterns is time consuming  Solution: Avoid commonly used but time consuming work by having a ready made shape that can be used as a reference to make the intended one easily  Examples:  Stencils in school  Painting templates Do you realize how early you started applying design patterns?
  • 30. Patterns in Nature - Interpreter  Problem: Need a dedicated way of handling a small domain related work.  Solution: Define a domain specific language, the grammar, rules for interpretation, etc.  Example: Language used in avatar (Na'vi) : Define a domain’s own language and the interpretation rules.
  • 31. Patterns in Nature - Command  Problem: Need a command in between that will shorten things up. Imagine every customer of hotel talking to the cook directly !  Solution: Have a person/thing in between who can take the command and delegate the request and handle it back.  Example: A server in hotel – One who takes the request is not the one that does the actual work.
  • 32. Patterns in Nature - Iterator  Problem: Need a easy way to visit every member of a group.  Solution: Have a representation of the collection so it is easy to callout each person.  Example: An attendance register.
  • 33. Patterns in Nature - Mediator  Problem: Need to mediate things so that the individual entities can have easy and effective communication.  Solution: Place a mediator who will mediate between the things. In our example, quikrr or ebay mediates between buyers and sellers.  Example: Quikrrrrrrrrrrr, ebay
  • 34. Patterns in Nature - Memento  Problem: Need to keep a memory for every occasion so it is easy to recollect later.  Solution: Have a memento for every occasion.  Example: from Ramayana, next slide.
  • 35. Aaranya Kand 1. Sita asks Rama to fetch the deer for her 2. Maricha (the daemon) shouts in the voice of Rama asking for Lakshmana for help.
  • 36. 3. Lakshman draws the restricted boundary line for Sita. 4.Ravana makes Sita to cross the line so that he can abduct her. 5. Ravana succeeds in abducting Sita
  • 37. Sita is in deep trouble Now comes the “Memento” design pattern to Sita’s rescue. 6. Sita keeps throwing her ornaments (mementos) for Rama to trace the route to find her ! No computer program would have applied this pattern before Sita did 
  • 38. Conclusion •So, Design Patterns are definitely not invented for Computer Science ! •We see, hear, experience and come across many patterns in our daily life. •Gang-Of-Four patterns are not the complete list of patterns.