How Statistics Can Enrich Domain-Driven Design’s Building Blocks? (Part-2)

Ruhollah Delpak
6 min readMar 2, 2023

In the previous part, I reviewed the most popular topics that have been discussed in software developers community about Value Objects, and then I explained the difference between Value and Variable, in order to be a little more prepared to enter the world of statistics. And now:

In the Realm of Statistics!

According to Wikipedia:

“Statistics is a branch of mathematics that deals with the collection, analysis, and presentation of data. Statistics should be considered as the science of extracting and developing experimental and human knowledge using the methods of collecting and analyzing experimental data (resulting from measurement and testing). Today, we know the science of statistics as the science of expressing other sciences.

What interests me — and I will explain how it can leads to the expansion of the design grammar in DDD — , is that in this science, the types of variables are divided into four categories and then for each category, a specific style of analysis and interpretation tools are used.

Correct identification of variable type is essential for statisticians. Because any analytical method or interpretation of variables is only valid for a specific type and invalid for other types.

Another point is that this classification is independent of the context due to the essence of statistics (a science to express other sciences) and can be used in all fields that somehow deal with quantities and measurements.

Let’s start review the classification of variables from statistics point of view.

Types of variables: Nominal, Ordinal, Interval, Ratio

1- Nominal Variables:

Nominal variables can be thought of as labels to categorize entities. These variables are unordered and if their order is changed, the function we expect from them will not be affected.

The important thing is there is no measure of distance between the values. You’re either married or not married. The answer is determined, yes or no. So there is no question of how far apart in a quantitative sense those categories are. They are just names.

Some examples of nominal variables:

  • Gender: Women, Men
  • Hair color: Blonde, Brown, Brunette, Red and etc.
  • Native language: Farsi, English, French and etc.
  • Blood type: A, B, AB, O.
  • Marital status: Married, Single, Widowed and etc.
  • Political party: Democrat, Republican, Conservative and etc.
  • Place of birth: Ahvaz, Shiraz, Rasht and etc.
  • Favorite sport: Football, Swimming, Chess and etc.
  • Race: Oriental, Black, Hispanic, White and etc.
  • Field of study: Mathematics, Biology, Chemistry and etc.

2- Ordinal Variables:

In addition to having the characteristics of nominal variables, ordinal variables imply order. For example, you don’t rank male and female as higher and lower. But you do rank stages of cancer, for example, as higher and lower. You can rank pains as higher or lower.

So, ordinal variables give you a more sophisticated level of measure — a finer tuned level of measurement. But you have now added only this one element having to do with ranking. You know that something is higher than something else, or lower than something, or more painful than something, or less painful than something.

Other example, educational stage from illiterate to PhD whose sorting logic is clear and based on this logic, you can find out which is the highest or lowest level of education.

In ordinal variables, terms like First, Last, Highest, Lowest, Largest, Smallest, Less Than, More Than and similar terms are meaningful and indicates the existence of rank. For example you don’t rank blood type as higher or lower. But you do rank education level as higher and lower.

However, in this variable type, the distance between degrees cannot be measured quantitatively and numerically. For example with age groups, it cannot be concluded that the kids age is half of adults age.

Some examples of ordinal variables:

  • Age categories: Children, Youth, Adult and Senior.
  • Rank in a race: first, second and third.
  • Blood pressure level: low, moderate and high
  • Military ranks of the armed forces: soldier, lieutenant, captain, major, colonel and etc.
  • Film rating system: G, PG, PG-13, R and NC-17.
  • Cancer stage: stage I, stage II, stage III.

3- Interval variables

This variable type has all the characteristics of variables of the previous category, i.e. ordinal variables; with the difference that the distance between the degrees of this type, is measurable and can be expressed with a number. So, differences in the numbers represent real differences in the variable.

Temperature on either Fahrenheit or Celsius is an example of an interval variable. They are called interval variables because the intervals between the numbers represent something real. This is not the case with ordinal variables. According to the standard definition of temperature, the distance between 5 and 10 degrees Celsius is equal to distance between 50 and 55 degrees Celsius.

So, with interval variables you now know not only whether one value is higher than another, but that the distances between the intervals on the scales are the same. Again, you have a higher level of information. Interval scales not only name and order, but also have the property that equal intervals in the numbers measured, represent real equal differences in the variables. But, for example, in the case of “Educational Stage” which is a ordinal variable, it cannot be claimed that the distance between diploma and bachelor degrees is equal to the distance between bachelor and master degree.

Examples of interval variables:

  • Temperature on either Celsius or Fahrenheit.
  • The result of the IELTS test (in general, many of standardized tests of the psychology, education, language preparation and etc. can be included in this category)
  • Intelligence Quotient (IQ)

The important thing about these variables is that the selection of their zero point is contractual. For example, the zero point of temperature on Celsius, is equal to the freezing point of water. This is the fact that the zero Celsius point does not indicate true zero or absolute zero temperature.

4- Ratio Variables

Ratio variables, have all the properties of interval variables, furthermore that the zero point in these types of variables means total absence of that thing or real zero.

For example, consider height or weight. Both of these are ratio variables and their zero points are interpretable for us. But, for example, temperature in Celsius is not like that. Below zero degrees Celsius does not mean lack of temperature. But the Kelvin temperature is a ratio variable because its zero point means the total absence of temperature.

By ratio variables, you can get a perceptible sense of the ratio of two values. A weight of 4 grams is twice a weight of 2 grams, because weight is a ratio variable. But a temperature of 100 degrees Celsius is not twice as hot as 50 degrees Celsius, because temperature, in Celsius, is not a ratio variable.

Examples of ratio variables:
• Weight
• Height
• Population
• Age
• Blood cholesterol levels

Summary

Leveraging the way statisticians categorize variables, the idea of Value Object can be expanded in such a way that simplifies the act of analyzing and designing complex domains and our models reflect the problem space more clearly. In the first part of this article, we got acquainted with the categories used in the science of statistics to categorize values. The summary of this review is as follows:

  • Nominal variable
    Usage is describing qualitative differences.
  • Ordinal variable
    Usage is ranking the differences. Where bigger, smaller, first, last and ordering is important.
  • Interval variable
    Usage is to measure the distance between two values. In these variables, there is a certain spacing system between degrees, but zero point is conventional.
  • Ratio variable
    It has all the usages of the interval variable, furthermore this variable has a real zero point.

In the third part, I will examine how these categories of variables in statistics, can lead us to the more practical use of the Value Object design pattern, and expanding the design grammar of Domain-Driven Design. Also, We will behold how this new ideas can make it easier for analysts and software developers to understand, discuss and model complex domains with a more equipped toolbox.

--

--