Carpentry - The art of making Software Right
March 09, 2019
![Carpentry - The art of making Software Right](/images/test-frame.jpeg)
Case of making a wooden frame
Suppose you started your career as a carpenter some time back. You got an order for making a wooden frame for mounting the window on it. How would you proceed?
Traditional Approach
You trust your skills. You also know the client has a sufficient budget to fulfill the cost. Now You ask the client series of questions.
- Where you want to fit this frame?
- What should be the size of the frame?
- Should it be made with waterproof wood?
- What should be the color used for polishing this window?
Those look like the perfect set of questions for Gathering Clients Requirement, and you did it at the very beginning before even you started. Suppose the client gives the following answers
- In Hall
- 4 Feet x 3 Feet, 2 inches thick
- Yes
- Colour which will suit the hall
You seem to be happy that you know what the client wants. You estimate you will do it in 7 days. You start working on it. And you built something like below (right side)
Well, you didn't wish to build something like below. Perhaps you don't know Carpentry. Maybe Since It is your first attempt, hence you built it that way. All those excuses but will the client accept that. Definitely no. What went wrong? Or did you check every time while you were making it? Let's learn from Carpenter how to make the wooden frame.
Preventive Approach
My father was a carpenter. While he used to create wooden frames, I used to observe him. These carpenters have a particular way of doing things. let's explore those If we observe both the frames above, we would see many things that could have bettered since the beginning, which wouldn't have led you to that out-of-shape frame.
First, build your units properly
Let's observe the above wooden frame properly. It consists of four blocks of wood, cut in particular shapes and then joined together. One needs to be precise while using the chisel properly on the edges to cut it in an appropriate shape. I observed that my father use to measure the angle between edges with the Right angle tool every time he applied the plane.
While making Software, Flawlessly Building its units is very important. At this place, Unit Testing plays an important role. Unit tests ensure you keep your units intact to the expectations every time you change some of their internals. It's like applying that right angle every time you use the plane tool.
Next, Are your units compatible with related units?
Now that you have built your units, it is time to calibrate those units for their compatibility with their pairs (maybe one or more). What would you ensure here? You would put two units together and check they fulfill part of your requirement. In this case, you would check if you place two adjacent blocks of wood together are they forming right angle as shown below.
We call this kind of verification Integration Testing. Similarly, while making Software, you need to ensure every change you make to any of its units is compatible with its integrated counterparts.
There is this interesting case of Contract Testing, which also plays a crucial part in Integration testing. Suppose, You made one block with a square groove and the other block joining it with a round cylindrical extrude. The problem here will be units won't fit each other, As they don't abide by the same Contract. Contract Testing is such a kind of testing that verifies participating parties abide by the same Contract.
Next, Does the Frame put-together look and feels what was intended by the client?
These are the last piece of tests that you would like to perform on the above frame to ensure that we made the frame according to its specification. In software testing, this is called Functional testing
Do I need to check everything at every place?
If you observe the above example closely, The amount of time spent on each part is inversely proportional to how basic it is. Meaning we spend more time on making units perfect than integrating them etc. The concept is called a Test Pyramid. The more you spend effort on the bottom part less you need on the top.
As a QA, what can you do to ensure that we build all tests properly?
Well, to answer this question, Let's answer this first. In the above case, who knows it better than you that right angles of particular edges and 45-degree of other would lead to correct units? So you being QA we can pair with the developer to list what tests should apply on various units integration and functional part.