Image for post
Image for post

Automating Discipline

Front-end Architecture at Shapeways

Angira Shirahatti
Jul 28, 2015 · 7 min read

Done might be better than perfect, but done is not better than good.

The engineering goals of most Shapeways front-end patterns are fairly standard. We want:

  • Separation of concerns, encapsulation, modularity, and reusability.
  • Standardized documentation
  • Evolution and implementation of new ideas with minimum headaches for ourselves and minimum disruptions to our codebase

Automating Discipline

The idea that lies behind Shapeways View Components is fairly simple; most sections of the Shapeways website, be they 3D modeling tools or part of the marketplace, are built of complex interactive pieces. Such pieces should, ideally, be encapsulated so that all of their logic is built and maintained in a single location. They should then be injected into different parts of the site by reference, so that code doesn’t get duplicated.

Image for post
Image for post
A View Component consists of a Component Object, a ViewContext, and a markup template. View Components help us keep our codebase consistent and modular.
  • Update the cart to reflect the added items
  • Render a useful error message if any item is no longer available for purchase
  • Basic functionality: by populating the most essential functions, the script provides a guide for what all a component should ideally contain
  • Headache reduction: by generating the skeleton and placing it in our file structure correctly, the script allows us to focus on building the features represented by our components, rather than on our components themselves

What’s in a Name?

Another, more semantic architectural shift we’re implementing in Shapeways’s front-end is BEM CSS methodology. We use SASS for our stylesheets at Shapeways, and while the benefits of being able to use variable names, nesting and mixins are many, SASS (and in fact any kind of CSS) becomes unmanageably very quickly. Although CSS is a style sheet language, all of our front-end engineering goals can, and indeed must, be applied to our SASS structure as much as to any other part of the Shapeways codebase. We have chosen to work towards those goals through BEM. BEM, which stands for Block, Element, Modifier, is more of a paradigm shift than a framework in the traditional sense. Its structure relies on naming and organizational convention. It provides a standardized way to name new CSS attributes, and a system for organizing them into modules.

Image for post
Image for post
By adhering to BEM’s standardized naming convention, we make it easier to find and reuse previously created style rules, and avoid bloating our SASS library.

The Road Ahead

In the end, being consistent is still not as simple as we would like. We continue to strive, toil and iterate on our systems, our patterns, and our habits as developers. We will continue to search for new ways to make disciplined programming easier, and to apply our engineering goals to our codebase. After all, the great success of continuously deployed web development is that sooner or later, someone is going to come back and improve on what we build, and to be good software engineers and good team players, we have to make sure it’s ready when they do.

Image for post
Image for post

Shapeways Tech

Building the Future of 3D Printing

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store