Search code examples
phpoopobjectmodels

What are domain objects and models in PHP?


I have been reading about domain objects and domain models - and I kind of understand them, but the more articles I read the more i get confused.

A phrase that keeps popping up is "Business logic"! What is meant by this?

Also, what is meant by the word "domain"? That confuses me too.

Any advise and examples would be appreciated.


Solution

  • Someone may be able to give a better whiz-bang computer science answer, but here's the basic meat of it:

    Models or domain objects are the "meat" of what makes your application unique. It is that with which your application is concerned. It is the domain of your application.

    Let's pull that thread a little: every web application has some type of request handling and response mechanism. Every web application (that produces web pages) has some sort of presentation system, even if it's as basic as including a static html page. But not every web application provides a mechanism for retrieving and sending e-mail. Not every web application lets you create and manage events and event calendars.

    If your domain is e-mail, then your domain objects would be things like EmailMessage, AddressBook, or Contact. Non-domain objects might be something like FrontController, or RouteTable, or Dispatcher. You might make customizations to these items outside of your domain, but they aren't what your application is about. Therein lies the difference.