News for hackers. Stuff that matters.
Re:Ask HN: Ask HN: How do you structure your code by hayst4ck on Sunday April 09, 2023 @03:22PM (#35505593)
http://misko.hevery.com/code-reviewers-guide/

This guy was a google test-ability engineer. His assertion is that good code (code that is decoupled/easy to replace) is code that it is easy to write unit tests for because all the things that make unit testing hard is bad engineering, like coupling of components or poorly scoped data.

If I summarized 80% of his the value of his work in one sentence it would be "Don't abuse global scope." It is a surprisingly simple restriction that results in orders of magnitude better code. Calling a function inside of a constructor is using that function from the global scope and therefore it is an abuse of global scope. If you mine his website, which is admittedly outdated, there are many many examples of the consequences of code patterns that will hurt later.

There are no comments on this comment yet.