GeeksforGeeks App
Open App
Browser
Continue

Coding good – Important criterias

In Order to understand the thinking process of a Problem Solver, we must put attention on the following questions:

1) Why do you like solving problems?

The answer to the this question is worth considering: “Contestants promise that they love math/algorithms and designing data structures. I have seen only a few saying “Oh yeah, I love checking for integer overflows” or “searching for an element in an array is so cool”. And still, we often get stuck doing these exact same things, again and again till our minds try to focus on the original problem statement while our fingers type out the code frantically.

So one solution to the first problem can be:

We solve problems to

1. Challenge our mind,
2. Soothe our egos by looking at green ticks and
3. Taste the adrenaline moving through our veins when we find ourselves in difficult situations.

Conversely, checking for integer division seems to be a monotonous task and that is not the reason why we come here.

There is a way around this, but  now let’s put focus on finding the answer to another problem

2) What is the biggest challenge you face when implementing your solution?

This is often mistaken to be trivial: writing code is, of course, the most difficult task! Oh, and how are we going to speed that up? The usual answers we get is Practice harder, “Work smart, advise others”, before looking into the monitors to debug their programs.

No. Coding an algorithm may be the most important task, but the code that does not work is not very different from code that does not exist. Most of your precious time will be taken up by debugging. especially if the algorithm was difficult to implement.

3) Which key area in your skill set can you improve simultaneously along with problem solving?

The final question is little unclear. What can we enjoy doing simultaneously? Guitar lessons. Gym. Sports, TV shows etc. But as software engineers, data scientists or algorithm designers, we have another duty on which we generally do not emphasize i.e. The job of communicating our ideas. And very often, all that people have to understand our ideas of code.

Competitive programmers are generally told: “be lazy“. No. Laziness is not a compulsion. It is like any other skill and must be used only when needed. Being lazy while designing the algorithm and naming variables can save 3 minutes of coding time, but it can cost additional 20 minutes through penalties/debugging. Surely, we require a better approach.

Now let us look at the better approach:

Using tools, libraries and patterns in our code not only makes problem solving easier, it also answers all the three questions mentioned in the beginning of the article.

1) Provides focus on facing the programming/mathematical challenge instead of other dull tasks.

2) Using library functions and following coding practices, greater reduction is possible in testing and debugging time.

3) The purpose should be to have fun, and at the same time also to learn lots. Outside the world of competitive programming, lies the software development. While honing the skills of algorithm design and data structure usage, we can learn how to write clean code.

Characteristics of a clean code are:

1. Proper indentation
2. Good naming variables save time, which you can invest on the next problem.

Finally, programming requires the ability to think logically and correctly. A programmer should always be creative, imaginative and innovative. A programmer should not get agitated if he/she is not able to solve a particular problem. But instead try another problem in the meantime.

This article is contributed by Mudit Maheshwari. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.