Updated 2017-02-12: Added a strategy for loading configuration at initial page load, using an “env.js” file.
Recently, I needed to inject some configuration variables into my client-side app. Because Googling for it turned up a lot of “well, you could maybe do this…” I decided to write down what I see as the 3 main options:
- Best in show: Load configuration at run time.
- Prize for simplest solution: Build your application with configuration variables as constants at compile time.
- Runner up: Use server-side templating to inject configuration at render time.
Harmonious Stylesheets and Inline Styles in React
Both traditional stylesheets and inline styles have their place within React applications. By using them harmoniously you can have the best of both worlds.
Homogeneous Pipelines with Docker
Continuous Integration Build Pipelines are a dirty, nasty place. What usually starts out as a couple of simple tasks or bash scripts inevitably ends up as a heap of scripts, Gradle/Rake/Maven/(insert build tool here) tasks, and manually configured jobs held together with a thin layer of Elmer’s glue and Scotch tape.
Why? Partly because modern applications are complex; even simple stacks use multiple languages and tools. And partly because developers are lazy, and sometimes hesitant to “mess with the pipeline.” I don’t often see the amount of rigor in cleanliness applied to them as to other parts of the codebase, leading to unnecessarily complex and unfortunately tangled build pipelines.
So, my current team attacked this head-on using a great piece of technology: Docker! Using Docker as our sole interface to running things in our build pipeline, we sped it up, simplified it, and lived happily ever after.
To give credit where credit is due, the implementation of this pattern was spearheaded by my colleague Amber Houle.
How your 'Mother' can help you 'Build' cleaner unit tests - Part III
We ended Part II with an inner Builder for
Address, which forced us to revert to specifying seemingly arbitrary values in each test that needed to build an
What I’ve usually seen at this point is pulling the Address objects into constants in each test class. As the test suite grows, the number of
private static final Address WHATEVER_ADDRESS = ...; grows and grows. Doing that makes it hard to keep control over your test data, especially in a large codebase. A minor change to Address, such as a new invariant or an added field, could cause cascading changes to keep all those objects valid.
To avoid that, the next step is actually a very simple one, and boils down to centralizing the definition and creation of an
Address with an Object Mother.