What's in a Word: Consistency
Tags: architecture, consistency, basics
Published: 2021-07-19 09:29:24

Another post in this [mini-series](#mini-series) to clarify overloaded terms: This time I'll cover _consistency_, pronounced kənˈsɪstənsɪ, meaning "without contradictions". It originally appeared on the [INNOQ blog](https://www.innoq.com/en/blog/whats-in-a-name-consistency/).
 

## Consistent

> The word is of Latin origin: The verb _consistere_ means 
> 1.: to stop, rest 
> 2.: to consist of, 
> 3.: to stand together.
> The noun _consistentia_ means "state of being in agreement or harmony". 
> From [dictionary.com](http://dictionary.reference.com/browse/consistency)


In everyday language, _consistent_ means "acting or doing something in the same way". Interestingly, besides behaviour, the noun 'consistency' also refers to the structure or content of things, and to mathematical/logical theorems.

In IT, we use the term in the following areas:

1. user interfaces
2. architecture and code
3. ACID databases
4. CAP theorem
5. names and terminology

## Consistency in User Interfaces

Consistency in user interfaces refers to the conformance of an UI with respect to user expectation: Software should always behave _as expected_, and offer actions or information in standard (_consistent_) ways (with the possible exception of games, which may surprise their users). For example, operations like "save file" should always be invoked with the same keyboard shortcut (such as ctrl-s). Imagine an application that, in order to save files, would require its users to press the ctrl-alt-del keyboard combo...

UI consistency refers to everything users see or do, for example, layout, colours, typography, icons/symbols, wording/naming, styling, order of things, order of actions, and required gestures or mouse clicks.

Please note that UI consistency refers to application- _internal_ conventions and additionally to conventions provided by the operating system user interface guidelines,  e.g. (see [Microsoft-UIG](https://msdn.microsoft.com/en-us/library/windows/desktop/ff72883185) and [Apple-Mac-OS UIG](https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/) for examples).

An example of quite recent inconsistencies was posted on [Twitter by Zac Bowden](https://twitter.com/ZacB_/status/619947511868997632):

![Windows Inconsistencies](http://www.windowscentral.com/sites/wpcentral.com/files/styles/larger/public/field/image/2015/07/windows-10-menus_.jpg)



## Consistency in Architecture and Code


In 1975, Fred Brooks wrote in his famous book [Mythical Man Month](http://c2.com/cgi/wiki?MythicalManMonth): 

> ... Conceptual Integrity is the most important consideration in system design. It is better to have a system ... reflect one set of design ideas than to have one that contains many good but independent and uncoordinated ideas."
 
_Consistency_ is just another term for this _conceptual integrity_: Solve similar problems in similar ways to minimise surprise. Sometimes I translate _consistency_ to _tidyness_ or _order_.
In any household, you have to invest some time to keep your rooms clean and tidy.  Likewise, you need to invest some time to keep your architecture and code tidy and consistent. Every single change bears the risk of introducing inconsistencies – so watch out.

When you need to inform users about internal errors, always do it in the same way. You don't want one developer to write `print` statements, a second one to use a logger, a third to open a GUI window, and the fourth to call `system.exit` with some error status code.


Within any system, apply a small set of concepts or ideas to increase understandability of code and design decisions, and to improve maintainability.


On the source code level, agreed-upon coding conventions can help write consistent code:  Use the typical idioms of your favourite programming language and don't try to apply every possible language or library feature.

The old saying "less is more" applies here: less variants or less different concepts or solutions to one single problem will lead to more consistency.

In this sense, architectural and code consistency resemble _simplicity_: you can rarely have enough of it.

 
## Consistency in (ACID) Data 

In well-established SQL databases that follow the ACID principles, _consistency_ (the 'C' in 'ACID') relates to data integrity: Any ACID database will prevent operations that break constraints, thus ensuring data consistency.

Consistency rules in this sense could be:

* columns store only values of defines types
* unique keys remain unique after operations
* constraint checks are satisfied before and after operations
* foreign key constraints are satisfied before and after operations

If any database operation violates those or other consistency rules, the corresponding database operations or transaction will be undone (_rolled back_).


## Consistency in the CAP theorem

_Consistency_ is inconsistently used in database and CAP (see [confusing CAP and ACID wording](http://blog.thislongrun.com/2015/03/the-confusing-cap-and-acid-wording.html) discussions:  Whereas relating to data integrity in (SQL/ACID) databases, it refers to the "atomic consistency model" in CAP [CAP-Theorem revisited](https://robertgreiner.com/2014/08/cap-theorem-revisited/), meaning that any read operation is guaranteed to return to a given client the most recent write's result.

Just in case you're *really* interested in knowing more about consistency models – [Wikipedia](https://en.wikipedia.org/wiki/Consistency_model) describes eleven (!!) different variants... way more than I want to cover here. 


## Consistency in Names and Terminology
Did you ever stumble upon the following problems within a project:

* People using a specific term, but meaning different things by that word?
* People using different terms, all meaning the same thing?

Both variants are perfectly ok for novels, fiction and crime-movies, but too risky for software projects.

My advice: Aggressively enforce consistency within names and terms within your projects. In [Domain Driven Design](https://domainlanguage.com/ddd/) this rule goes by the term 
_ubiquitous language_: identify relevant domain terminology
and clearly define their semantic, thereby ensuring a _consistent_ use of fundamental terms within a system, its implementation and documentation.


## Summary

The term _consistency_ can have different meaning, depending on context, application or technology.

In software architecture, we gain a lot from _consistently_ engineered and implemented systems: flexibility, understandability, maintainability and ease-of-use: It's very nice to have, and sometimes very expensive and dangerous not to...

But there's no free lunch: Consistency might be difficult to achieve, and very simple to violate. 

My advice: Make consistency an explicit goal within your architectures, implementation and documentation.
Be _constantly vigilant_ for any deviations, follow the [Broken Window Theory](https://en.wikipedia.org/wiki/Broken_windows_theory).

Thanx for reading so far – and may you construct and build consistent systems!


### Related Posts <a name="mini-series"></a>

* [What's in a Word: Quality](https://dev.to/gernotstarke/what-s-in-a-word-quality-48pl)
* [What's in a Word: Consistency](https://dev.to/gernotstarke/what-s-in-a-word-consistency-206b)
* [What's in a Word: Evaluate](https://dev.to/gernotstarke/what-s-in-a-word-evaluate-89i)

### Acknowledgments
Thanx to Dr. Andreas Krüger, Phillip Ghadir and Peter Hruschka for discussing _consistency_, conceptual integrity and the value of _keeping order_ with me: "A tidy house, a tidy mind" - and for their constructive reviews of draft versions.

Thanx to [Stefan Tilkov](https://tilkov.com/) for references, especially concerning CAP.