Clean Software Design - DevNot Summit Istanbul 2017

Post on 22-Jan-2018

824 views 0 download

Transcript of Clean Software Design - DevNot Summit Istanbul 2017

CLEANDESIGNSOFTWARE

LEMi ORHAN ERGiNagile software craftsman @ iyzico

codedesign processteammanagement

organizationtests customer

ux & ui culture officearchitecture infrastructure

ux & uimeetingssecurity

things smell…

things smell…and if something smells bad, it means it is not clean

codedesign processteam organization

LEMi ORHAN ERGiNagile software craftsman @ iyzico

/lemiorhan lemiorhanergin.com @lemiorhan

agile practice lead at iyzico developing software since 2001

worked at Sony, eBay/GittiGidiyor, ACM consultant, architect, mentor, developer

founder of Software Craftsmanship Turkey ex community leader of Agile Turkey

meetup.scturkey.org agileturkey.org

dev.iyzipay.com

Jack W. Reeves

The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

What is So"ware Design?

Source code is the real so"ware designDesigning so!ware is an exercise in managing complexity

Jack W. ReevesWhat is Software Design? The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

The so"ware design is not complete until it has been coded and testedTesting is part of the process of refining the design

Jack W. ReevesWhat is Software Design? The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

ProgrammingSource Code

SOFTWARE DESIGN

Automated Testing (Unit, Functional, etc.)

The very first value of so"ware is

Robert C. MartinAuthor of Clean Code and Clean CoderOwner of cleancoders.com training site

to tolerate and facilitate on-going changes

Robert C. MartinAuthor of Clean Code and Clean CoderOwner of cleancoders.com training site

The very first value of so"ware is

Each city has to be renewed in order to meet the needs of its populace. So!ware-intensive systems are like that.

Grady Booch

Developed UMLWrote foreword to “Design Patterns” and “Technical Debt” books

Istanbul, TurkeyCredit: European Space Imaging

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

Testing and Refactoring are first class citizens of so"ware designTests should pass Refactoring should be continuous

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

clean?

Automated Testing (Unit, Functional, etc.)

COUPLINGWhen readfile() is changed, do you change writeFile() too? It shows how many places we need to change

Two elements are loosely coupled if they are not shown in the same diff

Kent BeckThe creator of extreme programmingOne of the signatories of the Agile ManifestoPioneered software design patterns and TDD

COHESIONDo you search a lot where to change? It shows how easy to find the places we need to change

How many files at any one time is still open for edit shows the level of cohesion

Nat PryceCo-Author of Growing Object-Oriented Software Guided by TestsEarly adopter of XP

ProgrammingSource Code

SOFTWARE DESIGN

RefactoringLow Coupling High Cohesion

Automated Testing (Unit, Functional, etc.)

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

Refactor namings

(how) mailer.useGmailSmtpSendEmail (what) mailer.sendEmail (why) mailer.sendActivationEmail

Reveal what you are doing or why you are doing, not how you are doing

Refactor namings

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

manager handler

helper utils

facade service

validator converter

repository wrapper interceptor controller parser gateway generator dto, vo, entity

Know what these really means

Split methods, Create new abstractions, Re-organize code

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High CohesionBe aware of leaky abstractions. Do not expose details and limitations of its underlying implementation to its users that should ideally be hidden away.

ProgrammingSource Code

RefactoringLow Coupling High Cohesion

Automated Testing (Unit, Functional, etc.)

and Code ReviewPair Programming

When code is reviewed, the design will be cleaner.

ProgrammingSource Code

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

and Code ReviewPair Programming

Pair prog makes you code cheaper due to spending less time in decision taking, bug fixing and debugging.

Find and remove duplications

ProgrammingSource Code

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

and Code ReviewPair Programming

It’s not about code duplication, it’s about knowledge duplication. Don’t repeat yourself. Every piece of knowledge should have one and only one representation.

ProgrammingSource Code

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

and Code ReviewPair ProgrammingKeep it

SMALLclasses, interfaces, responsibilities, methods, modules, components…

use design pa!erns wisely

ProgrammingSource Code

Refactoring

Automated Testing (Unit, Functional, etc.)

Low Coupling High Cohesion

and Code ReviewPair Programming

theseSTOPSingletons? Sharing state Static & new keywords Framework slave coding Premature optimization Primitive obssession Huge upfront design Controling flows with exceptions

or use them wisely

ProgrammingSource Code

RefactoringLow Coupling High Cohesion

Automated Testing (Unit, Functional, etc.)

and Code ReviewPair Programming

LEMi ORHAN ERGiNagile software craftsman @ iyzico

/lemiorhan lemiorhanergin.com @lemiorhan