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

POCO - Defined

EF Code First enables you to use “POCO” – Plain Old CLR Objects – to represent entities within a database. This means that you do not need to derive model classes from a base class, nor implement any interfaces or data persistence attributes on them. This enables the model classes to be kept clean, easily testable, and “persistence ignorant”.
http://weblogs.asp.net/scottgu/archive/2010/12/08/announcing-entity-framework-code-first-ctp5-release.aspx

Saturday, July 13, 2013

Rule Triggers

Example of a "rule trigger" (which I believe muddies code when placed inline, which is why we need standard rules engines?)

Being a member of "Halloween Sale" does not mean that the item is always on sale. The "rule trigger" should also take into account the date. Example:
  HALLOWEEN = 18   // See example tables above
  if memberOf(item,HALLOWEEN) and month(today()) = "October" then
    item.price = item.price * 0.9
  end if
http://www.geocities.com/tablizer/sets1.htm