31
Design Principles in the Functional World Daniel Leon Optymyze [25 th of October 2014]

Design principles in the functional world

Embed Size (px)

Citation preview

Page 1: Design principles in the functional world

Design Principles in the Functional World

Daniel Leon

Optymyze

[25th of October 2014]

Page 2: Design principles in the functional world
Page 3: Design principles in the functional world

Motivation

Page 4: Design principles in the functional world

Question list

1) Design patterns vs design principles2) Anything else besides design type?3) How about functional principles?

Page 5: Design principles in the functional world

Principle vs patternPrinciple Pattern

Rules Concrete examples

Language/paradigm independent Language/paradigm dependent

Generic diagrams Class UML

Page 6: Design principles in the functional world

Types of programming principles1) Design principles

Single responsibilityOpen/closedLiskov substitutionInterface segregationDependency inversion

2) Packaging principlesCohesionCoupling

Page 7: Design principles in the functional world

Object-oriented principlesSingle Responsibility Principle -  A class should have one, and only one, reason to change.

Open-Closed Principle - You should be able to extend a classes behavior, without modifying it.

Liskov Substitution Principle - Derived classes must be substitutable for their base classes.

Interface Segregation Principle – Make fine grained interfaces that are client specific.

Dependency Injection Principle - Depend on abstractions, not on concretions.

Page 8: Design principles in the functional world

Functional principles ?Single Responsibility Principle -  A function should have one, and only one, reason to change.

Open-Closed Principle - You should be able to extend a function behavior, without modifying it.

Liskov Substitution Principle - Derived functions must be substitutable for their base functions.

Interface Segregation Principle – Make fine grained traits that are client specific.

Dependency Injection Principle - Depend on traits, not on concretions.

Page 9: Design principles in the functional world
Page 10: Design principles in the functional world

Creational design patterns

Page 11: Design principles in the functional world

Factory

Page 12: Design principles in the functional world

Lazy initialization

Page 13: Design principles in the functional world

Singleton

Page 14: Design principles in the functional world
Page 15: Design principles in the functional world

Structural design patterns

Page 16: Design principles in the functional world

Adapter

Page 17: Design principles in the functional world

Decorator

Page 18: Design principles in the functional world
Page 19: Design principles in the functional world

Behavioral design patterns

Page 20: Design principles in the functional world

Chain of responsibility

Page 21: Design principles in the functional world

Command

Page 22: Design principles in the functional world

Command

Page 23: Design principles in the functional world

Dependency inversion

Page 24: Design principles in the functional world

Null object

Page 25: Design principles in the functional world

Strategy

Page 26: Design principles in the functional world
Page 27: Design principles in the functional world

Conclusions

• Patterns are to principles what are implementations to patterns

• Sometimes to much design patterns in code shows the lack of design principles implementation in the language

• Java 8 still has some work to do in order to catch-up Scala

Page 28: Design principles in the functional world

My reaction to Java 8

Page 29: Design principles in the functional world

Bibliographyhttp://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf

http://java.dzone.com/articles/design-patterns-decorator http://pavelfatin.com/design-patterns-in-scala

Page 30: Design principles in the functional world
Page 31: Design principles in the functional world

Design Principles in the Functional WorldDaniel Leon[Optymyze]

[25th of October 2014]

Please fill the online evaluation form after event