2016-04-22: beyond solid: the package principles

30
Beyond SOLID: The Package Principles Red Panda Innovation Labs Code Words 2016-04-22 Christian Hujer CEO / CTO Nelkinda Software Craft Pvt Ltd

Upload: christian-hujer

Post on 16-Jan-2017

315 views

Category:

Software


0 download

TRANSCRIPT

Page 1: 2016-04-22: Beyond SOLID: The Package Principles

Beyond SOLID:The Package Principles

Red Panda Innovation LabsCode Words 2016-04-22

Christian HujerCEO / CTO Nelkinda Software Craft Pvt Ltd

Page 2: 2016-04-22: Beyond SOLID: The Package Principles

Agenda1.The Four Design Smells2.Origins and Reprise of SOLID3.ACCESS / CASE - The Package Principles

a.Package Cohesion Principlesb.Package Coupling Principlesc.Mnemonics

Page 3: 2016-04-22: Beyond SOLID: The Package Principles

DefinitionsSoftware Entity

Statement / line / method / class / package / serviceComponent

Logical (model / architecture / design) group of Software EntitiesPackage

Physical (e.g. directory, gem, jar) group of Software EntitiesCollocation

Putting things in the same Component / PackageCohesion

Things that are changed togetherCoupling

Dependency that potentially propagates change

Page 4: 2016-04-22: Beyond SOLID: The Package Principles

1.The Four Design Smells

Page 5: 2016-04-22: Beyond SOLID: The Package Principles

The Four Design Smells●Rigidity●Fragility●Immobility●Viscosity

Page 6: 2016-04-22: Beyond SOLID: The Package Principles

RigidityWhat is Rigidity?

Existing Code that causes Effort (known Effort)What causes Rigidity?

Coupling

Page 7: 2016-04-22: Beyond SOLID: The Package Principles

Fragility●What is Fragility?

○Existing Code that causes Risk (unknown Effort)●What causes Fragility?

○Coupling○Lack of Cohesion

Page 8: 2016-04-22: Beyond SOLID: The Package Principles

ImmobilityWhat is Immobility?

The difficulty (extra Effort) to reuse something.Rigidity and Fragility in the context of reuse.

What causes Immobility?CouplingLack of Cohesion

Page 9: 2016-04-22: Beyond SOLID: The Package Principles

ViscosityWhat is Viscosity?

Continuous extra Effort (Time)What causes Viscosity?

CouplingBad development setup / tools

Page 10: 2016-04-22: Beyond SOLID: The Package Principles

2.The SOLID Principles

A short reminder

Page 11: 2016-04-22: Beyond SOLID: The Package Principles

SRP - Single ResponsibilityOCP - Open-ClosedLSP - Liskov SubstitutionISP - Interface SegregationDIP - Dependency Inversion

Reminder of SOLID

Page 12: 2016-04-22: Beyond SOLID: The Package Principles

Design Principles and Design Patterns (2000)Mentions 10 principles● Principles of Object Oriented Class Design:

OCP, LSP, DIP, ISP● Principles of Package Architecture:

REP, CCP, CRP, ADP, SDP, SAP

Origin of SOLID

Page 13: 2016-04-22: Beyond SOLID: The Package Principles

3.The Package Principles

Page 14: 2016-04-22: Beyond SOLID: The Package Principles

The Package PrinciplesPackage Cohesion Principles

REP - Release Reuse EquivalencyCCP - Common ClosureCRP - Common Reuse

Package Coupling PrinciplesADP - Acyclic DependenciesSDP - Stable DependenciesSAP - Stable Abstractions

Page 15: 2016-04-22: Beyond SOLID: The Package Principles

3.a.Package Cohesion

Principles

Page 16: 2016-04-22: Beyond SOLID: The Package Principles

Release Reuse Equivalency Principle

“The granule of reuse is the granule of release.”

Reuse === ReleaseBundler / Gems, NPM, Jars / Maven, RPM, APT, Brew...

Page 17: 2016-04-22: Beyond SOLID: The Package Principles

Common Closure Principle (Cohesion) “Classes that change together belong together.”

⇒ This also is a nice pragmatic definition of cohesion and that cohesive elements should be collocated.I call it: Cohesion Collocation Principle

Page 18: 2016-04-22: Beyond SOLID: The Package Principles

Common Reuse Principle (Cohesion)

“Classes that aren’t reused together should not be grouped together.”

This is really the inversion of the idea that “Classes that change together belong together.”

Page 19: 2016-04-22: Beyond SOLID: The Package Principles

3.b.Package Coupling

Principles

Page 20: 2016-04-22: Beyond SOLID: The Package Principles

Acyclic Dependencies Principle“The dependencies between packages must not form cycles.”

Page 21: 2016-04-22: Beyond SOLID: The Package Principles

Stable Dependencies Principle“Depend in the direction of stability.”

Page 22: 2016-04-22: Beyond SOLID: The Package Principles

Stable Abstractions Principle“Stable packages should be abstract packages.”

Page 23: 2016-04-22: Beyond SOLID: The Package Principles

3.c.Mnemonics

How to remember all this stuff?!

Page 24: 2016-04-22: Beyond SOLID: The Package Principles

ACCESSYour new mnemonic acronymCombine to SOLID ACCESS

Page 25: 2016-04-22: Beyond SOLID: The Package Principles

ACCESS Mnemonic AcronymADP - Acyclic DependenciesCCP - Common Closure (Cohesion Collocation)CRP - Common ReuseREP - Release Reuse EquivalencySAP - Stable AbstractionsSDP - Stable Dependencies

Page 26: 2016-04-22: Beyond SOLID: The Package Principles

CASEA shorter mnemonic acronym

Combine to SOLID CASE

Page 27: 2016-04-22: Beyond SOLID: The Package Principles

CASE - A new mnemonic acronymCohesion / Common

CCP / CRP Common Closure / ReuseAcyclic

ADP Acyclic DependenciesStability

SAP / SDP Stable Abstractions / DependenciesEquivalence

REP Release Reuse Equivalency

Page 28: 2016-04-22: Beyond SOLID: The Package Principles

Related TopicsSoftware Architecture and DesignSoftware MetricsClean CodeRefactoringTDD, ATDD and BDDAgile Methods, Scrum, Extreme ProgrammingContinuous Integration / Delivery / Deployment, DevOpsSoftware CraftsmanshipLaw of Demeter / Tell Don’t AskCQS - Command Query SeparationProgramming Paradigms (Functional, Structured, Object-Oriented, Object-

Functional, Logic)

Page 29: 2016-04-22: Beyond SOLID: The Package Principles

References● SOLID and Package Principles, Design Smells:

Design Principles and Design Patterns (Robert C. Martin, 2000)

● ACCESS mnemonic: Christian Hujer● CASE mnemonic: Christian Hujer and Mark Burns

Page 30: 2016-04-22: Beyond SOLID: The Package Principles

Thank you!Questions?

Follow me on Twitter:@christianhujer