0

I'm getting used to DDD so don't assume I'm a DDD pro yet. I'm trying to implement a hexagonal architecture using the CakePHP framework in a completely custom made application that just utilizes the framework but doesn't built something based on the app skeleton it has. CakePHP is using the data mapper pattern, not active record as most people assume.

After reading a lot it seems to me that the table objects in CakePHP and the entities represent already what I'm after for my domain layer?

  • It appears that entities in the ORM are already my value objects I want in my domain layer?
  • It appears that, for example the table objects, implement already a repository interface and also act as aggregates by defining the associations to other tables

That's at least what I think. My question is now if my assumption about this is true?

0

I'm not an expert on CakePHP, but I did look at read up on the docs and looked through the code base. It appears to me that you're correct in your assumption. Entities are value objects and Table's are a type of domain object that are akin to Repositories. Also, after reading the docs a bit it seems your mostly right to think it's DataMapper and not Active Record.

Right here https://book.cakephp.org/3.0/en/orm.html it says:

The CakePHP ORM borrows ideas and concepts from both ActiveRecord and Datamapper patterns. It aims to create a hybrid implementation that combines aspects of both patterns to create a fast, simple to use ORM.

After reviewing the code and docs it seems like their statement is very accurate. Their ORM is trying to be both... which seems bad, but I could be wrong.

  • Why would it be bad, could you please add some details on this point? – burzum May 28 '18 at 8:40
  • It just seems bad to me (highly subjective) because it's trying to follow two paradigms which are orthogonal in some respects. Data mappers usually have strong separation of concerns where active record patterns tend to be a bit monolithic in their approach. Seems confusing to try to combine those two together, but I could be wrong. – zquintana May 29 '18 at 15:20
  • Is there proof of Data Mapper through example implementation? – Travis van der Font Mar 14 at 15:45
  • @TravisvanderFont, i'm not sure what proof you're looking for. See cakephp docs noted in post. – zquintana Mar 14 at 20:46
  • @zquintana, Examples of actual Data Mapper from Cake? In the docs it only states what's quoted above. However, I see no implementation examples.. unless, it's buried in the docs somewhere... o.O which is why I ask! – Travis van der Font Mar 19 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.