Skip to content

Latest commit

 

History

History
226 lines (135 loc) · 6.51 KB

File metadata and controls

226 lines (135 loc) · 6.51 KB

Oasis Frontend

architecture + practices

=

effective process

Disclaimer

  • this is about tech, but
  • any particular tech is not that important
  • tech is applied by certain people to solve a specific task
  • trilateral fit between tech, people and a task

Disclaimer

what is described below is an account of the particular balance of the three that over the years we found to work for Oasis frontends

Problem

  • agile = iterative, incremental
  • high quality
  • long life span
  • developed by a team(cross functional)

People

  • open to general purpose programmers
  • usually proficient at frontend javascript
  • don't need to be blockchain experts to provide usefull input

Toolbox

general purpose tools composed to act in harmony:

  • Typescript
  • React with theme-ui(dai-ui) for the views
  • RxJS for everything else

Composition

Ideas/Patterns/Practices

Functional programming

  • simple subset of "functional programing"
  • immutability, higher order functions, curry
  • goes well with React, RxJS
  • easier to reason about functions than objects

Modularization

  • loosely coupled modules
  • explicit dependencies
  • late binding, application setup at runtime
  • modules available to presentations via react hooks
  • 'poor man's' dependency injection

Modularization/Examples

Bussines logic separation

  • state model data based
  • explicit representation
  • independent of presentation
  • module based implementation

Logicless presentations

  • logicless = look is the only concern
  • little use of useState
  • parallel work on presentation and bussines logic
  • multiple presentation modes possible (browser vs native client)

Bussines logic separation/Examples

RxJs Everywhere

bussines logic implemented as rx pipelines:

  • blockchain transactions
  • data transformations
  • user input
  • backend services

RxJs Everywhere/Examples

Development process

Notable practicies

  • storybooks
  • pipeline unit tests
  • both productivity and quality control

Focus

19th century

Focus

modern century

Pipeline unit testing

  • bussines logic at the pipeline level
  • pipelines mockable thanks to explicit dependencies
  • speeds up development, regression tests

Pipeline unit testing/Examples

manageVault.test.ts

Storybooks

  • fixes "operating field" for the iterative act of ui development
  • speeds up exhaustive exploration of ui state space
  • communication tool - generated on each commit, available to non technical team members
  • quality control aspect:
    • "manual" visual inspection
    • automated visual testing (to be integrated)

Storybooks/Examples

Hypothesis

it should be easier to develop with pipeline unit tests and storybooks than without

  • better focus
  • quick iterative feedback
  • works for storybooks
  • not so clear with pipeline unit tests

Test piramid

  • basic unit tests
  • pipeline unit tests
  • storybooks
  • minimal functional tests (endtest.io)

Unequal battle against entropy

The second law of thermodynamics, in principle, states that a closed system's disorder cannot be reduced, it can only remain unchanged or increase. A measure of this disorder is entropy. This law also seems plausible for software systems; as a system is modified, its disorder, or entropy, tends to increase. This is known as software entropy.

wikipedia

The end

Scrapbook

Using RxJS to build bussiness models

  • pipelines created by functions
  • parameters are explicit, treated as dependencies
  • late binding, application setup/arming in AppContext.ts
  • pipelines available to views via hooks: useAppContext, useObservable
  • non functional aspects like caching configurable at setup time

AppContext.ts setup dependencies

  • create pipelines that forms bussines model of the app
  • model distributed to the views via React context
  • models that require parameters at the moment of usage are just curried and memoized functions

React RXJS glue

  • useAppContext
  • useObservable

Backend data processing

Examples

Handling user input

  • reducer pattern rxjs way
  • state machines when necessary managed by pipelines Examples: simple, complicated

Blockchain access

Osis Commons

  • web3context - web3react based
  • connectors: mm, hw wallets, wallet link/connect, others
  • call definitions
  • transactions definitions
  • transactions.ts module