Engineering Mental Model — Analogy of a Restaurant Kitchen
Engineering Vs Restaurant Kitchen
Engineering should learn how restaurants divide and conquer the work to prepare a fancy meal. They have Chefs who work inside the kitchen that needs to make sure that the dish is consumable, while the Waiters need to be responsible that the dish is served well to the guests. These 2 play an important role in creating the best experience for the guests, so it’s important for both parties to work hand in hand to make that happen.
With this analogy, Backend engineers are the Chefs inside the kitchen while Frontend engineers are the Waiters that serve the dish. And the table between these 2 parties is the API contract that needs to be preserved. We have to make sure that by the time we have the dish (data) ready on that table (API contract), it’s already consumable by the guests (client). The job of the Waiter (Frontend) is just to serve the dish (data); all the cooking (business logic) should happen in the kitchen (backend).
With this segregation of work, we can make sure that both sides can work effectively and efficiently. We can easily measure how each of them performs and we know what each of the 2 sides is responsible for. Let’s say there’s an undercooked dish, we can easily point out where we should fix the dish.
Now imagine a world where we are not following this pattern. Chefs will be handing over raw meat, and Waiters need to cook the meat using whatever tools that are available outside of the kitchen — insane! Another problem is that it’s now much harder to point out who should be responsible for that uncooked meat since both parties are responsible for cooking the data.
Going back looking at the problem from the engineering’s perspective. Most times, engineers don’t realize where do they should draw the line between what should be done on the Backend side vs the Frontend side. The rule of thumb is just to follow what we discussed above.
Backend engineers as the Chefs should focus on getting the data cooked, while Frontend engineers as the Waiters should focus on the presentation side of the cooked data.
Backend Engineers as the Chefs
It doesn’t matter what kind of API architecture that you’re using, the idea of getting the processed data from the Backend should always be the directive. So when building an API, question yourself: as the Chef in the kitchen, am I sending raw data, or is this cooked data that can be presented to the client.
Also as Chefs, you still need to listen to what Waiters are saying eg. the customers want the meat to be medium-rare, then in that case you will need to provide exactly like what the agreement between you and the Waiter.
Frontend Engineers as the Waiters
On the other hand, on a simple term Frontend engineers are the Waiters to serve the dish to the guests. But in more complex engineering practice, Frontend Engineers should act like the Head Chef where they are responsible for how the data is being presented like the illustration below.
Composing each data from different services and making them look pretty is the responsibility of the Frontend engineers. They might need to use the blow torch to cook it even more in some cases, but definitely not all cases.
The Ideal Restaurant Kitchen
To have that perfect restaurant, we all have to work together as a team, but moreover having segregation on what should be done on each part is going to create that good synergy in the restaurant — just like a good engineering practice.
Backend Engineers as Chefs should be responsible for processing the data and sending it as close as possible to what will be served to the client. All the business logic should happen on the Backend side because the Backend has all the ingredients and tools to make it happen.
Frontend Engineers as Waiters should be responsible for serving the data in the right sequence, presentable UI/UX, and appetizing for the client to consume.
As a closing sentence, to have that ideal engineering practice, we will always need to remember our responsibility and where do we draw the line between engineers. Hopefully by having this analogy of a restaurant kitchen should help you draw that line for a better engineering process!