Two Kinds of Abstractions

When someone talks about abstractions, they’re usually trying to make the software more flexible. But that’s usually one of two kinds of abstractions. Build an abstraction to hide an implementation Abstractions that hide implementations are more commonly touted as good designs. Ruby’s Faraday abstracts the specific HTTP library implementation. Rails’ ActiveRecord abstracts the SQL you need to write to interface with a relational database. The Data Mapper Pattern abstracts the persistent storage from your application. ...

May 31, 2016 · 6 min

Design of Software Solutions

What’s the best way to model a solution? In software, there’s several common ways of building solutions that solve specific problems. It’s worth trying to identify their characteristics and the tradeoffs they make. Architect the Software After the Current Problem The easiest is way to model software. There’s no need to take in consideration of future solutions the user made want. Sometimes this is what you need. If you’re writing a throw-away program, the fastest possible way to implement it is to codify for the exact problem you’re trying to solve. An example are most shell scripts. They tend to not be abstracted and usually automate a very specific task. ...

April 30, 2016 · 5 min

Modeling the Domain

Let’s mentally build an API for an an e-commerce site. Let’s say we’re tasked with building the cart & checkout portion of the API. Building a RESTful API seems like the natural choice. At first, a Cart seems like any other model entity in the system. But what about an multi-page checkout step? Allow partial updating of the Cart model (sounds like a job for PATCH). We need to preserve as much information as possible on the server to allow the user to pick up where they left off. Each update needs to be validated against the current known state of the world. Store credit may not fully cover an order that has an upgraded shipping method specified later on. The final cart has to be “commited” where final validations need to be performed before commited. An finally, the committed cart requires taking to third party APIs all along the way (shipping, credit card processing, tax calculations) as well as at the commit point. REST doesn’t provide an easy way to model this. ...

January 31, 2016 · 4 min