Frage

I am constructing an object using data from a database table by passing the primary key of the row of data I want to use to construct the object.

Should the population of the member varibles of this object take place in the constructor or another method called by constructor or somewhere else altogether?

How is this done in a rails ActiveRecord and other ORMs, I suspect there are a set of setters which are called for each field by the framework, but I don't really want a complex framework doing all this so whats good practice to role my own simple mechanism?

Note: Keeping in mind I don't want to be creating a mass of anemic data models which can't manage there own state.

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top