![Page 1: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/1.jpg)
Design
![Page 2: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/2.jpg)
Design
• Practices• Principles• Patterns
What are the characteristics of good design?
What are good solutions to common design problems?
How do we go about design and what do we produce?
LAST TIME
![Page 3: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/3.jpg)
design a la cs121
• noun: a predictive model that captures the essential properties of a thing
• verb: the practice of “creating” a design to solve some problem
LAST TIME
![Page 4: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/4.jpg)
Forms of models
• Text (hyperlinked)• Prototypes • Mathematical models• Diagrams, charts, graphs
LAST TIME
![Page 5: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/5.jpg)
Design
• Practices• Principles• Patterns
What are the characteristics of good design?
What are good solutions to common design problems?
How do we go about design and what do we produce?
TODAY:Software design
![Page 6: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/6.jpg)
Goals
1. Make it easy to build2. Make it easy to test3. Make it easy to maintain4. Make it easy to change
INTUITIVE FLEXIBLE
![Page 7: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/7.jpg)
Desirable Characteristics of a DesignDesign Grading
• Minimal Complexity – Brooks would argue that complexity is what you need to manage.
• Ease of maintenance• Loose Coupling – hold connections to different parts of
program to a minimum• Extensibility – extend without destroying underlying structure• Reusability – reuse in other systems• High fan-in – high number of classes using this class• Low fan-out – each class should use a low to medium number
of other classes.
![Page 8: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/8.jpg)
Desirable Characteristics of a DesignDesign Grading, cont
• Portability• Leanness – designing so there are no extra parts• Stratification – try to keep levels of decomposition such that
you can view the system at any level and get a constant view• Standard Techniques – do not rely on exotic pieces, or
approaches
![Page 9: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/9.jpg)
Tic Tac Toe
1. As a team go to a board and do a Domain Model/Top Level Design of Tic Tac Toe
2. From that model, decide on your objects/classes.
![Page 10: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/10.jpg)
Design Principles
• Heuristics to create design that has the desired characteristics...
• If we do these, the project will be perfect, and satisfy all the desired Design Characteristics...not really, just has a better chance of success
• Look at ‘most important’ for our project
![Page 11: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/11.jpg)
Design principle
Use real world objectsINTUITIVE
Domain model
Design model
Name 8 or less of the most important “real world” objects in your tic tac toe game.Do your design objects match these?
![Page 12: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/12.jpg)
Real-World Objects
• Start with real-world, build your objects– attributes of that object– operations on that object– operations by that object to other objects– visible object parts– object’s interfaces
![Page 13: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/13.jpg)
Doesn’t look easy, does it?
![Page 14: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/14.jpg)
Design principle
Single responsibility principleevery class/object should have a single responsibility
INTUITIVE (easy to understand)
Can you sum up in one simple sentence the responsibility of each of your tic tac toe classes? – Do so...
![Page 15: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/15.jpg)
Single Responsibility
• Drilled into you via functions in 70 and elsewhere, issue of side effects, etc.
• Carries over to objects, need more than a single game object which does all things.
![Page 16: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/16.jpg)
![Page 17: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/17.jpg)
Design principle
Encapsulate changeeach class should have at most one reason to change,
i.e, should not change because some other class changed
FLEXIBLE What changes in your game?What can you envision changing later?A change in one object should not require changes to n otherobjects
![Page 18: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/18.jpg)
Encapsulation• "the process of compartmentalizing the elements of an
abstraction that constitute its structure and behavior; encapsulation serves to separate the contractual interface of an abstraction and its implementation.”
• The purpose is to achieve potential for change:– the internal mechanisms of the component can be improved without
impact on other components, – the component can be replaced with a different one that supports the
same public interface
![Page 19: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/19.jpg)
Design principle
High cohesionHigh cohesionLow couplingLow coupling
INTUITIVE
FLEXIBLEseparates data, operations, and visualizationillustrates low coupling and high cohesion
![Page 20: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/20.jpg)
Coupling and Cohesion• Coupling is a qualitative measure of the degree to which
classes are connected to one another.– 30 public methods is high coupling
• Cohesion is the “single-mindedness” of a component. Implies that a component or class encapsulates only attributes and operations that are closely related to one another or to the class itself – a focused class, strongly related functionality
![Page 21: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/21.jpg)
Design principle
Open-closed principleclasses should be open to extension but closed to modification
architecture of your game
![Page 22: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/22.jpg)
Open-closed Principle
• want to create a collection of classes so that we can extend the system adding new functionality, without modifying a large number of existing classes
• important in Agile, one aspect of refactoring is to mitigate such modification
![Page 23: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/23.jpg)
HELLO WORLD!HELLO WORLD!
HELLO WORLD!HELLO WORLD!
HELLO WORLD!
![Page 24: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/24.jpg)
Design principle
Don’t repeat yourselfdata/code should occur once and only once
![Page 25: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/25.jpg)
![Page 26: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/26.jpg)
Design principle
Law of Demeteronly talk to your friends
Principle of Least Knowledge
![Page 27: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/27.jpg)
Law of Demeter
• object A can request a service (call a method) of an object instance B, but object A cannot "reach through" object B to access yet another object, C, to request its services
• the LoD is a specific case of loose coupling
![Page 28: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/28.jpg)
![Page 29: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/29.jpg)
crapal chapel
![Page 30: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/30.jpg)
myGame->theBoard->cells[0][0].update()
![Page 31: Design. Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems? How do we go about](https://reader033.vdocument.in/reader033/viewer/2022052706/5a4d1af07f8b9ab05997d76f/html5/thumbnails/31.jpg)
Summary
• Use real world objects• Single responsibility principle• Encapsulate change• High cohesion/low coupling• Open-closed principle• Don`t repeat yourself (D.R.Y)• Law of demeter (talk only to your friends)