Lecture06 Architecture
Lecture06 Architecture
Code
One answer
Requirements
A miracle happens!
Code
A better answer
Requirements
Provide a high
level framework to
Software Architecture build and evolve
the system
Code
Box‐and‐arrow diagrams
Very common, hugely valuable.
But, what does a box represent? an arrow? a
layer? adjacent boxes?
SW architecture gives these meaning
SW architecture gives these meaning
An architecture is expressed by
components and connectors
d
• Components
Co po e ts dedefine the basic computations
e t e bas c co putat o s
comprising the system, and their behaviors
– abstract data types, filters, etc.
• Connectors define the interconnections between
components
– procedure call, event announcement, asynchronous
message sends, etc.
• The line between them may be fuzzy at times
The line between them may be fuzzy at times
– Ex: A connector might (de)serialize data, but can it
p
perform other, richer computations?
p
An architecture bridges the gap
between requirements and code
A good architecture
A good architecture
• Satisfies
Satisfies functional and performance
functional and performance
requirements
• Manages complexity
Manages complexity
• Accommodates future change
• Also: reliability, safety, understandability,
compatibility, robustness, …
7
Divide and conquer
Divide and conquer
• Benefits of decomposition:
– Decrease size of tasks
– Support independent testing and analysis
– Separate work assignments
Separate work assignments
– Ease understanding
• Use of abstraction leads to modularity
– Implementation techniques: information hiding, interfaces
• To achieve modularity, you need:
– Strong cohesion within a component
within a component
– Loose coupling between components
– And these properties should be true at each level
Qualities of modular software
Qualities of modular software
• decomposable
– can be broken down into pieces
b b k d i t i
• composable
p
– pieces are useful and can be combined
• understandable
– one piece can be examined in isolation
• has continuity
– reqs. change affects few modules
• protected / safe
9
– an error affects few other modules
Interface and implementation
• public interface: data and behavior of the object that
can be seen and executed externally by "client" code
• private implementation: internal data and methods in
the object, used to help implement the public
the object, used to help implement the public
interface, but cannot be directly accessed
• client: code that uses your class/subsystem
– Example: radio
• public interface is the speaker, volume buttons, station dial
• private implementation is the guts of the radio; the transistors,
capacitors, voltage readings, frequencies, etc. that user should not
see
10
UML module diagrams
UML module diagrams
• Express
– Subclassing
– Use (dependence)
Use (dependence)
Loose coupling
• coupling
p g assesses the kind and q
quantity
y of
interconnections among modules
* -End1
End1
-End2
End2
*
-End6 *
-End3 * *
* -End16
* -End25 * -End23
* -End11
* -End26 * -End24
End24
* -End4
-End5
* *
-End13
* -End9
* -End7 * -End19
* -End12
* -End14 * -End8
* -End20
-End10 -End15 *
* * -End18 -End22
-End17
*
*
Tightly or loosely coupled?
Strong cohesion
• cohesion refers to how closelyy the operations
p
in a module are related
• Ti
Tight
h relationships
l i hi iimprove clarity
l i andd
understanding
• No schizophrenic classes!
Strong or weak cohesion?
class Employee {
public:
…
FullName GetName() const;
Address GetAddress() const;
PhoneNumber GetWorkPhone() const;
…
bool IsJobClassificationValid(JobClassification jobClass);
bool IsZipCodeValid (Address address);
bool IsPhoneNumberValid (PhoneNumber phoneNumber);
…
SqlQuery GetQueryToCreateNewEmployee() const;
S lQ
SqlQuery G tQ
GetQueryToModifyEmployee()
T M dif E l () const;
t
SqlQuery GetQueryToRetrieveEmployee() const;
…
}
An architecture helps with
• System understanding – describes the interactions
between modules
Performance
Installation
(execution)
equ e e s
Requirements
Req irements
Requirements
Booch
Web application (client-server)
Booch
Model View Controller
Model-View-Controller
User
sees uses
Separates the application
object (model) from the
View Controller
way it is represented to
the user (view) from the
updates manipulates way in which the user
Model controls it (controller).
Application
Pipe and filter
Pipe – passes the data
Blackboard systems have traditionally been used for applications requiring
complex interpretations of signal processing such as speech and pattern
complex interpretations of signal processing, such as speech and pattern
recognition.
27
Hearsay‐II:
Hearsay II: blackboard
blackboard
28