Why loose coupling?

Designing and Maintaining Software (DAMS)
 Louis Rose

Habitable Software Leaner

Avoids Duplication

Less Complex

Clearer

Loosely Coupled

More Extensible

More Cohesive

???

Epsilon A family of programming languages & developer tools

Epsilon A family of programming languages & developer tools

Epsilon

Eclipse IDE

Epsilon A family of programming languages & developer tools

Epsilon
 Languages

Epsilon
 Developer
 Tools

Eclipse IDE

Epsilon A family of programming languages & developer tools …











EOL

EOL DT Eclipse IDE

Power and Peril “Because well designed objects have a single responsibility, their very nature requires that they collaborate to accomplish complex tasks. This collaboration is powerful and perilous. To collaborate, an object must know something know about others. Knowing creates a dependency. If not managed carefully, these dependencies will strangle your application.” - Sandi Metz
 http://www.informit.com/articles/article.aspx?p=1946176

Coupling “The measure of the strength of association established by a connection from one
 module to another.” - Stevens, Myers and Constantine
 Structured Design
 IBM Systems Journal 13:2, 1974

Coupling “The measure of the strength of association established by a connection from one
 module to another.” - Stevens, Myers and Constantine
 Structured Design
 IBM Systems Journal 13:2, 1974

Coupling “The measure of the strength of association established by a connection from one
 module to another.” - Stevens, Myers and Constantine
 Structured Design
 IBM Systems Journal 13:2, 1974

Coupling is a Spectrum

http://www.ustudy.in/node/7980

Loosely coupled software is… Flexible: the impact of a change is small Reasonable: the impact of a change is localised Mobile: the system is decomposed into reusable parts - Bob Martin
 http://www.objectmentor.com/resources/articles/dip.pdf

DIP The argument in favour of loosely coupled software

Dependency Inversion Principle “High-level modules should not depend on low-level modules. Both should depend on abstractions.”
 
 “Abstractions should not depend on details. Details should depend on abstractions.” - Bob Martin
 http://www.objectmentor.com/resources/articles/dip.pdf

DIP Example

Monthly Sales Reporting

MySQL
 Database
 Access

DIP Example Monthly Sales Reporting

Sales
 Data
 Provider

MySQL
 Database
 Access

Ignore DIP when…

The low-level details are highly unlikely to change. The abstraction is the same as the low-level details.

Summary Coupling is a measure of the extent to
 which modules depend on each other Loose coupling enables flexible,
 reasonable and mobile code
 
 DIP tells us to avoid coupling high-level and
 low-level details; and to depend on abstractions

Designing and Maintaining Software (DAMS) - GitHub

Designing and Maintaining Software (DAMS). Louis Rose ... Loosely coupled software is… Flexible: the ... http://www.objectmentor.com/resources/articles/dip.pdf ... Monthly. Sales. Reporting. Sales. Data. Provider. MySQL. Database. Access ...

354KB Sizes 0 Downloads 114 Views

Recommend Documents

Designing and Maintaining Software (DAMS) - GitHub
ASTs are tree data structures that can be analysed for meaning (following JLJ in SYAC 2014/15) ... More Cohesive. Avoids Duplication. Clearer. More Extensible.

Designing and Maintaining Software (DAMS) - GitHub
%w.rack tilt date INT TERM..map{|l|trap(l){$r.stop}rescue require l};. $u=Date;$z=($u.new.year + 145).abs;puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick". $n=Module.new{extend. Rack;a,D,S,q=Rack

Designing and Maintaining Software (DAMS) - GitHub
Clear Documentation. Designing and Maintaining Software (DAMS). Louis Rose. Page 2. Bad documentation. Misleading or contradictory find_customer(id). CustomerGateway. Used to look up a customer by their customer number. Page 3. Bad documentation. Red

Designing and Maintaining Software (DAMS) - GitHub
R&D: sketch habitable solutions on paper, using UML. 4. Evaluate solutions and implement the best, using TDD. Probably start again at 3. 5. Give to the product owner to validate. Probably start again at 1. 6. Put into production for customers to eval

Designing and Maintaining Software (DAMS) - GitHub
Observers. Designing and Maintaining Software (DAMS). Louis Rose. Page 2. Page 3. Delivery people need to know when pizzas are ready class Pizza def initialize(delivery_person). @delivery_person = delivery_person end def bake cook # blocking call. @d

Designing and Maintaining Software (DAMS) - GitHub
When we are testing the way that a unit behaves when a condition is met, use a stub to setup the condition. Solution: use stubs for queries class Subscription ... def bill(amount) unless payments.exists(subscription_id: id) payments.charge(subscripti