Boilerplate for enterprise app
Closed this issue · 2 comments
With so many options of boilerplate to kick off a new project, which one would you choose to start a new large project today and why? How would you structure a project for a large app, what libs would you pick?
With so many options of boilerplate to kick off a new project, which one would you choose to start a new large project today and why?
I have mixed feelings about boilerplates even if I happen to maintain one. They represent a set of opinions always. And it's very easy to disagree. That's why we have so many boilerplates. You might find something that's close to what you want, but it might be missing a bit or two. A new boilerplate is born as a result.
Even though boilerplates might help in the initial stages of a project, they don't help with maintenance. They also tend to become obsolete after the author loses interest. Fortunately the more popular ones tend to stay alive for longer.
Pick the Best Ideas
Instead of relying on some specific boilerplate, I would advise you to look into a few and pick ideas you like. Ironically this might lead to yet another boilerplate, but I feel this is the pragmatic thing to do at the moment. The last thing you want is a starting point with some mystery code you don't fully understand. That code will bite you at the worst possible moment.
I made the mistake of starting from something far too elaborate in an older project of mine and ended up ripping away half of the boilerplate code. That's something that could have been avoided with some thought beforehand. It's easier to add than to remove.
Push Dependencies Elsewhere
I hope the era of boilerplates as we know them is coming close to an end. Ideally we would be able to push some of the common concerns elsewhere and consume them as a dependency. Tools like kotatsu and nwb are important steps towards this direction. There's also a Yeoman generator that might come in handy.
You can even apply this idea yourself without any special tooling. You could maintain configuration related aspects in a npm package which you then consume from your projects. When there's churn (tooling changes etc.), then you would have to update just one place ideally.
How would you structure a project for a large app, what libs would you pick?
I don't think there's one right way. It depends on the type of the application. If it's universal, you'll most likely want to maintain both frontend and backend code in the same repository. The whole point is in sharing a lot of the code after all.
I've written a little appendix on structuring. The way I see it, it's fractal. You can start from something humble and then evolve the structure as the application solidifies. Applying too much structure early on might just slow things down especially if you are still prototyping and figuring things out.
On Evolving a Codebase
I don't see any harm in applying some anti-patterns early on (i.e., everything in a single file) as long as you are aware of what you are doing. Once the situation is stable, you can split up and go from there.
As the codebase grows and you are more sure of what you are doing, you will want to apply measures to solidify it. Defining propTypes
and setting up unit tests is a minimal starting point. Basically you'll want to make it as hard as possible to break those things you cannot afford to break. Flow allows you to go a step further.
On Libraries
Figuring out what libraries to pick is a good problem on its own. Older solutions that have been around for a while tend to be more stable. Newer solutions might have more churn around them, but even this is something you might be able to live with. I think it's a good idea to design your system so that you can change your mind later.
You could start with something that fits your current requirements and then evolve the system as you begin to hit limits. I consider that a strength of a library based approach. It doesn't fix you to any particular mindset. Rather you make up your mind on your own.
Yeah, feel free to leave this open. If you have further comments, add here and I'll reply. 👍