simplicity

Post on 27-Jan-2015

115 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Building working software is hard. But it's so much harder to build software that is easy to change. Yet this is a prerequisite for being truly agile, and a key enabler of agility is simplicity. But what exactly does simplicity mean and why is it so hard to achieve? It looks like complexity creeps in as soon as you stop paying attention, and most of it is accidental. Luckily, there are practical ways to get to simplicity by following good design principles and choosing simpler tools.

TRANSCRIPT

simplicity 0.3

Osvaldas Grigaso.grigas@gmail.com

complexity 0.3

Osvaldas Grigaso.grigas@gmail.com

inspired by

DanNorth

RichHickey

J.B. Rainsberger

Michael Feathers

Edsger Dijkstra (1980)

Computing's central challenge,"How not to make a mess of it",

has not been met.

agile

agile

continuous improvementbased on frequent feedback

iterative development

incremental development

DONE

embrace the transient natureof your code

Russ Miles

Complexity is the silent killer of delivering change at the right time.

simplicity is prerequisite for agility

what is simplicity ?

Nothing is more simplethan a single giant button

MacBook Wheel

what "simple" isn’t ...

what "simple" isn’t ...

familiar / convenient

what "simple" isn’t ...

familiar / convenient

small / concise

what "simple" isn’t ...

familiar / convenient

small / concise

beautiful / elegant

“Simplicity -- the art of maximizing the amount of work not done -- is essential.”

from the agile principles

YAGNI

from the agile principles

“Simplicity -- the art of maximizing the amount of work not done -- is essential.”

“Technical excellence andgood design enhances agility.”

from the agile principles

Martin Fowler

Design is there to enable you tokeep changing the software easily.

when it comes to design ...

COMPLEXITY SUCKS

SIMPLICITY RULES

COMPLEXITY SUCKS ...

COMPLEXITY SUCKS ...… your brain power

COMPLEXITY SUCKS ...… your brain power

Rich Hickey

Once your software is of a certain size, complexity is gonna

dominate what you can do.

essentialcomplexity

essentialcomplexity

your code

essentialcomplexity

your code

libra

ries

frameworks

essentialcomplexity

langua

geruntime

your code

libra

ries

frameworks

accidental

complexity

essentialcomplexity

SIMPLICITY RULES ...

SIMPLICITY RULES ...… are …

SIMPLICITY RULES ...… are …

The 4 Rules of Simple Design

SIMPLICITY RULES ...… are …

The 4 Rules of Simple Design1) passes all tests

SIMPLICITY RULES ...… are …

The 4 Rules of Simple Design1) passes all tests

2) clear, expressive names

SIMPLICITY RULES ...… are …

The 4 Rules of Simple Design1) passes all tests

2) clear, expressive names3) no duplication

SIMPLICITY RULES ...… are …

The 4 Rules of Simple Design1) passes all tests

2) clear, expressive names3) no duplication4) minimal

rule #4: minimal

the less code,the better

code folding

codegenerators

dependencymanagers

stop typing.

think!

test-first(TDD / BDD)

rule #3: no duplication

primitive obsession

duplication in behavior

data clump

duplication in structure

refactoring

rule #2: clear, expressive names

small, focused methods

reduce cyclomatic complexity

small, focused classes

single responsibility

AccountService

AccountManager

AccountHandler

AccountUtils

AccountHelper

AccountImpl

AccountData

AccountDTO

AccountInfo

AccountDetails

AccountObject

AbstractAccount

BaseAccount

CustomAccount

SimpleAccount

refactoring

rule #1: passes all tests

unit testing

testability & good design

testability & good design

(but not integration tests)

inheritance-based design

wget -qO- http://c2.com/ | tr -cs '[:alpha:]' '\n' | sort | uniq

composition

dependencies

auto-import

refactoringtools

A

G

F

DC

introduce indirection

A

B

E G

F

DC

introduce indirection

A

B

E G

F

DC

followthe law of Demeter

introduce indirection

modularity

coupling

add an interface?

layered architectures

add remoting?

SOAP

enterprise grade decoupling?

ESB

enterprise grade decoupling?

ESB

assumptions

assumptions

interface segregation

tell, don’t ask

high cohesion

dependency inversion

role

anti-corruption layer

adapter

role

notify

Payment Order

Auditor

FinancialEvent

Listener

Mongo Audit Trail

log

AuditTrail

MongoAudit

Recordsinsert

Payment Order

AuditDAO

AuditDAOImpl

insert

further decoupling

queue

publish subscribe

use cases& business rules

framework

persist

ence

fram

ewor

k

web

DB

infrastructure

messagingQUEUE

task

scheduler

WS

DomainLogic

FrameworkFramework

DomainLogicDomainLogic

FrameworkFramework

accidentalcomplexity

complexityleak

@Entity@Table(name = "orders", schema = "com"})public class Order implements Serializable {

@Id @GeneratedValue(strategy = SEQUENCE, generator = "order_seq") @Column(name = "ID", unique = true, nullable = false) private Integer id;

@Column(name = "NUMBER", nullable = false, length = 8) private String number;

@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name = "order_items", catalog = "com", joinColumns = {@JoinColumn(name = "ORDER_ID", updatable = false, nullable = false)}, inverseJoinColumns = {@JoinColumn(name = "ITEM_ID", updatable = false, nullable = false)}) private Set<Item> items = new HashSet<Item>();

}

the law of leaky abstractions

home-grownframeworks

libraries

state& side effects

values& pure functions

functional style imperative style

functional style

expressions

imperative style

statements

functional style

expressions

immutable values

imperative style

statements

mutable state

functional style

expressions

immutable values

data transformations

imperative style

statements

mutable state

side effects

functional style

expressions

immutable values

data transformations

recursion &polymorphism

imperative style

statements

mutable state

side effects

looping &branching

stepping out ofcomfort zone

Edsger Dijkstra (1980)

Computing's central challenge,"How not to make a mess of it",

has not been met.

I‘mdone

top related