16
SWC – Introduction to Software Architecture

SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

Embed Size (px)

Citation preview

Page 1: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC – Introduction to Software Architecture

Page 2: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW 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

Page 3: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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…?

Page 4: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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

Page 5: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC

Application

Architecture is Structure

GUI Control(Logic)

Model(Data)

Page 6: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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– …

Page 7: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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

Page 8: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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.

Page 9: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC

Layers

GUI LayerRegisterItemGUI Register

CustomerGUI…GUI

GUIUtility

Page 10: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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

Page 11: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC

Layers

Control Layer

Handler Package

Business Logic Package

RegisterItem

Handler

ShippingCost

Calculator

Page 12: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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

Page 13: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC

Layers

Model LayerDomain Model

Package

Data Collection Package

Persistence Package

Item ItemCatalog

ItemCatalog

DB

Page 14: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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)

Page 15: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

SWC

Application

1.Semester view

GUILayer

ControlLayer

ModelLayer

RegisterItemGUI

RegisterBorrowerGUI

RegisterItemHandler

RegisterBorrowerHandler

ItemCatalog

BorrowerCatalog

Item

Borrower

Page 16: SWC – Introduction to Software Architecture. What is SW Architecture? A large topic! We will only – for now – consider the most basic concepts in SW architecture

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”