SlideShare a Scribd company logo
1 of 27
Software Design Fundamentals
Ajay Shrivastava
1
Design Fundamentals:
• Buzzwords :
– Extensibility
– Maintainability
– Modularity
• Layman Terms: Think of Future:
– Addition of behaviors/types.
– Modification of behaviors/types.
– Deletion/Disabling of behaviors/types.
2
Duck Game: Design Exercise
3
Duck Game: Its Easy!!
Switch .. case :
------------------------------------------------------
Enum DuckType
{
RedHeadDuck;
MallardDuck;
}
Quack(int ducktype)
{
switch(ducktype)
{
case :RedHeadDuck:
RedHeadQuack();
case : MallardDuck :
MallardQuack();
case XYZ :
------
default:
------
}
If .. Else .. If ladder :
------------------------------------------------------
Enum DuckType
{
RedHeadDuck;
MallardDuck;
}
Quack(int duckType)
{
if(duckType == RedHeadDuck)
{
RedHeadQuack();
}
else if(duckType == MallardDuck)
{
MallardQuack();
}
else if ()
--
else
--
}
Duck Game: Now Think of future …
• Add a common default behavior to all ducks:
• Need to create the new function with all cases
• Might miss out some kind of ducks.
• Add a new Duck Type:
• All functions must be remembered and updated too.
5
Duck Game: Solution: OO design
6
Duck Game: Future: New requirement
• Flying ducks :
7
Duck Game: That’s Easy!
8
Duck Game: Solution 2:
9
Duck Game: Think of future: Rubber ducks ..
A localized update to the code caused a non local side effect (flying rubber ducks)!
10
Duck Game: What’s wrong ..
11
Duck Game: Solution 3:
12
Duck Game: Think of future: Wooden ducks ..
• Need to override these methods in many classes
• Otherwise they start Quacking & flying by default 
13
Duck Game: Solution 4: Interfaces:
• Take fly() out of Duck superclass and make a Flyable interface with a fly() method.
• All ducks that’s want to fly will implement the Flyable interface and have a fly() method.
• Similarly have a Quackable interface also.
14
Duck Game: Solution 4: Problem ..
• If having to overrride a few methods was BAD!
• How are you going to feel when you need to make a little change to the flying behavior
• In all 48 of flying Duck subclasses!!
15
Duck Game: Crux of the problem..
16
Duck Game: Solution 5
17
Duck Game: Solution 5 contd..
18
Duck Game: Solution 5 contd..
19
Duck Game: Solution 5: Full design..
20
Duck Game: Code …
Code after Design:
------------------------------------------------------
• Duck duck = new RedHeadDuck();
Perform(duck);
• Perform(Duck duck)
{
duck->Display();
duck -> Quack();
duck->Swim()
duck->Fly()
}
If .. Else .. If ladder :
------------------------------------------------------
• int _currentDuckType = ReadHeadDuck;
Perform(_currentDuckType )
• Perform(int duckType)
{
Display(duckType);
Quack(duckType);
Swim(duckType);
Fly(duckType);
}
21
• Quack(int duckType)
{
if(duckType == RedHeadDuck)
{
RedHeadQuack();
}
else if(duckType == MallardDuck)
{
MallardQuack();
}
else if ()
--
else
--
}
• Class RedHeadDuck: public Duck
{
Display();
Swim() { }
Fly() ( flyBehavior->Fly(); )
Quack() { quackBehavior-> Quack(); }
FlyBehavior flyBehavior;
QuackBehavior- quackBehavior;
}
• Class RedHeadDuck: public Duck
{
Display() { // display of RedHead }
}
Duck Game:
22
Post Mortem:
• What caused design changes :
– Layman :
• Addition
• Modification
• Deletion [Not covered in this exercise].
– Buzzwords : Problems were in:
• Extensibility
• Maintainability
• Modularity.
23
Design: Impact… [ where’s money  ]
• Effects :
– Extensibility:
• Less cost in adding new features.
– Maintainability:
• Less cost in modifying/removing behavior, fixing bugs.
– Modularity:
• is part of maintainability.
• Side Effects:
– Generic(Reusable) code => Less Code.
– Less Code => Less Bugs !!!
– Less Code => Smaller files (binaries, Javascript etc).
– Smaller files => Better Performance (small memory footprint, less time to load)
– Better performance => Simplest & Most Effective Magic!!
24
Design: Recommendations..
• Many functions having same/similar ifs/switch, is an indication for Need
for Design.
– Otherwise Addition/Modification/Deletion is costly and prone to bugs (even for the type
which you don’t want to touch).
– Try to at least get to first OO design in this deck.
• Never intermix CRM logic with any non CRM Components logic.
– It becomes difficult to remove/replace it or support another parallel similar component.
– Vancouver ?? Sharepoint?? Dundas??
• Functions should NOT be more than a screen/page long.
– Automatically enforces modularity.
– Should be tracked in review.
25
Questions ??
26
Thank You!
27

More Related Content

Similar to Design Fundamentals

Cracking Pseudorandom Sequences Generators in Java Applications
Cracking Pseudorandom Sequences Generators in Java ApplicationsCracking Pseudorandom Sequences Generators in Java Applications
Cracking Pseudorandom Sequences Generators in Java ApplicationsPositive Hack Days
 
Poker, packets, pipes and Python
Poker, packets, pipes and PythonPoker, packets, pipes and Python
Poker, packets, pipes and PythonRoger Barnes
 
Tokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperTokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperConnor McDonald
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Leonardo Borges
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchpramod naik
 
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?SegFaultConf
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsBrendan Gregg
 
NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010Ben Scofield
 
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...StampedeCon
 
Game programming-help
Game programming-helpGame programming-help
Game programming-helpSteve Nash
 
Breadth or Depth: What's in a column-store?
Breadth or Depth: What's in a column-store?Breadth or Depth: What's in a column-store?
Breadth or Depth: What's in a column-store?Jeff Smith
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cMauro Pagano
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backVictor_Cr
 
Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amiesPierre Laporte
 
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...DataStax Academy
 
CptS 440/ 540 AI.pptx
CptS 440/ 540 AI.pptxCptS 440/ 540 AI.pptx
CptS 440/ 540 AI.pptxDrDejaVu2
 

Similar to Design Fundamentals (20)

Cracking Pseudorandom Sequences Generators in Java Applications
Cracking Pseudorandom Sequences Generators in Java ApplicationsCracking Pseudorandom Sequences Generators in Java Applications
Cracking Pseudorandom Sequences Generators in Java Applications
 
Poker, packets, pipes and Python
Poker, packets, pipes and PythonPoker, packets, pipes and Python
Poker, packets, pipes and Python
 
Tokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperTokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java Developer
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Game playing
Game playingGame playing
Game playing
 
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame Graphs
 
l3.pptx
l3.pptxl3.pptx
l3.pptx
 
NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010
 
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
 
Game programming-help
Game programming-helpGame programming-help
Game programming-help
 
Breadth or Depth: What's in a column-store?
Breadth or Depth: What's in a column-store?Breadth or Depth: What's in a column-store?
Breadth or Depth: What's in a column-store?
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12c
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
 
R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amies
 
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
 
CptS 440/ 540 AI.pptx
CptS 440/ 540 AI.pptxCptS 440/ 540 AI.pptx
CptS 440/ 540 AI.pptx
 

More from Ajay Shrivastava

More from Ajay Shrivastava (6)

Startups
StartupsStartups
Startups
 
Change Good to Great
Change Good to GreatChange Good to Great
Change Good to Great
 
Development Process
Development ProcessDevelopment Process
Development Process
 
Iterative Development Process
Iterative Development ProcessIterative Development Process
Iterative Development Process
 
Team 2014
Team 2014Team 2014
Team 2014
 
Team Principles
Team PrinciplesTeam Principles
Team Principles
 

Recently uploaded

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 

Recently uploaded (20)

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 

Design Fundamentals

  • 2. Design Fundamentals: • Buzzwords : – Extensibility – Maintainability – Modularity • Layman Terms: Think of Future: – Addition of behaviors/types. – Modification of behaviors/types. – Deletion/Disabling of behaviors/types. 2
  • 3. Duck Game: Design Exercise 3
  • 4. Duck Game: Its Easy!! Switch .. case : ------------------------------------------------------ Enum DuckType { RedHeadDuck; MallardDuck; } Quack(int ducktype) { switch(ducktype) { case :RedHeadDuck: RedHeadQuack(); case : MallardDuck : MallardQuack(); case XYZ : ------ default: ------ } If .. Else .. If ladder : ------------------------------------------------------ Enum DuckType { RedHeadDuck; MallardDuck; } Quack(int duckType) { if(duckType == RedHeadDuck) { RedHeadQuack(); } else if(duckType == MallardDuck) { MallardQuack(); } else if () -- else -- }
  • 5. Duck Game: Now Think of future … • Add a common default behavior to all ducks: • Need to create the new function with all cases • Might miss out some kind of ducks. • Add a new Duck Type: • All functions must be remembered and updated too. 5
  • 6. Duck Game: Solution: OO design 6
  • 7. Duck Game: Future: New requirement • Flying ducks : 7
  • 10. Duck Game: Think of future: Rubber ducks .. A localized update to the code caused a non local side effect (flying rubber ducks)! 10
  • 11. Duck Game: What’s wrong .. 11
  • 13. Duck Game: Think of future: Wooden ducks .. • Need to override these methods in many classes • Otherwise they start Quacking & flying by default  13
  • 14. Duck Game: Solution 4: Interfaces: • Take fly() out of Duck superclass and make a Flyable interface with a fly() method. • All ducks that’s want to fly will implement the Flyable interface and have a fly() method. • Similarly have a Quackable interface also. 14
  • 15. Duck Game: Solution 4: Problem .. • If having to overrride a few methods was BAD! • How are you going to feel when you need to make a little change to the flying behavior • In all 48 of flying Duck subclasses!! 15
  • 16. Duck Game: Crux of the problem.. 16
  • 18. Duck Game: Solution 5 contd.. 18
  • 19. Duck Game: Solution 5 contd.. 19
  • 20. Duck Game: Solution 5: Full design.. 20
  • 21. Duck Game: Code … Code after Design: ------------------------------------------------------ • Duck duck = new RedHeadDuck(); Perform(duck); • Perform(Duck duck) { duck->Display(); duck -> Quack(); duck->Swim() duck->Fly() } If .. Else .. If ladder : ------------------------------------------------------ • int _currentDuckType = ReadHeadDuck; Perform(_currentDuckType ) • Perform(int duckType) { Display(duckType); Quack(duckType); Swim(duckType); Fly(duckType); } 21 • Quack(int duckType) { if(duckType == RedHeadDuck) { RedHeadQuack(); } else if(duckType == MallardDuck) { MallardQuack(); } else if () -- else -- } • Class RedHeadDuck: public Duck { Display(); Swim() { } Fly() ( flyBehavior->Fly(); ) Quack() { quackBehavior-> Quack(); } FlyBehavior flyBehavior; QuackBehavior- quackBehavior; } • Class RedHeadDuck: public Duck { Display() { // display of RedHead } }
  • 23. Post Mortem: • What caused design changes : – Layman : • Addition • Modification • Deletion [Not covered in this exercise]. – Buzzwords : Problems were in: • Extensibility • Maintainability • Modularity. 23
  • 24. Design: Impact… [ where’s money  ] • Effects : – Extensibility: • Less cost in adding new features. – Maintainability: • Less cost in modifying/removing behavior, fixing bugs. – Modularity: • is part of maintainability. • Side Effects: – Generic(Reusable) code => Less Code. – Less Code => Less Bugs !!! – Less Code => Smaller files (binaries, Javascript etc). – Smaller files => Better Performance (small memory footprint, less time to load) – Better performance => Simplest & Most Effective Magic!! 24
  • 25. Design: Recommendations.. • Many functions having same/similar ifs/switch, is an indication for Need for Design. – Otherwise Addition/Modification/Deletion is costly and prone to bugs (even for the type which you don’t want to touch). – Try to at least get to first OO design in this deck. • Never intermix CRM logic with any non CRM Components logic. – It becomes difficult to remove/replace it or support another parallel similar component. – Vancouver ?? Sharepoint?? Dundas?? • Functions should NOT be more than a screen/page long. – Automatically enforces modularity. – Should be tracked in review. 25