Is ServiceLocator an anti-pattern?

If you define patterns as anti-patterns just because there are some situations where it does not fit, then YES it’s an anti pattern. But with that reasoning all patterns would also be anti patterns. Instead we have to look if there are valid usages of the patterns, and for Service Locator there are several use … Read more

Why are Callbacks from Promise `.then` Methods an Anti-Pattern

You should change it to var getTokens = function() { return $http.get(‘/api/tokens’); }; And, then in other module use yourModule.getTokens() .then(function(response) { // handle it }); As to why it’s an anti-pattern, I’d say that, first, it doesn’t allow you to further chain your success/fail handler methods. Second, it handles the control of processing the … Read more

Why is Singleton considered an anti-pattern? [duplicate]

To help with answering, here is more about the anti-pattern comment: it is overused, introduces unnecessary restrictions in situations where a sole instance of a class is not actually required, and introduces global state into an application From: http://en.wikipedia.org/wiki/Singleton_pattern For more on this you can look at: https://www.michaelsafyan.com/tech/design/patterns/singleton Here is a great ending to the … Read more