3 ms·
I tend to agree. Too many classes can create obfuscation and confusion. I generally don't mind some overlapping function so long as my instinct tells me it ma
by jomamaxx 10y ago
I tend to agree.
Too many classes can create obfuscation and confusion.
I generally don't mind some overlapping function so long as my instinct tells me it makes sense.
I used to make classes for everything. Often ahead of time.
Now I make classes generally only as needed.
Also - the title is a little misleading.
At the OO level, this is not really even 'code' - it's 'design'.
'Code', I often think of as what's written, i.e. inside the functions etc..
As far as that goes, 'clean' is really important when it's exposed.
Anything that is really tightly encapsulated within a function ... well, can be a little grimy so long as it's not so bad. Point being, it's uglyless cannot spread beyond the function.
But some things - especially API's - it's really important that they make sense, because they represent the language of the application.
I'll take clean, consistent API's with messy 'code' than crap API's with tight code any day. You can always fix the code. APIs ... create dependency problems, and bad ones spread problems.
- cgriswald 10y agoAgree in general. > Anything that is really tightly encapsulated within a function ... well, can be a little grimy so long as it's not so bad. Point being, it's uglyless cannot spread beyond the function. Of course, if you're in the position of having to debug that function, you might curse its griminess. I tend to only write really gnarly functions if I'm trying to heavily optimize them and it is only by virtue of those optimizations that they become grimy. And even then, I tend to do it only for those functions that can easily and quickly be rewritten entirely. (And I also try to write them one optimization at a time so I can always fall back to an older, less optimized one if a bug is introduced.) And, of course, there are always comments to help light the way and warn of dragons.
- jomamaxx 10y agoYes - but my point is, you're 'having to re-write' that function is not an existential problem for the product or company. It's just a shitty piece of work. Any individually poorly written but well encapsulated piece of shit is just a 'bathroom clean' away from being nice. Contrast that with bad design, bad APIs, or other things: they mess up other things. They can even create massive, ugly dependencies, and massively increase complexity, bugs etc. etc.. I've seen build-chains that involved 6 different scripting languages. Because we all had to use it, and almost nobody knew all 6 languages, it f*ed the whole company and caused huge pain.