Design principles in software development

Post on 15-Jul-2015

59 views 3 download

Tags:

transcript

Design PrinciplesRinat Khabibiev

* www.ExigenServices.com

DESIGN PRINCIPLES

● KISS (Keep It Simple, Stupid!) ● YAGNI (You Aren't Going to Need It) ● Don't make me think ● Write code for the maintainer ● DRY (Don’t Repeat Yourself) ● SOLID

Table of contents

* www.ExigenServices.com

DESIGN PRINCIPLES: KISS

Best code is not written code.

Best solution is make it unnecessary.

Keep It Simple Stupid! (KISS)

* www.ExigenServices.com

DESIGN PRINCIPLES: YAGNI

• Every feature need to be tested after every code refactoring,

do you really need all this stuff?

• Ideal solution is YAGNI.

You Aren't Going to Need It (YAGNI)

* www.ExigenServices.com

DESIGN PRINCIPLES: DON'T MAKE ME THINK

• I do not have enough time to think how it works.

• Comments is good but it isn’t crucial.

- One does not simply write code

Don't make me think

* www.ExigenServices.com

DESIGN PRINCIPLES: WRITE CODE FOR THE MAINTAINER

• Avoid spaghetti code.

• Every entity should be available by Ctrl/Cmd + click.

This is crazy maintainer, he knows where you live

Write code for the maintainer

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• Every piece of knowledge must have single, unambiguous,

obvious representation.

Don’t Repeat Yourself (DRY)

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• One goal for single entity.

SOLID: Single responsibility

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• Software entities should be closed for modification.

• Software entities should be open for extension.

SOLID: Open/closed principle

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• If B is subclass of A then B objects may be used instead of A

objects.

SOLID: Liskov substitution principle

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• Several specialized interfaces is better than one universal.

SOLID: Interface segregation principle

* www.ExigenServices.com

DESIGN PRINCIPLES: SINGLE RESPONSIBILITY

• High-level modules should not depend on low-level modules.

• Abstractions should not depend on details.

Example of bad design

SOLID: Dependency inversion principle

* www.ExigenServices.com

PHPUNIT: MOCK OBJECTS

The end