5 ms·
Abstract till you drop. Going beyond 'extract till you drop'
- candeira 11y agoI wanted to hear what HN has to say about this, because to me it reads like a parody, but maybe I'm the ignorant one, and can learn something.
- Delmania 11y agoMy response? YMMV Abstractions help to create clean, readable code. You do create lots of small classes, but they tend to be focused on one thing and are easily verified by unit tests. It helps debugging since it helps you focus on the area that is causing an error, without having to know how the full system is working. The downside is that is does scatter the code around, and the creation of units tests requires discipline. When you're first learning the system, it can be challenging since the code is not all in one area.
- candeira 11y agoYes, but just to search/replace code? In a language that already has regular expressions? Maybe I'm being too literal, and I was supposed to see beyond the particular example, but hang me if I see the point of filling a screen with code for a functionality that can be written in two lines.
- Delmania 11y agoPart of the Bob's argument was that the function was not just doing a replacement, but also a ensuring the replacement was only done once. Essentially, there's state maintenance in there, which complicates things, hence the original post about extraction. Extraction provides descriptions to the state maintenance. I would agree this particular post is taking abstraction to an unreasonable level, but that is definitely a subjective analysis.
- nstart 11y agoPosted it here precisely because I wanted to hear what the opinions were. For what it's worth, I found this through cleancoders twitter feed. Their recommendation
- crazy_geek 11y agoHaving inherited much code like this in the past, I can tell you I feel bad for the poor people who inherit this crap. Over extraction is okayyyyy-ish. Over abstraction is rage inducing. If you're over abstracting, you're making and polishing a wonderful monument to yourself made of turd for someone else to deal with. Edit: I remembered that I wrote a blog post about this: https://drew.thecsillags.com/cult-of-abstraction/ https://drew.thecsillags.com/cult-of-abstraction/