r/ProgrammerHumor • • Nov 25 '22

Meme Coding strategies

Post image
52.2k Upvotes

385 comments sorted by

View all comments

Show parent comments

34

u/DoctorWaluigiTime Nov 25 '22

Interface-based development is more than "you make an interface so you can plug multiple implementations" into it, though. Helps keep good code decoupled and reduces dependency infestation across projects and classes. Makes it easier to mock/fake too when testing code.

Making an interface for a class is not some symptom of overengineering a simple solution, nor does it take excessive amounts of time to do.

5

u/euph-_-oric Nov 25 '22

Agreed. Everyone here glorifying spaghetti code, because business...? It's like you save time and money in the long run by writing clean code. But literally in every field it's like the only thing thst matters is right now. This quarter. Not long term viability. In code and in business.

2

u/Mareeck Nov 25 '22

Dependency Infestation LMAO I gotta use that

2

u/woodside-jump Nov 26 '22

Also, if you do not use interfaces, you have to make 1 huge pull request for the entire feature that no reviewer actually reads.

With interfaces, you can create several digestible cohesive pull requests that can be merged in separately without breaking the application. Some interfaces just remain temporarily without an implementation.

1

u/anubus72 Nov 25 '22

sure, that's true in some cases. It's also very unnecessary in some cases

2

u/DoctorWaluigiTime Nov 25 '22

I'd wager it's true in most cases, in my experience. If nothing else I know I'd rather have an overabundance of interfaces than not enough. (And frankly I've yet to see someone doing it for the sake of doing it and providing no benefit to the application.)

1

u/goofan Nov 25 '22

Yep. I had OPs opinion years ago before I understood their value.

Also helped when I realised if they're single use interfaces just chuck them in the same file as the implementation so it doesn't overcrowd the file structure.