Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Don't forget that in many cases, you can replace a conditional with polymorphism. http://c2.com/cgi/wiki?ReplaceConditionalWithPolymorphism


You certainly can, but it doesn't mean that you should.

Case in point - Linux networking code, and more specifically sockets handling part. Mr. Kuznetsov did an excellent job abstracting a lot of things behind interfaces (= blocks of function pointers), but at the same time this made it much much harder to follow the code. It's basically impossible to trace the code by hand without a pen and paper.

(edit) To elaborate on the context - reading and tracing the code straight off the source files is a necessity of kernel development, routinely required for both debugging and writing new code.


Spend this afternoon figuring out GLOBAL and setting up to work with your editor.

http://www.gnu.org/software/global/


How would this help to understand what sk->ops[SK_READ]->foo[index](bar) exactly calls?


It lets you quickly jump to the definitions of the variables, their types, and their uses. (And then back to where you were.)

It's not going to do all of the work for you, but it'll reduce some of the cognitive load.


This is the same as ctags then, and it's completely irrelevant to the issue with over-abstracting things in the code.


Or pattern matching, if you're lucky.


This is a better suggestion than most of the article. Especially alongside a classic guideline like: "code to interfaces, not classes".




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: