Upload
warren-bridges
View
218
Download
1
Embed Size (px)
Citation preview
SWC – Introduction to Software Architecture
SWC
What is SW Architecture?
• A large topic!• We will only – for now – consider the most
basic concepts in SW architecture• Purpose mainly to have a (small) vocabulary,
for discussing organisation of classes• Think of SW architecture as a tool or guideline
for class organisation
SWC
Architecture is Structure
• We know that ”classes should have as few responsibilities” as possible
• Should classes then only have one method!?• What types of ”responsibilities” are we talking
about…?
SWC
Architecture is Structure
• A typical (large) program involves– User interaction (GUI)– Business logic and control (rules, Use Cases,…)– Data storage (both in memory and persistent)
• A class should usually not have responsibilities within more than one of the above categories
SWC
Application
Architecture is Structure
GUI Control(Logic)
Model(Data)
SWC
Architecture is Structure
• Why only responsibilities within one category?• Usually, we aim for flexibility• Examples:– Being able to replace the GUI, without changing
the remaining classes– Being able to replace the storage strategy, without
changing the remaining classes– …
SWC
Architecture is Structure
• We often refer to the elements in a SW architecture in terms of layers
• The top-level architecture typically contains:– A GUI layer– A Control layer– A Model layer
• Inside a layer, we can define packages of classes
SWC
Layers
• What goes into the GUI layer…?• All classes that are related to implementing
the GUI in itself (frames, panes, controls, event handlers, etc.)
• Could also contain utility classes related to GUI, GUI base classes, etc.
SWC
Layers
GUI LayerRegisterItemGUI Register
CustomerGUI…GUI
GUIUtility
SWC
Layers
• What goes into the Control layer…?• Classes that control the ”flow” of a Use Case,
i.e. handler-type classes• Classes that contain logic (rules, procedures,
etc.) for the business domain
SWC
Layers
Control Layer
Handler Package
Business Logic Package
RegisterItem
Handler
ShippingCost
Calculator
SWC
Layers
• What goes into the Model layer…?• Classes that model domain objects, like Car,
Item, Boat, Order, Contract, etc.• Classes that manages collections of data, i.e.
catalog-type classes• Classes that manage persistent data storage,
like database-oriented classes
SWC
Layers
Model LayerDomain Model
Package
Data Collection Package
Persistence Package
Item ItemCatalog
ItemCatalog
DB
SWC
1.Semester view
• We look at architecture in a slightly simplified way during 1.semester– We only think in terms of layers and classes– There are no classes for persistent data storage
involved, only domain and catalog classes– We rarely have any dedicated classes for business
logic and rules (logic is in handler classes)
SWC
Application
1.Semester view
GUILayer
ControlLayer
ModelLayer
RegisterItemGUI
RegisterBorrowerGUI
RegisterItemHandler
RegisterBorrowerHandler
ItemCatalog
BorrowerCatalog
Item
Borrower
SWC
Architecture is Structure
• Think of a SW architecture as a tool for obtaining structure on the set of classes in your application
• Classes should fit naturally into your architec-ture; if not, you may need to redesign, break a class into smaller classes, etc.
• If you do proper design work, your classes will fit the architecture almost ”for free”