The Pragmatic Programmer EP.3 — A Pragmatic Practice Part II

Natnicha R.
CodeX
Published in
5 min readApr 24, 2022

Orthogonality

The word “orthogonality” is borrowed from mathematics which means vector u and v form a right angle. The two composed vectors will never meet each other [wikipedia]. This word turns into a programming word meaning that if we change one thing, the others in the system will not be affected.

Why our system should have an orthogonality property

Gain productivity:
1. Engineers will easy to read the codes, fix issues, and enhance the system.
2. This methodology encourages the reuse of functions. Functions lead to single responsibilities. So, it is easy to reengineer.

Reduce Risk:
1. Because each part of the code is an isolate. In the case of an infected module, the others will not be affected.
2. Any fix or change of code will limit to a specific area. Other modules can continuously work.
3. We will not be stuck with the particular vendors or tools. It’s easily plugged into any new product.

As our familiar, we design the system by separating it into layers. Then, we can easily change anything without any earthquake in the system. For example, we can change the user interface (UI) without changing the database. Nevertheless, an orthogonal system also allows both testers and developers easily write and execute unit tests through end-to-end tests because a module is limited to only one purpose. Not only the source codes should be orthogonal, but also documentation should be too. Programming documentation should be in a format that can view depending on tools, such as Markdown (.md) files.

Image from Pinterest

Tips to produce an orthogonal system

  1. One function, one responsibility
  2. Away from global variables: Someday, our system may develop to handle a multithreading system. Those declared global variables will directly affect to not correctly work. Global variables are allowed to store an unchanged value since starting the system. A singleton pattern is a useful way to deal with it. Let’s pursue this in the further episode.
  3. Avoid similar functions: These are the problems leading to code duplication which is the structural problem.

Reversibility

Building a reversible system needs to produce decoupling modules and architectures. It lets our system easy to change. This means if you constantly rely upon one fact, it is a high potential to have change. Changing requires costly effort to undo. So, don’t final decisions even though your customers said that. Remind yourself that anything can be changed at any time such as requirements, tools, and so on.

Tracer Bullets

Soldiers use tracer bullets to refine the accuracy to hit a target. The bullets are loaded into a gun regularly. When the soldiers pull a trigger, the tracer bullets are pushed out by phosphorus ignition. If tracers hit the target, regular bullets will hit as well.

This term is turned into a pragmatic technique meaning getting real-time feedback from actual conditions. This technique is used when we want to build a system that we have not ever seen, never done before, or even have not known the curtain target. Then, it lets us immediately get feedback. It is called tracer bullet development.

This technique is just implementing only required modules in each layer to make only your target work while the unused functions will be implemented later as below.

Image from O’Reilly

Unsurprisingly, this implementation style adds more room for the idea that the project has never finished. So, it can change or add any functions to it. In addition, each cycle of implementation is not guaranteed that it will succeed in the first time.

Don’t confuse tracer bullet development and prototyping. Prototyping is a concept of creating something to research in a particular point, and discarding it and rebuilding it after finding the answers, whereas the tracer bullet implementation style will code only needs and refine them again and again after getting feedback, not discard it.

Prototype

Prototyping is a way to implement a product to test one or more specific aspects of a project in the easiest and fastest way with the cheapest cost. Prototyping also help you to clarify something you are doubted. So, in a prototype, you can ignore others thing unrelated what you want to know, for example, correctness, completeness, robustness, style of implementation, and so on.

Photo by Senne Hoekman

Domain-specific Languages

A Domain-specific Language (DSL) is computer programming language of limited expressiveness focused on a particular domain. [wikipedia]

An external DSL is a completely separated language that is parsed into data that the host language can understand whereas an internal DSL is implemented within a host language as a library. This means internal DSL is limited by the host language capabilities. Rspec and Cucumber are the typically discussed and compared under DSL topic because Rspec and Cucumber are internal DSL and external DSL, respectively.

The authors’ suggestion is “don’t spend more effort than you save”. So, you should trade-off time spent and what you will receive. In general, you should select external DSL such as YAML, JSON, CSV, etc. If not, you should consider internal DSL instead.

Photo by Ono Kosuki

Estimating

If you are asked to estimate something, what (s)he is looking for is high accuracy estimation. That refer to the unit of estimation. This refers to the estimating unit. If you evaluate that you will spend 250 days, and you convey that “it’s around 8 months”. Your target audience will realize that it may be 7 to 9 months. Although, 250 days means 7–9 months, in fact, 250 days will be higher accuracy than estimation in months unit.

How to estimate

The simplest way to estimate how long you will use or how much it will take is that ask someone who has experience about it. If not, try to do following steps

  1. understand the questioner’s needs
  2. build a model
  3. extract the model into components
  4. find factors which have high impact to our system
  5. calculate the answers

Please note that, in real life, you should answer the question under defined the conditions. For example, the system will consume bandwidth 100 Mbps if the user access is not over 100,000 per minute.

Thanks to The Pragmatic Programming book for above knowledge, if you are interested in reading this book, click here for more detail.

--

--

Natnicha R.
CodeX
Writer for

Software Engineer, Backend Designer, Algorithm Developer