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.

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

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.
http://stackoverflow.com/questions/3498200/organising-classes-and-modules-in-python

Singletons vs. Modules

A module is the language level implementation of a singleton without the need to prepend self to every methods argument list.
http://stackoverflow.com/questions/3498200/organising-classes-and-modules-in-python

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.

Saturday, August 10, 2013

Third Normal Form

We’ve created functional dependencies between nonkey columns, violating the third normal form. Basically, the value of Discriminator column determines the corresponding values of the columns that belong to the subclasses (e.g. BankName) but Discriminator is not part of the primary key for the table.
http://weblogs.asp.net/manavi/archive/2010/12/24/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-table-per-hierarchy-tph.aspx