DEV Community

Cover image for Programming Explained With the Human Body - Frontend, Microservices Backend and Testing
Dennis Persson
Dennis Persson

Posted on • Originally published at perssondennis.com

Programming Explained With the Human Body - Frontend, Microservices Backend and Testing

In this article, we will explore the human body. We will visit the doctor and we will translate "unit testing backend code" so anyone knowing what a heart and a brain is will understand.

You have gotten the question a million times, haven't you? What is the difference between frontend and backend? What do you answer? "Frontend is what you see and backend is what you don't see?". Kind of a boring answer, isn't it? After reading this article you will have a better explanation to shine with. And even grandma will know what you are talking about!

Is Backend the Brain or the Heart?

Everything starts with the brain or the heart, doesn't it? Our two most beloved organs. Yeah, I said two, you will have to visit some other site to read about the third and fourth organs.

Which of the brain and heart would compare to the term "backend"? Can you guess it?

Empty space
I've just added some empty space here so I don't spoil the answer (photo: Gary Scott)

If you answered the brain, you were right. If your answer was the heart, you were right as well. Backend would actually be all the inner organs in the body. Backend is the brain. Backend is the heart. Backend also includes the useless little appendix that probably once had a purpose, but nobody no longer knows why it's there and nobody cares to remove it as long as it doesn't pose any problem.

Well, that's a sentence I never thought I would write. Maybe that's how all those weird Google autocompletes comes up?

Google search autocomplete for backend is
That's a weird suggestion... Is it for real?

(Yeah, that's how google.com looks like for me, this is how I styled it)

Backend Microservices

Back on track, I said backend could be compared to all inner organs, not just the brain. When building web services today, backend is often split into microservices. Each microservice has its own responsibility, it serves one functionality and then communicating with other services through a network. That network would be our nervous system when speaking about the body and the services would be organs.

Together, all microservices in an application work together to keep the application up and running just as all organs in the body work together to keep you alive. Some organs in the body are vital and can't be removed, like the brain. Other organs are less important and can be substituted, like the stomach. The body will continue to function without them although you may have to patch the body a bit to make it work. Other organs, such as the kidney, are organs we can't easily live without but we have multiple copies of. If we lose one, we can still continue to live on with the other one.

A microservice backend works in the same way. Some services can't be removed while other can, even if the application may not be of perfect use. Parts of it could be running while some certain functionalities could malfunction, e.g., a chatbot. That's one of the key advantages of microservices, to keep the application running even when individual services go down.

Another way to ensure that a service is running is to scale it. Scaling an application means to either run it on more powerful machines (scaling vertically) or letting the application run on more than one machine (scaling horizontally). With microservices, we can scale each service individually. If the chatbot would be very important for our application, we could run it on two or more machines while other services can continue to run on one machine. Just like the body has two kidneys and only one nose. The nose is less important, you will look a bit peculiar if you lose it, but we can live like that.

Voldemort nose meme
I intentionally avoided mentioning anyone by name...

Frontend Is the Beauty and the Feel

Obviously, frontend is what you see. Your face, your muscles and your way of walking. But it's also all of your external organs. Your ears would be speech recognition, see Web Speech API. You have a mouth that outputs audio and eyes that work like a camera. When you click on a button on a web page it will notice it, just as you feel when someone presses your skin.

Tom and Jerry developers meme
Was Tom & Jerry the first cartoon developers?

Testing Is for Doctors

Testing is what doctors do. Human doctors can examine specific organs or diagnose illnesses that affect the complete or parts of the body. The difference between unit and integration testing would be that unit testing tests individual organs while integration testing searches for diseases affecting the whole body or integrations between body parts. An example of the latter one could be an autoimmune disease where a person's immune system mistakenly attacks other parts of the body.

If doctors would have used the same terminology as developers do, doctors could have been divided into frontend, backend and full stack doctors dependent on what they did. Examinate skin problems would be frontend investigations and listening to a patient's heartbeat would be to monitor backend functionality. Figuratively speaking, "unit testing backend code" could be translated to "diagnosing inner organs".

Backend doctor meme
In the world of web development, doctors could be either frontend or backend doctors dependent on their specialties

The Soul

What about the soul? Isn't a part of body, or is it? Does it really exist? I know what my view on it is, but let's hear about yours. Leave a comment!

Thanks for reading,
Dennis Persson

Top comments (0)