Skip to content

Why should I use a generator?

Charles Fulnecky edited this page Mar 6, 2016 · 13 revisions

Yeoman Generator Modern web development is a complex undertaking and not for the faint of heart, consider the following reaction:

As many others here have observed, fashionable webdev now is beyond a joke; I’m seriously glad I got out of it when I did. Once you’re forced to actually deal with this nonsense you either run screaming for the exits or go insane. It’s not even fragmentation, it’s fragmentation cubed. I’ve lost count of the number of MVmumble frameworks I’ve seen pitched as “a framework using Foo, Bar and Baz”, where Foo turns out to be a event library you’ve never heard of with 3% usage share, Bar is a templating library you’ve never heard of with 2% share and Baz is a databinding library you’ve never heard of with 1%, making the combination useful to… I dunno, the author, maybe, for the next five minutes until he switches to a new set of libraries.

I don’t understand. I don’t understand why anyone thinks this is a good idea. I’ve seen code produced by people using this stuff, and it’s just unbelievably awful, because nobody has time to understand anything when it changes every thirty seconds.

**othermike, Reddit** [Another Response to the Selfsame Post](http://www.reddit.com/r/programming/comments/2kl88s/angular_20_drastically_different/clml1hj)

Enterprise development is an order of magnitude more complex.

  • You need a testing and CI strategy Jenkins workflow

  • A deployment strategy Deployment diagram

Adding yet more churn is the migration from ES5 to ES6 and Typescript.

Yeoman generators can be a big part of the solution for all the above complexities. Our AngularJS 1.x, React and AngularJS 2.0 applications all share the same basic structure: They all have routers, components, models and some mechanism for dealing with asynchronous operations (Promise based services, RxJS, BaconJS, SuperAgent or any one of the many Flux Architectures). They all have linters, unit-tests and E2E-tests and they all have to package the app into an optimized, deployable bundle and even deploy to a CI environment in some cases.

Generators are the place that you capture and update your organizations best practices. All your projects that use the generator can benefit from the lessons learned in each. By propagating the best practices back to the Yeoman generator, all projects can benefit by simply running yo <generator-name> and re-scaffolding the app. Yeoman will prompt you before overwriting each file (unless you tell it not to) and any changed files can be compared via diff tool (or local history in webstorm) and any necessary merge/restore operations can be performed.

We've just scratched the surface but hopefully the utility of generators as a tool to smooth out the bumps in enterprise web development is a bit clearer. There is one more tool in our arsenal and if you aren't already using it you should run, not walk, to:

Docker

also see: Why Docker?

Clone this wiki locally