Design Design and Software Architecture

advertisement
Design
Design and Software Architecture
The design phase
• The analysis phase describes what the system
should be doing
• The design phase describes how the system
will do it
– We’re working at the level of designing the code
itself (in part)
Different types of design
• Architecture design (SWE 443)
– Layers of the software (e.g. model, view, controller (MVC))
– Categories of classes (e.g. UI, Business logic, interfaces)
• Component design (SWE 332)
– Individual classes
• UI design (SWE 205)
– Sample screens
– UI guidelines
• Data design
– Database design
– Data structure design
Good design
• Design principles
– What you should try to do
• Design patters
– What other people have done and found
successful
• Design metrics
– How do you measure what you have done, to
decide if it is good?
Bad design
• Software that is rigid
– Hard to change because every change affects a
large part of the system. Example?
• Fragility
– When you make a change, unexpected bad things
happen. Example?
• Immobility
– Can’t reuse components successfully. Example?
Design principle examples
• Single responsibility principle (see video)
• Interface segregation principle (see video)
• Many more that we have talked about other
classes related to OO concepts of abstraction
and information hiding
Design pattern examples
•
•
•
•
Singleton (see video)
Factory (see video)
Visitor (see video)
Many many more
Design metrics
• Class size
• Methods per class
• Lack of cohesion (too many methods with
dissimilar purpose)
• Coupling between classes (we want to keep
this low)
• Depth of inheritance tree
• Method complexity
Quiz review
• What is a design principle?
– Single Responsibility Principle
– Interface Segregation Principle
• What is a design pattern?
– What is the point of the singleton pattern?
– What is the point of the factory pattern?
– What is the point of the visitor pattern?
• What is rigid software? Fragile software? Immobile
software?
• What is class cohesion?
• What is class coupling?
In-class exercises
• Imagine I am writing code for Amazon. What is
wrong with the following interface, if I will have
movies, t-shirts, and books all implement it? (it’s
pseudocode btw)
• interface Item{
–
–
–
–
}
double getPrice()
int getWeight()
int getLength()
String getItemName()
Download