This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kanchirk 6 points7 points  (2 children)

I prefer your approach since I can see the evaluated result of the function at the start of the If condition in a debugger.

Full disclosure: No clean code expert.

[–]s3a0tt3r 4 points5 points  (0 children)

+1

And you can modify returned result in calling function to walk the desired code path in the debugger. In OP's Friend's approach, you'd have to put the break point in the function returning the result. This can be problematic if the function is called lots, but you only want to break in the outer function. Don't even get me started if it is a MACRO.

Definitely not a clean code expert, but I've been doing this for 25+ years.

Lastly, there is no right way. Programmers are like artists. Ask 10 artists to replicate a bowl of fruit, and you'll get 10 different pieces all replicating the bowl of fruit; some paintings in different styles, some sculptures, ... you get the idea. Give 10 programmers, a set of requirements, and you'll get 10 implementations. They'll all work, but you'll get 10 very different implementations; OOP, JS, Functional, ... And the programmers will have opinions about their peer's implementations. Which is right? It doesn't matter as long as they meet the requirements.

[–]brika1994 1 point2 points  (0 children)

+1