3

Google's advise to use abstraction to improve function

While Google advises to use abstractions, I like the left-hand side variant. It looks to me easier to understand and change. The right hand side is scattered and abstractions mutate the object, which may have side effects.

5 months agoMaksadbek

It's all about the right level of abstraction at the right time. The example given is too kind to the reader, I can imagine functions with 1000s of lines with the exact same structure of doing too much distinct sub-steps. Of course you don't want to create something like the indirection hell that frameworks like Spring in Java create but it's not hard to find a middle ground. For instance I find it specially easier to create code like the right-hand side when I'm using test driven development.

5 months agomtrovo

Agreed more readable, instead of searching/scanning. That's an issue I have with larger projects, more files and classes to jump to for not any gain really.