About a Utilities module

A Utilities module, i.e. a collection of unrelated functions, is often given as an example of non-cohesiveness, but that’s wrong.

There is no reason to look for cohesiveness into a Utilities module as well as there is no reason to look for cohesiveness into a language syntax.

How cohesive are branching (e.g. if) and looping (e.g. for)?

How cohesive are debouncing (e.g. _.debounce) and grouping (e.g. _.groupBy)?

The question itself doesn’t make sense. But it’s easy to see that both a language syntax and a Utilities module provide (generic) programming constructs.

Utilities are language extensions.

About Software Architecture

I think I found the perfect analogy for the essence of Software Architecture.

  • Software architecture is the health of a software application.
  • A software architect is a physician which is concerned with the health of a software application.
  • Architectural characteristics are measurable dimensions of the health of a software application.

Software architecture is a misleading name, because it reminds us of structure, solidity, and immutability, but that’s far from the truth. 1That would be the skeleton, which is certainly an important subsystem, but only one of many that conform the whole.

Software applications are dynamic entities 2both in the sense that they live and work along time and that they change from time to time, so they have an intrinsic and comprehensive survival ability that changes over time. That ability is the health of the application.

A software architect can audit a software application, and find out if it has good health or it suffers an illness. Then she can suggest a therapy 3more or less invasive to improve its health.

Fundamentals of Software Architecture

Lately I bought a book published by a ThoughWorks employee: “Fundamentals of Software Architecture: An Engineering Approach”. 1by Mark Richards and Neil Ford – O’Reilly – 2020

I praise ThoughWorks and all the companies out there that dedicate time and effort to distribute knowledge, however it is collected, however it is shared, inside the company and outside.

I praise them because, in my decades long career in IT in Spain, I’ve yet to work for such a company. Each one of the companies I worked for didn’t have any implementation of information sharing, except maybe for an internal basic wiki, with mostly stale content.

Did you know that Martin Fowler works at ThoughWorks? His writings, at the same time professional and accessible, innovative and systematizing, fundamental in essence, made me expect a comparable level of excellence for this FSA book.

Instead, the standards are quite low here. I’m about to start studying the fourth chapter, but I already found something so bad that pushed me to write this post.

First, I can summarize the first two chapters like this: “Be a professional IT specialist and apply common sense.” Not really fundamental, nor surprising stuff, but the worst thing is that the authors needed 35 pages for telling me that.

Second, the Modularity chapter is an anthology of misfires.

The issue with module

The authors start by recognizing how difficult it is to find a usable definition of “module” in IT, so much so that they dedicate the first section of the chapter to define it.

Leaving aside the fact that the chosen definition (albeit appearing in the first paragraph) is blended with discursive text instead of being extracted and framed as we are used to see in foundational books, I start having doubts about whether I match the target readership of this book or not.

In 2020+ there is really no IT professional on Earth that doesn’t know what a module is. Anyway, it surely makes sense to define one of the fundamental concepts of software architecture in a book about Software Architecture. Why not be rigorous then?

The authors just say that a module is a “logical grouping of related code” and explain it by enumerating its many implementations in programming languages. I’m not comfortable with this definition because I think they missed a crucial point.

A module is a logical grouping of related code WITH A GIVEN NAME.

Forgetting to mention the name here, which is basically the very essence of the abstraction a module provides, is a huge mistake.

Only after you give a name to a logical grouping of related code, that code becomes a module. 2An anonymous grouping of related code is not a module, it’s just a block of code. And only because of the name, you can ask yourself how much the code is cohesive.

Other issues

Cohesion

In this section, the authors start with a good definition of cohesion, but soon after, when defining each of the different types, they say “two modules”, when they really mean “two parts of a module”, which is quite confusing.

Coupling

In this section, the authors start with the definitions of afferent and efferent coupling, which first appeared in the book “Structured Design: Fundamentals of a Discipline of Computer Program and System Design”. 3by E. Yourdon and L. Constantine – Prentice Hall – 1979

I didn’t have a chance to read that book, but the authors of the FSA book did not explain the subject clearly, nor did the authors of the related Wikipedia pages: Software package metrics and Efferent coupling, which almost contradict each other.

In the FSA book the authors say that

  • Afferent is the number of incoming connections to a code artifact
  • Efferent is the number of outgoing connections to other code artifacts

The Wikipedia pages are much better at this, because dependency 4which clearly states what flows from and to makes a lot more sense than connection. In the first page, the Wikipedia authors say that 5slightly adjusted to the FSA terminology

  • Afferent is the number of elements in other modules that depend on a module
  • Efferent is the number of elements in other modules that a module depends on

However, in the second page they also say that

  • Efferent is the number of elements in a module that depend on other modules

which is quite different a number from the previous definition, and possibly wrong.

Abstractness, Instability, and Distance from the Main Sequence

In this section, 6whose title is totally crazy the authors start with a wrong definition of abstractness

  • Abstractness = [Count of Abstract Elements] / [Count of Concrete Elements]

but, in the following section, 7surprisingly titled “Distance from the Main Sequence” again they say

Note that both abstractness and instability are ratios, meaning that their result will always fall between 0 and 1.

which is right 8Wait a moment. It’s wrong: a ratio is not that! but contradicts their own definition.

In fact, the right definitions of abstractness is

  • Abstractness = [Count of Abstract Elements] / [Count of All Elements]

Distance from the Main Sequence

In this section, the authors don’t give any reference to support the admittedly arbitrary statement that modules for which Abstractness == Stability 9this formula derives from (1) Abstactness + Instability – 1 == 0 and (2) Stability = 1 – Instability are balanced and healthy, nor they say why these two would be competing concerns.

What I missed

This chapter on modularity is all but foundational.

The subject is presented along the historical point of view, which instead should have been collected into a separate section, appropriately called “If you ever wondered how this all came about”, which one could decide to skip.

Throughout the chapter there is a great deal of confusion on terms, again for historical reasons. For example, to the same end, the authors use functions, classes, packages, modules, components.

The principle of high quality modular architectures that is summarized by the sentence “strong cohesion, loose coupling” is never mentioned, not once. However it permeates almost every paragraph.

Types of cohesion, coupling, and connascence are enumerated and defined separately, again following existing literature. Really with no other reason than that, because they are basically the same concepts. 10The authors did realize that they couldn’t not recognize overlappings, so they briefly discussed them in the second to last section

Cohesion

Functional

Sequential

Communicational

Procedural

Temporal

Logical

Coincidental

Coupling

Afferent

Efferent

Stamp 11this type and those below are not described in the FSA book, except for a mention in Figure 3-6

Control

External

Content / Pathological

Connascence

Name

Type

Meaning / Convention

Position

Algorithm

Execution

Timing

Values

Identity

How refreshing would have been to see only one enumeration, with no duplicates, with all the types defined in a generic but usable fashion.

All the formulas for assigning some meaningful numerical value to a system of modules occupy a big portion of the chapter. However, the authors don’t justify any, and state that they fail their purpose to mean anything. So why, why on Earth are they central to the chapter instead of being collected in an appendix at most?

Quite disappointing that a book about architecture doesn’t show much of it in the organization of the subject, at least in this initial chapter on modularity.

Crossing fingers for the rest of the book.