The Two Ground Rules for Using a Framework
Published on MarĀ 26, 2015 (updated JanĀ 12, 2022), filed under development, frameworks (feed). (Share this on Mastodon orĀ Bluesky?)
And of any framework at that. These two rules are golden:
1. Follow the Documentation
Whether internal or external framework, whether expert or beginner, read and follow the documentation.
This rule is paramount because the second source of quality issues with frameworks and the works created with them (after framework bloat) is user and developer error. Or user and developer misconduct! Some scenarios that illustrate this might be when a pattern is hacked to work, when something has been developed thatās actually already part of the framework, when things get overwritten without regard for framework updates, or when something has just been āmade working.ā
When using frameworks, always follow the documentation.
2. Donāt Overwrite Framework Code
For reasons that will become clearer [later in the book], never overwrite framework code.
Contributing to the expertās dilemma with external frameworks, overwriting framework code can have unforeseen consequences and break things with future updates. Hereās an example:
Framework:
header { /* No layout declarations */ }
Overwrite:
header { position: relative; top: 1em; }
Framework update:
header { left: 0; position: absolute; top: 0; }
The example, simplified as it is, shows how a seemingly innocent change can have acute consequences. Here, a header is moved by one em. (Note that the example constitutes an overwrite because the framework header is inherently āpositionedā and also rests on the initial values for
position
andtop
.) The next framework update, however, switches to absolute positioning. As the overwriting rules come later in the cascade, they prevent the update from working (with the exception ofleft: 0;
). In cases like this, overwrites are unpredictable. Overwrites should hence be avoided where possible.The remedy: For internal frameworks, update the framework, or leave things as they are (as in, no overwriting). For external frameworks, leave things as they are, or create a separate pattern that does the job (like an alternative header, with different markup). Stay away from forking or āpatch improvementsā; solve issues at the core, or not at all.
As briefly as I could put itāin The Little Book of HTML/CSS Frameworks! (Needless to say, the book includes extra context to understand how these rules contribute to the quality I deem so important in our work.)
About Me
Iām Jens (long: Jens Oliver Meiert), and Iām a web developer, manager, and author. Iāve been working as a technical lead and engineering manager for companies youāve never heard of and companies you use every day, Iām an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for OāReilly and Frontend Dogma.
I love trying things, not only in web development and engineering management, but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (I value you being critical, interpreting charitably, and giving feedback.)