Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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.

Slide 3

Slide 3 text

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.

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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”.

Slide 6

Slide 6 text

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.

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Some typical layerings

Slide 9

Slide 9 text

User input (mouse event) command (e.g. Flux Action) domain model view state model View presentation Update UI by some user action

Slide 10

Slide 10 text

User input (mouse event) command (e.g. Flux Action) Update view state model Update view presentation Update only UI by some user action

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

HTTP abstraction (and TCP abstraction… ?) REST API abstraction Update domain model Update view model Update view presentation Receive a HTTP response & Display it

Slide 13

Slide 13 text

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/flatmap computations.

Slide 14

Slide 14 text

The benefit of Reactive Extensions • Unify an asynchronous interface. • Make each layer boundaries to Observable. • We can compute Observable with using their operators. • Code a data flow graph which are produced from asynchronous events.

Slide 15

Slide 15 text

Layering example Driver Adapter Domain Domain Model Gateway HTTP Socket Repository DB Driver View Model View Command (Intent)

Slide 16

Slide 16 text

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.

Slide 17

Slide 17 text

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.

Slide 18

Slide 18 text

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.

Slide 19

Slide 19 text

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…

Slide 20

Slide 20 text

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 :(

Slide 21

Slide 21 text

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.