Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Facade as a separate class/responsibility #6

Closed
schlessera opened this issue Jan 24, 2018 · 2 comments
Closed

Static Facade as a separate class/responsibility #6

schlessera opened this issue Jan 24, 2018 · 2 comments

Comments

@schlessera
Copy link
Contributor

In the ObjectCache class, there's this comment:
https://github.com/felixarntz/wp-psr-cache/blob/master/src/ObjectCache.php#L771

The main problem is that you're trying to put multiple things into one class. A static facade is a separate responsibility and should go into a separate class. This way, static calls will properly work, and you can get rid of the getInstance() calls.

@felixarntz
Copy link
Owner

Ah that makes sense. I had initially looked at your static facade library and assumed that it would easily enable calling methods statically without a real singleton, until I noticed that existing non static methods are preferred over __callStatic(). But yeah, having it inside the class wouldn't make sense anyway. Let's continue discussing a solid approach in #7.

@schlessera
Copy link
Contributor Author

My Static Facade is meant to create objects that fulfill that single role. It is not meant to extend existing, real objects. Always prefer composition over inheritance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants