http://flic.kr/p/87iHCA Software Design
3 SWEBOK KAs covered so far ^4 We’ve added one! Software Requirements Software Design Software Construction Software Testing Software Maintenance Software Configuration Management Software Engineering Management Software Engineering Process Software Engineering Models and Methods Software Quality Software Engineering Professional Practice Software Engineering Economics Computing Foundations Mathematical Foundations Engineering Foundations
3 SWEBOK KAs covered so far ^4 Software Requirements Software Design Software Construction Software Testing Software Maintenance Software Configuration Management Software Engineering Management Software Engineering Process Software Engineering Models and Methods Software Quality Software Engineering Professional Practice Software Engineering Economics Computing Foundations Mathematical Foundations Engineering Foundations Today’s topic
Software Design Subtopics We’ll touch on a bunch of these today!
Much of SE involves designing—be it artifacts, procedures, etc. What is design? Create component or process Not just code With desired properties Design objectives/constraints Involves decision making Design decisions Much of SE involves designing—be it artifacts, procedures, etc.
What is design? Create component or process With desired properties Not just code With desired properties Design objectives/constraints Involves decision making Design decisions What are some for software components?
Some desirable properties for software components Reusable Understandable Modifiable Extensible Maintainable Readable Reliable Efficient (as in performance) … Tradeoffs and prioritization may be necessary!
What is design? Create component or process With desired properties Not just code With desired properties Design objectives/constraints Involves decision making Design decisions How to make good decisions?
Making software design decisions Design principles: High-level, fundamental advice More general Design patterns: Tried and true template solutions to common problems More specific Conform to principles
Making software design decisions Design principles: High-level, fundamental advice More general Design patterns: Tried and true template solutions to common problems More specific Conform to principles Example principle:
Making software design decisions Design principles: High-level, fundamental advice More general Design patterns: Tried and true template solutions to common problems More specific Conform to principles Let’s see an example pattern
Model-View-Controller (MVC) Architectural Pattern Timeout! What do we mean by “architectural”?
Two levels of software design Architectural design: High-level structure of software system Detailed design: Low-level design of individual components/modules/classes
Model-View-Controller (MVC) Architectural Pattern Timeout! What kind of diagram is this?
Data Flow Diagrams components flows
Model-View-Controller (MVC) Architectural Pattern Being “architectural”, these components may contain many subcomponents (classes, etc.)
MVC Component Responsibilities Timeout! What do we mean by “responsibilities”?
Responsibility-Driven Design Frames object design as deciding How to assign responsibilities to objects How objects should collaborate What role each object should play in a collaboration http://flic.kr/p/btp5ZK
MVC Component Responsibilities View: Responsible for UI (buttons, etc.)
MVC Component Responsibilities Model: Business logic, domain objects
MVC Component Responsibilities Controller: Translates UI actions into operations on domain objects
MVC Component Responsibilities What principle does MVC follow?
MVC Component Responsibilities What principle does MVC follow?
MVC Component Responsibilities What good properties does this principle/pattern engender?
How Rails applies MVC
Browser sends HTTP request How Rails applies MVC Browser sends HTTP request
Router translates to action (method call) How Rails applies MVC Router translates to action (method call)
Controller performs actions on model How Rails applies MVC Controller performs actions on model
Model manipulates (CRUD) the database How Rails applies MVC Model manipulates (CRUD) the database
Model returns data to the controller How Rails applies MVC Model returns data to the controller
Controller passes data to view How Rails applies MVC Controller passes data to view
View creates HTML based on data How Rails applies MVC View creates HTML based on data
Controller sends HTTP response to browser How Rails applies MVC Controller sends HTTP response to browser
Must you write the entire model/view/controller? How Rails applies MVC Must you write the entire model/view/controller?
How Rails applies MVC Must you write the entire model/view/controller? No. Rails provides a framework, and you extend it But how?
Files to extend Rails app/views/… app/controllers/… config/routes.rb app/models/…
Ch. 2 Example: config/routes.rb “resources” line creates these routes
All controllers are part of this class hierarchy Ch. 2 Example: app/controllers/microposts_controller.rb All controllers are part of this class hierarchy
What kind of diagram is this? Ch. 2 Example: app/controllers/microposts_controller.rb Timeout! What kind of diagram is this?
UML Class Diagram classes inherits relation-ship
All controllers are part of this class hierarchy Ch. 2 Example: app/controllers/microposts_controller.rb All controllers are part of this class hierarchy
All model classes are part of this hierarchy Ch. 2 Example: app/models/micropost.rb All model classes are part of this hierarchy
Ch. 2 Example: app/views/users/index.html.erb ERb is embedded Ruby – Combines HTML & Ruby
How to “hook into” frameworks (like Rails) Extend framework classes Call framework methods Put files in certain places Follow naming conventions
MVC Question: What code would you change if you wanted to…
MVC Question: What code would you change if you wanted to… … change the colors/style of your webapp?
MVC Question: What code would you change if you wanted to… … change the colors/style of your webapp? View code
MVC Question: What code would you change if you wanted to… … change how sales tax is calculated?
MVC Question: What code would you change if you wanted to… … change how sales tax is calculated? Model code (and maybe Controller)
MVC Question: What code would you change if you wanted to… … add a survey form?
MVC Question: What code would you change if you wanted to… … add a new survey form? View, Controller, and maybe Model
MVC Question: What code would you change if you wanted to… … add validation that a form input is a legal email address?
MVC Question: What code would you change if you wanted to… … add validation that a form input is a legal email address? Model mainly (but maybe Controller and maybe View)
MVC Question: What code would you change if you wanted to… … change the behavior of an existing button?
MVC Question: What code would you change if you wanted to… … change the behavior of an existing button? Controller (maybe Model, maybe View)
What’s next?