Elegant Design

29 Nov 2018

## Why Javascript promotes healthier design patterns.

Every Computer Science student gets beaten over the head with Object Oriented design. Have a problem to solve? Quick! Start jotting down hierarchies of classes and subclasses that will end up paralyzing you in the long run. This is what happens when we learn languages like Java that are so OOP dependent, everything starts looking like a nail so to speak.

The explosion of popularity with JavaScript has lead developers to move away from such hard nosed OOP design patterns. Sure JavaScript still has objects, but with features such as dynamic typing and first class functions, JS lends itself to more functional design patterns.

A more functional approach with React

The react library lends itself beautifly to a more functional design pattern. As I have began to dig deeper into using the React library, I have loved how react focuses on the flow of data between components. Yes you will need some React components as classes because anything involving UI requires state. But React also allows stateless components that are simply functions, which allows the flow of data to be easier to manage and easier to test. Keeping your components as immutable as possible makes bugs much less likely to appear.

Stateless or near stateless design patterns creates software that is easier to maintain, easier to debug, and easier to test. The growth of JavaScript in the development community has led to a promotion of more elegant, functional development patterns. Maybe they should start teaching JavaScript in our ICS 100 classes.