Image for post
Image for post

Philosophies that Shaped Successful Frameworks

Qiang Xue
Qiang Xue
Mar 17, 2016 · 10 min read
Image for post
Image for post

The Philosophy

Like any product, the success of a framework depends on many factors including the ideas behind it, the code quality, the documentation, the community surrounding it, the marketing, the support, etc. In my opinion, one item of particular importance is the philosophy taken into account when a framework is being designed and developed.

  • Monolithic is worse
  • Be consistent
  • Explicit over implicit
  • Convention over configuration

Simple is Better

Converting a developer to a new framework is never an easy task. However, when a developer does adopt a framework, they’ll become heavily invested in it and come to count on it for their current and possibly future projects. Moreover, unlike using a library — where a developer can learn an API only when implementing it — learning a framework requires developers to fully understand the framework rules before putting it into actual use. Therefore, it’s important to ensure simplicity when designing a framework to make it more accessible, enjoyable, and easy to learn, adopt, and utilize.

var express = require(‘express’);
var app = express();
// accept homepage request
app.get(‘/’, function (req, res) {
res.send(‘Hello World!’);
});
// accept POST request at /user
app.post(‘/user’, function (req, res) {
res.send(‘Got a PUT request at /user’);
});
// accept DELETE request at /user
app.delete(‘/user’, function (req, res) {
res.send(‘Got a DELETE request at /user’);
});

Monolithic is Worse

Here the term monolithic refers to frameworks built as a single unit with a tightly coupled code base. When web frameworks first became popular, they tended to be monolithic since their primary goal was to provide full spectrum support for rapid web application development. Gradually, people realized that monolithic frameworks have many issues. For example, a change made to a small part of the framework requires the entire monolith to be retested and released, which in turn causes the applications built with the framework to be rebuilt even if the change is totally irrelevant. The fact that the code in monolithic frameworks is interwoven makes it extremely difficult for these frameworks to keep backward compatibility between different versions. Last but not least, with more readily available specialized frameworks, such as those specialized in caching, logging, and database, people become less willing to be bound to a single monolithic framework.

Image for post
Image for post

Be Consistent

Being consistent means a framework sticks to uniform patterns in its usage design, naming convention, code style, code organization, etc. A consistent framework will lower its barrier to entry since users can learn one aspect of the framework and apply that same pattern towards quickly learning the rest of the structure. Being consistent also helps users reduce the likelihood of typos or misuses of framework features.

(new Query())
->select(‘id, email’)
->from(‘user’)
->orderBy(‘last_name, first_name’)
->limit(10)
->all();
SELECT `id`, `email`
FROM `user`
ORDER BY `last_name`, `first_name`
LIMIT 10

Explicit over Implicit

Explicit over implicit is about writing self-explanatory code and avoiding too much “auto-magic.” There are two reasons for sticking to this philosophy. First, explicit code is easier to understand and maintain. Since the code is self-explanatory, maintainers who may not be the original authors of the code do not need to jump back and forth to dig out what the code actually does. Second, explicit code is less error-prone. While being explicit may require writing more lines of code, it reduces the chance of overlooking important code under the hood of seemingly simple implicitness.

$order->link(‘customer’, $customer);
$order->customer = $customer;

Convention over Configuration

The concept of convention over configuration has been around for years. The idea is that a framework should take sensible default values that adhere to conventions while still allowing extensibility via configuration. The goal is to reduce the number of decisions developers need to make, thus achieving Philosophy #1 — simplicity.

Image for post
Image for post

Summary

Building a successful framework is all about striking the right balance between power and simplicity. Throughout the process of building a framework, trade-offs often need to be considered in order to stick to, and exemplify, the philosophies described above.


Capital One Tech

The low down on our high tech from the engineering experts…

Qiang Xue

Written by

Qiang Xue

Distinguished Engineer @CapitalOne, Creator of @yiiframework

Capital One Tech

The low down on our high tech from the engineering experts at Capital One. Learn about the solutions, ideas and stories driving our tech transformation.

Qiang Xue

Written by

Qiang Xue

Distinguished Engineer @CapitalOne, Creator of @yiiframework

Capital One Tech

The low down on our high tech from the engineering experts at Capital One. Learn about the solutions, ideas and stories driving our tech transformation.

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