Difference between @Delegate, @Mixin and Traits in Groovy?

I agree, they all seem to allow reusing multiple “classes” of behaviour. There are differences, though, and understanding these will probably aid your decision. Before providing a brief summary/highlight of each feature and examples of suitable usage, let’s just summarize on the conclusion of each. Conclusion / typical usage: @Delegate: Used to add all the … Read more

When are design patterns the problem instead of the solution? [closed]

I don’t think the patterns per se are the problem, but rather the fact that developers can learn patterns and then overapply them, or apply them in ways that are wildly inappropriate. The use of patterns is something that experienced programmers just learn naturally. You’ve solved some problem X many times, you know what approach … Read more

What is the best way to pass common variables into separate modules in Node.js?

I have found using dependency injection, to pass things in, to be the best style. It would indeed look something like you have: // App.js module.exports = function App() { }; // Database.js module.exports = function Database(configuration) { }; // Routes.js module.exports = function Routes(app, database) { }; // server.js: composition root var App = … Read more

Are Doctrine2 repositories a good place to save my entities?

Yes, repositories are generally used for queries only. Here is how I do it. The service layer manages the persistence. The controller layer knows of the service layer, but knows nothing of how the model objects are persisted nor where do they come from. For what the controller layer cares is asking the service layer … Read more

What is the difference between Command + CommandHandler and Service?

Having Commands gives you the benefits of the good old Command pattern: you can parameterize an object, e.g. a UI element, with a Command to perform you can store a Command and execute it later, e.g. in a queue or a transaction log you can track which Commands you executed, giving you a foundation for … Read more

Singleton in go

Setting aside the argument of whether or not implementing the singleton pattern is a good idea, here’s a possible implementation: package singleton type single struct { O interface{}; } var instantiated *single = nil func New() *single { if instantiated == nil { instantiated = new(single); } return instantiated; } single and instantiated are private, … Read more