Back to blog

Rant: Overengineering

2019-07-16 22:48

Consider a typical web dev situation: React, Redux, Material-UI, a new JSS-decorated component that's going to be connected with Redux. We create a new file, write the component code in it, then export it like that:

export default withStyles(styles)(connect(mapStateToProps)(MyComponent));

This simple line contains at least 5 functions in it. Let's tear this down right-to-left:

functional component

function that returns the mapping

decorator function

And we're only done with the first part of this abomination! Now let's proceed to the outer block:

has to be a function

Yep, that's how easy it is to overengineer in React/modern JS. The code above might not exactly be a good example of a well-designed component, but this gives you an idea of how things generally go.