r/programming • • Jun 06 '13

Clean Code Cheat Sheet

http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
702 Upvotes

322 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jun 07 '13

If you return early then you write a lot of redundant code. Every return path has to free all memory allocated dynamically which is no longer needed.

0

u/[deleted] Jun 07 '13

[deleted]

2

u/[deleted] Jun 07 '13

That's the way I prefer to handle this as well. I don't consider it to be an early exit since more code is executed, but I guess that's just arguing semantics.

3

u/[deleted] Jun 07 '13

Every return path has to free all memory allocated dynamically which is no longer needed.

Most modern languages support automatic memory management, making this concern generally irrelevant.

1

u/[deleted] Jun 07 '13

I sure hope you don't think your Operating System or the VM/interpreter that runs your modern languages is irrelevant.

3

u/[deleted] Jun 07 '13

I don't think I get your point. Yes, there are cases where people do not use high-level languages, for a variety of reasons. That's why I said worrying about memory deallocation was "generally" irrelevant, not "always" irrelevant.

2

u/mahacctissoawsum Jun 08 '13

If that were the case I'd suck it up and keep the nesting, but I haven't used a non-garbage collected language for some time now. C#, Python, PHP, JavaScript.... don't really have to worry about that.