my thought about beyond flux

21
Thought about beyond Flux Layering an application for scalability Tetsuharu OHZEKI Github:saneyuki

Upload: tetsuharu-ohzeki

Post on 24-Jan-2017

1.168 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: My thought about beyond flux

Thought about beyond FluxLayering an application for scalability

Tetsuharu OHZEKI

Github:saneyuki

Page 2: My thought about beyond flux

CAUTION

• This is still a note of my thought.

• Some points are unclear and opaque.

• I believe that we should practice a way which might not get a glory but never lose for building an application.

Page 3: My thought about beyond flux

Keypoints of Flux “pattern”

• Unidirectional data flow + observer pattern + command pattern

• It’s just a Model-View-Intent.

• http://staltz.com/mvi-freaklies/

• WPF’s “Command” is similar terminology.

• One of design patterns than an architecture.

Page 4: My thought about beyond flux

Escape from “Flux” enclosure!Flux is just a pattern!

Page 5: My thought about beyond flux

Separate a “Responsibility”

• We should separate a “Responsibility” rather than “Concern”.

• The most important point is “cross over the boundary of responsibility”.

• In other word, this “responsibility” is a “context”.

Page 6: My thought about beyond flux

Separate an internal “layer”

• An internal design is layered naturally if you separate the boundary of a responsibility.

• Typical cases: OS’ layering architecture, OSI reference model.

• Hardware abstraction, low level API, providing a process lifecycle and a higher level API, running an actual application domain based on APIs, present a computation result, and etc.

Page 7: My thought about beyond flux

Example: Windows 7 Architecture

Mark E. Russinovich, David A. Solomon, Alex Ionescu(2012)『インサイドWINDOWS 第6版 上』株式会社クイープ訳, Microsoft Press, p53.

Page 8: My thought about beyond flux

Some typical layerings

Page 9: My thought about beyond flux

User input (mouse event)

command (e.g. Flux Action)

domain model

view state model

View presentation

Update UI by some user action

Page 10: My thought about beyond flux

User input (mouse event)

command (e.g. Flux Action)

Update view state model

Update view presentation

Update only UI by some user action

Page 11: My thought about beyond flux

User input (mouse event)

command (e.g. Flux Action)

domain model

REST API abstraction

HTTP abstraction (and TCP abstraction… ?)

Dispatch a HTTP request by user action

Page 12: My thought about beyond flux

HTTP abstraction (and TCP abstraction… ?)

REST API abstraction

Update domain model

Update view model

Update view presentation

Receive a HTTP response & Display it

Page 13: My thought about beyond flux

Each “layer” is a data transform layer

• A data flow in application is a stacked data transformations which is a result of each layers.

• As a simplified concept, their basis is a result of many map/flatmapcomputations.

Page 14: My thought about beyond flux

The benefit of Reactive Extensions

• Unify an asynchronous interface.

• Make each layer boundaries to Observable<T>.

• We can compute Observable<T> with using their operators.

• Code a data flow graph which are produced from asynchronous events.

Page 15: My thought about beyond flux

Layering example

Driver

Adapter

Domain Domain Model

Gateway

HTTP Socket

Repository

DB Driver

View Model

View

Co

mm

and

(Inten

t)

Page 16: My thought about beyond flux

Is this a Domain Driven Development?

• My interpretation is that domain driven development is one of practical system.

• I feel there are mixed into some system-specific practices and generic practices.

• This session focuses into a generic thought about an architecture

• e.g. layering.

Page 17: My thought about beyond flux

This vision is too rich!

• This is a high level abstract concept.

• Rightfully, some hardware/environment/performance limitations limits a materialization of this concept.

• Software engineering is just filling this gap, and the flower of it.

Page 18: My thought about beyond flux

Where is the framework?

• This does not suppose any framework libraries.

• It’s inevitable that All software codebase/repository make some style/framework in them.

• The difference is whether cutting out internal materials from it.

Page 19: My thought about beyond flux

dependency relation (1)

• In Clean Architecture context, domain model layer should not depend on presentation (driver) layer.

• I agree it as the basic principle.

• But it’s hard to apply it strictly…

Page 20: My thought about beyond flux

dependency relation (2)

• There need a “connection layer” which connects HAL and specific domain layer.

• Some runtime supports like dependency injection would cover and help this connective operation.

• So it would be difficult that all relationships among layers are a unidirectional dependency perfectly.

• We cannot defined a simple rules :(

Page 21: My thought about beyond flux

dependency relation (3)

• In a general usecase, its rule should be confirmed that “domain layer don’t touch a driver layer directly”.

• However, of course, we would need to accept some dirty pit holes to resolve performance sensitiveness.