DEV Community

Discussion on: It’s all about the abstractions baby

Collapse
 
dance2die profile image
Sung M. Kim

And if you want to abstract even further, instead of an concrete MyObjectCriteria & MyObject, you can extract an interface, thus making it more testable/abstract.

public interface IMyObjectRetriever
{
   IEnumerable<IMyObject> GetMyObjects(IMyObjectCriteria criteria);
}

I think it's overengineering but wanted to point out that abstraction can go far to the point it's unmanageable (but could be easier to mock & test).

Collapse
 
kritner profile image
Russ Hammett

heh, indeed! I've gone down this path a few times, sometimes for actual reasons even! It gets real weird when you're working with everything as interfaces and then start pulling in some visitor pattern action to avoid casts of your interfaces into their concretes. Every time I try to remember how to use or read the visitor pattern, my brain explodes just a tad.

Thread Thread
 
dance2die profile image
Sung M. Kim

I try to remember how to use or read the visitor pattern

I believe the percentage of people who can implement the Visitor Pattern without a cheat sheet should be about the same as number of devs show can do CSS gradient without looking up 😀