[Frontend Masters] Hardcore Functional Architecture Patterns in JavaScript

0
[Frontend Masters] Hardcore Functional Architecture Patterns in JavaScript

Hardcore Functional Architecture Patterns in JavaScript – Learn patterns to architect your JavaScript programs using functional programming techniques. On this course, you’ll libraries and functions using functional programming patterns. You’ll additionally learn new tools to use, such as Monoids, Monad Transformers, Free Monads, and Lenses. See functional programming in action.

Introduction

  • Introduction Brian introduces the course by explaining that structure is about grouping issues, and offers a refresher on the principle practical programming properties.
  • Naming & Grouping Brian introduces the identification functor, and explains that it takes a price and returns a price. The identification functor is based on class idea, which states that practical programming necessitates each composition and identification.
  • Composition Structure Brian compares working with one huge operate that does all of the work with little capabilities that signify small functionalities from a given utility, and says that this course will deal with composition involving a number of small capabilities.
  • Normalize Impact Sorts Brian explains that normalizing the impact sorts inside the app is an effective tenet to permit each factor inside the app to compose, and says that other ways to resolve this problem can be reviewed within the subsequent sections.

Semigroups & Monoids

  • What’s a Semigroup Brian explains {that a} semigroup is a construction that incorporates an associative operation, and that’s closed. Rationalization is given for why a closed and associative.
  • Creating Semigroup Knowledge Sorts Brian explains the best way to carry an operation by a kind to have the ability to program an interface.
  • Defining Empty Id Brian explains that monoids are semigroups with an identification, and reside codes examples of monoids.
  • foldMap Brian explains that foldMap takes parts, maps them right into a sure sort, after which folds them.
  • Semigroup vs Monoid Brian explains the principle variations between a monoid and a semigroup. A semigroup can have an empty identification.
  • Id Functor Brian explains that functors are monoids, and demonstrates the benefits of programming to an interface. Programming to an interface means referring to a extra summary stage than a category.
  • Concat Technique Brian demonstrates the best way to concat completely different functors collectively, and the best way to use the concat methodology to affix completely different monoids.
  • Monoid Workouts The scholars are instructed to code completely different monoid workout routines.
  • Monoid Options Brian reside codes the options to the monoid workout routines.
  • Monoid Use Instances Brian shares two use circumstances for monoids to demonstrates how monoids can be utilized in on a regular basis code and make code cleaner.
  • Homomorphisms & Monads Brian provides an instance of a homomorphism. A homomorphism takes two parts and combines them then goes by a kind transformation. At a excessive stage, when combining a monoid operation and flattening two sorts, these sorts develop into monads.
  • Making a Validation Library Brian demonstrates the best way to architect an app round validation, and builds a validation library that mixes completely different sorts of validations, and offers errors or a closing object.
  • Creating Success & Fail Monoids Brian demonstrates the best way to create success and failure sorts, and provides a concat methodology, due to this fact constructing two monoids.
  • Creating the Validation Monoid Brian continues to develop the validation library, and demonstrates the best way to create a validation monoid.

Function Modeling

  • Operate Modeling Brian explains that, as a substitute of modeling information, it’s doable to mannequin a operate. Useful modelling permits to make use of completely different strategies.
  • The Reader Monad Brian demonstrates the best way to use the Reader monad so as to add dependency connections and thread invisible environments by a whole program.
  • The Endo Functor Brian clarify that the endofunctor is named endo as a result of it solely works with the identical type of sorts.
  • contramap Brian explains that contramap maps over inputs, combines two reducers that have been beforehand contermapped demonstrating that contermap hits arguments earlier than it is available in.
  • Operate Modeling Practices Brian reside codes operate modeling and demonstrates the best way to use Endofunction, predicate, and the best way to use the contramap or contravariant functor. An endofunction is a operate that has an equal area and codomain.
  • Operate Modeling Equivalences Brian demonstrates the best way to mix reducer capabilities, and remodel them into an Endo sort, and explains that the 2 are equal.
  • Composing Functors Brian explores several types of functors utilizing the map, extract and fork strategies, and explains that functors have completely different identities, may be composed collectively, and have a class inside which they act like capabilities.
  • Monad Transformers Brian explores the usage of monad transformers with the Process transformer which incorporates a carry methodology that can keep away from duplicating an internal sort. A transformer is a monad that merges two monads collectively. Transformers are wanted as a result of not like functors, monads don’t compose.
  • Reconstructing with Monad Transformers Brian introduces monad transformer primarily based libraries, and explains that every transformer is beneficial for a selected activity, and reconstructing code with monad transformers requires understanding which transformer to make use of on the proper place.
  • Monad Transformers Practices Brian covers monad transformer practices, and demonstrates the best way to use the carry methodology.
  • Defining the Free Monad Brian explains that the free monad is a option to deal with capabilities like datatypes, and offers an instance of a free monad that takes a url as an argument, returns a datatype, and the content material of the argument, on this instance, the url.
  • Lenses Brian explains that lenses are constructed on functors and, compose backwards going left to proper, provides that it’s doable to write down a whole utility with lenses, and demonstrates the best way to deal with properties as functors.

Monadic Web Apps

  • Constructing a CLI App Brian explores the best way to construct a CLI weblog for creating and viewing blogposts by specializing in the architectural choices to construct the app in a practical means.
  • Refactoring Recursive Duties Brian continues constructing the CLI weblog and makes use of completely different types of operate modeling to refactor code, such because the repair sort.
  • Free Monads Brian continues to refactor the CLI weblog app utilizing Free monads to check the completely different app duties.
  • Interpreters Brian provides interpreters to the completely different free monads. Interpreters permit builders to log details about how the Free monad runs.
  • Creating an Various Redux Brian explores a brand new utility and begins constructing an alternate Redux that’s contained within the occasion loop. Redux is a bare-bones method to practical UI. The choice takes benefit of monads, operate modeling, monoids, and lenses.
  • Utilizing the ask Technique & Lenses Brian continues to construct the applying began within the earlier part in order that state is merged robotically when the ask methodology runs, makes use of lenses to change state in a chic and immutable means, and builds reducers that compose and are unary capabilities.

Wrapping Up

  • Wrapping Up Brian wraps up the course, explains that the aim of this class was to provide examples of practical structure that may be reused at work, and explains when to make use of JavaScript vs when to make use of TypeScript in practical structure.

[Frontend Masters] Hardcore Functional Architecture Patterns in JavaScript

[FrontendMasters] Hardcore Functional Architecture Patterns in JavaScript

LEAVE A REPLY

Please enter your comment!
Please enter your name here