Understand Software Engineering with Real Life Examples — Part I

Lalit Mehra
CodeX

--

We often come across technical terms and phrases that take some time to fit in inside our beautiful brain. While somethings are obvious others need some careful reading to be understood. And yes, if you are a newbie then it might take a while before you get it on your fingertips.

In this article I will be presenting some of those technical terms along with a real life example to help with understanding the concept better.

Deadlock

A deadlock happens when the resources required to perform a task are held by different threads and none of the threads is ready to relinquish control of whatever resource they have acquired.

Let’s take up this analogy to understand it.

We all wear shoes. Some of us also have siblings that have the same shoe size and end up wearing our shoes. I’m not liking it!

What if there is a pair of shoe that is liked by all. Maybe one signed by our favorite sports personality.

Raman and Sharan are two brothers who always fight for one such pair of shoe. Whenever they both have to go out, they end up wearing one of the shoe so that the other doesn’t get it but in the process end up waiting, almost every time for the other one to give up on the only shoe they have.

Now you get it, they are in a deadlock situation.

What do you think is the solution to it?

One such day they decided to always wear the left shoe first and whoever gets hold of the left one also gets to wear the right one. This sorted the problem for them. Now instead of fighting for the other show they only fight for the left one.

The solution here was simple i.e., to always follow a sequential order.

Semaphore

A semaphore is a variable or abstract data type used to control access to a common resource by multiple threads and avoid critical section problems in a concurrent system such as a multitasking operating system. ~ Wikipedia

Think about it. What is it that is in plain sight and is a perfect example of the working of a semaphore?

A public toilet. Unless it is vacant, no one can enter and use it.

Linked List

Well, you already know about it. A linked list is a list whose elements are connected to each other via links. Simple, eh.

It can be traversed from both the sides and can be extended by adding more elements to the front, back or between two elements.

A neat and classic example of a linked list is a train. Yes, the train that sits on a railway station and that takes us to long distances. A train has coaches that are connected to each other by couplings. Additional coaches can be added to the front, back and between existing coaches just like elements in a linked list.

Stack

Another one of the well known data structures. A stack is a collection of elements that grows vertically and to which elements can only be added to and removed from one side, i.e. the top of the stack.

There are many real life examples of stack available to an observing eye, but one of the activities that closely resemble the functioning of a stack is wearing and removing bangles. You only wear them one after the other and the one that is put on at the end is the first one to be taken off.

Network Broadcast

A broadcast is a way of communication in which the sender transmits data to all the probable receivers simultaneously. There is no specific list of receivers that is followed. The receivers decide what to do with the received data, they can decide to process it or ignore it.

Something similar happens with a public announcement at an airport or a metro station. The information is directed to everyone and to no one at the same it. The listeners decide the relevance of the announcement and act accordingly.

--

--

Lalit Mehra
CodeX

Your friendly neighborhood software-engineer. I write about software development, design and architecture, and life in general.