I need a viewpoint for this question : Writing shorter code is not always the sa
ID: 3776855 • Letter: I
Question
I need a viewpoint for this question :
Writing shorter code is not always the same as writing code that's easier to understand. For example, look at this pseudocode:
Here's a different version of the same code (it produces the same results for all values of OriginalPrice):
Some people look at the first version of the code and they think it's brilliant. It gets rid of all of that "complex" logic in the case structure and substitutes a "simple" calculation instead. I completely disagree with this, but I'm not going to tell you why just yet. Instead, I'm going to ask you for your opinion.
My question is the following: Do you think the first module is better or worse than the second version? It's OK if you think it's better, but I want you to explain to me why you think it's better. If you think it's worse, I'd like you to explain how you would convince the author of the code that the "dumb" way of doing it is better than the "smart" way?
Explanation / Answer
As a programmer I would also like to code as earlier one. Because this will help us to reduce the burden in many ways. It is simple to implement the coding logic and easy to understand also if we could be able to spend some time on it. By keeping our code short and simple we can save our time, can reduce the time complexity of code. Here the program will do only what it has to do unlike the last one whether you need it or not you have to go through every line of code while executing. So writing short and simple code snippets will serve us better than long and precise one.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.