Skip to content

Many different ways to solve a problem

Every time you need to face a problem, possibilities are that someone else already faced it, and eventually resolve it in a smart way. A big part of our work consist in discovering solutions around the web, and try to understand if they could fix our current architecture. This is important, because it’s the difference between a reckless abuse of cut & paste and a proper integration of a different codebase inside our project.

But what happens when you call people, that indeed are great in everyday work, for solving some very simple theoretical problem?

I accidentally did this funny test while assessing some some tasting platforms I’d like to include in our recruiting process. One of this platform is pretty neat: it allow you to create some very beginner to intermediate code assessment that the candidate need to complete as part of the recruitment process. The nice part is that in the platform I can see exactly what the user did, how many times he tried to run the code, how he manage to debug code during a test that doesn’t allow debugging.

I’m not a big fan of code tests during recruitment process: some people are pretty good at their work, but not so good during interviews, where the pressure could lead to very strange behaviours. That said, I’m starting to plan to include something simple, because I feel it could be very useful to understand how a candidate actually think during his/her code production.

It came out I discovered three different kind of candidate:

The dino

Plays the game in safe zone: trying to use as much old school code as he can to obtain the result.

The middle man

Tries to leverage some of the syntactic sugar / shortcut offered by the technology, but not being too extreme.

The z-boy

Tries to resolve the problem using as much lambda, expression and everything as he can to keep the code short and fancy and sexy. (yes, the title is from “Dogtown and Z-Boys“, if you were wondering).

Is there a winner?

It was funny to see such differences and being surprised from the different approaches. But that said, is there a right or wrong way to do it? Honestly I think that the answer is no. If you later talk with the candidates, you can find out that maybe there’s a reason for going for the “dino” approach. It could be because I don’t remember exactly the syntax of something and having a short time and no lint / editor help, decided to go for the safe approach.

This is exactly the same approach in the real code: IMHO, using a for cycle or using the filter prototype of the array, is not a matter of “the second one is better”. They both works, and they are actually quite similar.

There are no “right” or “wrong” solutions to a problem, there are solutions that fits the current architecture, and solutions that don’t.

Alessandro Ghizzardi

The best approach would be to know all the possible solutions available for a given problem, and ask yourself a simple question: is it performance an issue on this particular code block? If it is, then stop and understand which of the best solution is optimal for the result. If is’t not, just go for the solution that best fits the architecture you’re working into.

… and if it’s a new project, yes just go for the z-boy solution! Sometimes trying to push a bit ourselves when starting a new project and when free to experiment, it’s a very nice way to learn to learn how to handle our lightsaber!

Photo by NeONBRAND on Unsplash

Published inTech life

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *