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

VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 

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