|
Re: Best practices in a thin-controller application: msg#00101php.zend.framework.mvc
Are you sure both Trip and Destination are both equally-weighted objects of the domain? May there be a trip without destination? And does every destination has a trip? The last one really does not make sense if you talk that sentence. ... >Feels a little strange to me, as I've always considered the collection >to be the root of the domain, at least when treating tables and domain >models as though they were the same thing. Is there a better way? What do you mean by "root" of domain? Tables and domain models aren't the same things. A domain model exists without a table with no problems, persistance is only a technical drawback of software or the need for storing something because we have no chance to let the object live forever. A user of a system is a user of the system. He doesn't die if he leaves our system. And if he comes back he isn't born again. We only have a problem to reflect this reality concept in software, so most of the time we need a database. But it's not the problem of the object user...:-) A domain model is *always* the concept that lives in the real world and in your mind and has to be expressed and materialized with your software. >The semantics at this point are confusing, because Collection is sort >of like a table, whereas List is sort of like a rowset...but their >names don't clearly imply this fact. Again: don't think in database terms. Never. You wouldn't do it in the real world, why you should in your software? You use collection for the sum of all your elements in the database. What is that good for? Better express your needs it in pure speech: "Show me a list of all Trips to (from?) France" Who answers this question? Think of a collection or list as something like a list on paper. It's only a list of things (objects) that are not "living", they have no state, they are only written on something or said by someone. If you really have a list/collection that has behaviour, that can do something and that could change e.g. its state then you would need to have an object like that. But do you know any list or collection that lives or has real behaviour? Me not. Just a few thoughts. I don't know your exact requirements, so you have to find out yourself. But always try to express the concept in your head and then create a model of that. Don't think of technology like a database. That is solved somehow. ... Errors should be there where they make sense. And entities (domain objects) should never be created (be returned) if their creation has failed but only in a consitent state. Only if the creation has a state other than "valid" and it is intended to return such an inconsistent object. Therefore I would replace $this->view->trip = new Travel_Trip($this->_getParam('id', null)); if ($this->view->trip->failed == Travel_Trip::NOTFOUND) { with $this->view->trip = new Travel_Trip($this->_getParam('id', null)); if (!($this->view->trip = instanceof(Travel_Trip)) ...error handling... because $this->view->trip->failed implicits that the object was created properly and has an attribute failed (which seems paradox). Greetings, Nino Adam Jensen schrieb: Hello! |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Question about setControllerDirectory: 00101, David G. |
|---|---|
| Next by Date: | Re: Question about setControllerDirectory: 00101, Matthew Weier O'Phinney |
| Previous by Thread: | Best practices in a thin-controller applicationi: 00101, Adam Jensen |
| Next by Thread: | Re: Best practices in a thin-controller application: 00101, Adam Jensen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |