Functional components vs. Feature components
Tags: product, systems, design, architecture
Published: 2020-02-01 11:29:10

---
title: Functional components vs. Feature components
published: true
description: A useful way to consider component boundaries in the context of product feature development
tags: product, systems, design, architecture
---

I've been working as part of a product team for a while now and I've started to pick up on a pattern. It comes back to whether development is focused on building what I'm calling _features_ or _functions_.

These terms are quite similar and are quite frequently used interchangeably in software engineering - they're very similar in definition.

Here I'll define them to avoid any doubt:

  - **Feature** - part of the product that the user can use directly
  - **Function** - a system component that can exist in isolation from any feature that uses it

When building a feature, a trade-off between _reusability_ and _extensibility_ exists whereby features that are developed entirely isolated from each other are infinitely extensible whereas features that share as many components as is technically possible are less extensible.

If a feature exists in total isolation, none of its components are used by other features. For example, this could be part of an app dedicated to listing blog posts that allows filtering by category and full-text search. If built in isolation, none of the other parts of the app would share any of the same components.

By nature, isolation lends itself to extensibility and so the app page in the example above could theoretically be changed in any way without impacting other parts of the app.

But this comes at a cost - building everything from scratch takes longer.

So naturally most systems are not built in this way and there are hundreds of ways to consider how to architect a system that I won't go into here.

But one thing that I've seen a lot first-hand is how the feature design process influences the boundaries of each component in a system.

Which brings me to an observation:

 - _feature-specific_ components are bound to a feature and therefore cannot be reused by other features
 - _function-specific_ components are _used_ by a feature and _can_ be reused by other features

By designing a system component to be explicitly bound to a feature, reuse is actively discouraged, whether it's a service, an API endpoint, a button in the UI or anything really. What this allows is for individual features to be changed frequently and without much consequence to other parts of the system (although by nature system components are never totally isolated).

This might be suitable for certain products that need to change frequently, or that have a short shelf life. But in the long-run features will be developed repeatedly that are similar in nature but differ in their components.

This can become costly - a lot of dev time that could be spent investing in components for the future is instead spent building components for today.

By designing a system component to be explicitly bound to a _function_, reuse is a fundamental consideration because by the definition above it can be _used_ by new features in the future. The more features that can utilise a component, the more extensible the product is overall.

The thought process becomes more about separating the functional requirements of a feature from the feature itself - system components _become_ functional requirements.

As an example, take a dashboard for monitoring a service that tracks employee workload by monitoring how many email threads they are active in in a single day. Let's suppose the product team wants to add a page to the dashboard that let's the user view a graph that shows the workload over time for a specific group of employees.

One way of delivering the feature is to create a new service dedicated to this page, have it expose an API that provides the data, which is stored in a new database called `group_workload_stats`. The service updates the table over time and the API will return an updated view when that happens.

It's easy to see that none of the above can be reused as part of another feature.

To rethink this implementation, we could consider making each component _function-specific_.

For example, the new service could be dedicated to the _function_ of returning workload data over time - something that is predictably reusable, something required by other features that are planned for the future. It's true that this restricts new features by constraining them to the functionality provided, but it _is_ possible to build such
services with extensibility in mind.

In summary, I think there are a lot of benefits to thinking of system components in terms of whether they are _feature-specific_ or _function-specific_. This in theory encourages features comprised of functional components, which in turn saves time in the long run.

In a later post I'd like to discuss how this relates to design patterns such as microservices and how some parts of the system must define the composition of functions in order to deliver features.