I'm quite confused on how do I build my models, I failed to understand this for the last 9 months. Although I am reading and watching all the references , @teresko gave to me.
To further narrow down my question, I'll give an example of how I did this from before.
Lets say I have a student
entity that has student_number
, first_name,
last_name`
I will then create my so called model
, (my professor did the same, but I know this is quite wrong). I don't know if my professor knows Value Objects, but I do.
private $student_number;
private $first_name;
private $last_name;
public function setStudentNumber($sn) {$this->student_number = $sn}
public function getStudentNumber() {return $this->student_number}
... and so on for other properties
If I am correct, this setters and getters are classified as a Value Object pattern, that can be used like this:
$s = new Student();
$s->setStudentNumber(143);
$s->setFirstName('FooName');
$s->setLastName('BarName');
And pass it in a Data Access Object (StudentDAO) like this:
$sDao = new StudentDAO($s);
$sDao->add();
Where the DAO extends the Database Class, so I can do CRUD for example.
The question is, well, I'm pretty sure I will get a lot of scolding here about I missed too many principles, but what are those? How do I create my models? Thank you! Well, I know many answers will tell about DataMappers, Factories and stuffs, which I cannot understand very well.