re: What You Need To Know About The Helpful Strategy Pattern VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Great post sir, I have some points though. At run time the "ifs and elses" and "_extractors.FirstOrDefault(e => e.UseExtractor(fileExtension));...
 

This could certainly work but it loses the benefit of abstracting out the extractors. The idea is that each extractor knows what it can extract and it indicates that with the function that finds it.

This provides nice encapsulation by allowing the class that implements the interface to decide what it can extract.

Your idea would be quite different and more akin to the Factory pattern.

code of conduct - report abuse