Settings

Theme

Google's advise to use abstraction to improve function

testing.googleblog.com

3 points by Maksadbek a year ago · 3 comments

Reader

MaksadbekOP a year ago

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.

  • mtrovo a year ago

    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.

  • vbgamer45 a year ago

    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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection