I recently started to study OOP and MVC but I have lot of problems already! :)
I would love a clarification about the list on this site http://c2.com/cgi/wiki?DomainObject
- recognize which [of their] references indicate aggregation and which ones indicate association
- copy themselves
- maintain business logic
- compare themselves to other domain objects of the same type
- facilitate other objects that choose to print or display them
- conduct tests on their domain information"
- identify themselves
- validate themselves
1: are they referring to a list of methods that return ID's of other domain objects?
7 & 8: what do they mean with "identify and validate themselves"? how should this work since identification and validation would probably require the access to the persistence layer?
I've read a lot in the past months but I can't actually say I have a solid idea of OOP/MVC :(
What is this validation? And why do I need it? And how is it supposed to be performed? If data comes from a database why would I need validation since persistent data is already valid?
With just my own insightfulness I made up this set of classes for each model entity I have:
// it holds Student information, it can also contain partial data
// (for updating just certain fields in the database)
interface Student
{
getID($id)
setID($id)
getName()
setName($name)
getSurname()
setSurname($surname)
}
interface StudentValidator
{
validateInsert(Student $data)
validateDelete(Student $data)
validateUpdate(Student $data)
}
interface StudentMapper
{
getByID($id)
getAllByClassroomID($crid)
updateByID(StudentValidator $v, int $id, Student $data)
deleteByID(StudentValidator $v, int $id)
deleteAllByClassroomID(StudentValidator $v, int $crid)
insert(StudentValidator $v, Student $data)
}
how far is this from being decent code? :)
thanks in advance!!!