This article on game development touches on the nuances faced and the angst developers face when dealing with complex systems and still adhering to best practices ala IoC. The highest voted answer seems to favor neither the service locator pattern nor the singleton, but seems to lean toward dependency injection ("passing around the instances"). Nevertheless the OP appears to settle on Service Locator.
http://gamedev.stackexchange.com/questions/84197/how-can-i-avoid-having-many-singletons-in-my-game-architecture
An alternative to all three could be AOP as shown in this old article: http://blogs.msdn.com/b/simonince/archive/2008/06/30/dependency-injection-is-dead.aspx
But if you think that DI is hard, DI via AOP is certainly an order of magnitude harder -- which is probably why it's not spoken of much.
Thursday, October 2, 2014
Wednesday, July 2, 2014
Private Inner / Local Classes - Advantages / Disadvantages
Good debate found here: http://stackoverflow.com/questions/3353318/how-do-i-test-local-inner-class-methods-in-java
The consensus (and accepted answer) is that in general if it's important enough for a local / private inner class to be tested, it should refactored out, e.g. to a separate package.
On the other hand, "bob" makes a good point about keeping the class internal as an implementation detail for the sake of cohesion.
Kai Sternad provides an answer that probably could have been accepted.
The consensus (and accepted answer) is that in general if it's important enough for a local / private inner class to be tested, it should refactored out, e.g. to a separate package.
On the other hand, "bob" makes a good point about keeping the class internal as an implementation detail for the sake of cohesion.
Kai Sternad provides an answer that probably could have been accepted.
Saturday, November 2, 2013
Transactions and ACID Principle
http://blogs.curtin.edu.au/webdev/2010/05/09/nested-cf-transaction-blocks/ - article gives good use case for nested transactions: insert user, then add-or-update content items which are associated to the new user.
Saturday, September 28, 2013
Django and MTV
MTV for Model Template View, to replace respectively Model View Controller
http://www.djangobook.com/en/2.0/chapter05.html
http://www.djangobook.com/en/2.0/chapter05.html
Saturday, September 14, 2013
Single Responsibility Principle
The rational behind the exact example that you gave is that if each class has a save method, then if you later change how you are saving data (from say filesystem to database or remote XML file) then you have to change every class. If each class implements an interface to yield that data that it wants saved, then you can write one function to save instances of every class and only change that function once. This is known as the Single Responsibility Principle: Each class should have only one reason to change. |
Singletons vs. Modules
A module is the language level implementation of a singleton without the need to prepend
|
Sunday, September 8, 2013
Allowing Nulls in R-tables
According to Codd a "table with at least one nullable attribute" (Wikipedia) disqualifies it from being 1NF.
http://en.wikipedia.org/wiki/First_normal_form
But while the NULLs do not violate 1NF, they do violate the core relational Information Principle (IP), which requires data to be represented in exactly one way--as values in R-tables.
Subscribe to:
Posts (Atom)