Functional: A Dysfunctional Word in Software Engineering
As it is customary, we can’t discuss a word without the obligatory dictionary definition. In our case, that from the Oxford Learner’s Dictionary:
- practical and useful; with little or no decoration
- having a special purpose; making it possible for someone to do something or for something to happen.
- (especially of a machine, an organization, or a system) working; able to work
With the formality out of the way, let’s now explore together why this word—and its cousins—is devoid of any clear, reliable meaning in software engineering. In the list that follows, I start with the use of the word in a more business context to then end with its use in the context in which it is the most deceitful: programming.
The whole MBAs' raison d'être is that they confer students with the “skills necessary to progress from a functional management role to a general management one”. Does this mean that once graduated, MBAs are trained to perform an impractical, purposeless, and unworkable job? Blame the Oxford Learner’s Dictionary, not me.
A block of code that performs something the business cares about, such as adding VAT to the price of an item? No. This is not what a business function is. The BCM Institute provides the following definition:
“A business function is defined as any set of activities performed by the department that is initiated by an event, transform information, materials or business commitments, and procedures an output (e.g. order fulfillment, invoicing, cash management, manufactured batch, customer response tracking, regulatory submissions, etc).”
An organisational chart showing who heads each department and whether they are supporters, or detractors? No. This is a term that originates in mathematics. Functional decomposition is about identifying constituent (sometimes intermediate) subfunctions that transform inputs into outputs, and that, collectively, produce the same result as the original function.
A "unit of measurement" to express the amount of business functionality an information system (as a product) provides to a user. Only superseded in dumbness by user stories. Covered by various ISO standards though.
Functional Requirements (FRs)
The requirements for the functions that a system must implement? Maybe, but everyone knows that functional requirements are all of those that do not fit the NFR criteria.
Non-Functional Requirements (NFRs)
Simples. All the requirements that aren’t functional. A fine example of mutual recursion.
Jokes apart, and for Fred Brook’s sake, just be specific and spell it out: is it compliance, scalability, latency, or something else? There isn’t a magical all-you-can-eat requirements bucket simply called NFRs.
All testing which isn’t performance testing … but wait a second. Is end-to-end testing something else then? What about integration testing? Is it also a requirement to test the body of the function or only its inputs and outputs?
All we know, for sure, about functional testing, is that it isn’t performance testing.
Not a Function. Reserved keywords such as
func (e.g. Go) are lying to you. These
are subroutines that may optionally take arguments, return values, with
no guarantee that the same input will produce the same result.
Either Haskell or an apologetic language whose authors go great length to explain the reasons as to why they have included only a fraction of Haskell’s features. In most cases, the apologetic language, on top of the capital sin of not using an ML-like syntax, will either lack types, or if it has types, it will lack higher-kinded ones.
Pure Functional Language
HolyC and only if running under TempleOS. Close, but no. A language in which functions cannot normally launch cruise missiles from within them? Pretty much. Pure functional programming languages don’t normally allow mixing the definition of pure logical functions with input/output (I/O) interaction code. Fun fact: Getting seeds for random numbers counts as I/O.
Just a regular function. Oh, but can you remind me what a regular function is, please? Of course, it is a mapping between two values from two sets (types in programming languages). For example, the mapping between integers and strings such as 1->January, 2->February, etc. The key here is that there should always be a mapping between two types. There isn’t such a thing such as a function that doesn’t “return” a value.
Most importantly, though, a pure function consistently produces the same result given the same input value. If a function has the ability to find facts in the outer world (via I/O or other means) or be influenced by code elsewhere, resulting in a change of the mapping, in spite of no change in the input, then, it is not a pure function.
A function as envisioned by Kim Jong-un? Nearly there. A function that
has a mapping for every value in its domain (it’s input). For example,
month2string, if implemented as a mapping between regular integers (say uint32)
and strings, would be partial, rather than total because there are only mappings for the
numbers between 1 and 12, but not for 0, 13, 14, etc.
Impure Functional Language
Pretty much synonymous with “anything other than
Haskell Coq”. Jokes apart,
most programming languages have to be impure to be useful: for example,
the ability to inline print statements with logical statements makes a
language impure but useful. Yes, I know that this is what debuggers are
Something other than functions, impure or otherwise. Just subroutines.
First Class Functions
Functions that should travel in British Airways' premium cabin but can’t due to Covid-19. You hit the nail on the …. no, sorry. A property of languages in which subroutines are regular values that can be assigned to variables, passed as arguments to subroutines, etc.
Functionality (Of a Computer Program)
Nothing to do with its functions (regardless of whether written in a functional language or not). Everything to do with the degree with which the program does the expected bidding of humans. What the … ?