DEV Community

Discussion on: What You Need To Know About The Helpful Strategy Pattern

Collapse
kylegalbraith profile image
Kyle Galbraith Author

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.