GithubHelp home page GithubHelp logo

domain's People

Contributors

gitter-badger avatar rayrutjes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

domain's Issues

Demo / Example

Do you have a simple example of how you are implementing this?

Thanks!

Feedback

Hey Ray,

you've requested some feedback for your repo on the DDDinPHP mailing list. Here it is :-)
Good job so fare ๐Ÿ‘ I like the naming convention and the structure.

I only have some hints and a few notes to may start a discussion:

  1. I would move the method AggregateRoot::id (or remove it, see point two) to the Entity interface and remove the AggregateRoot interface. The methods AggregateRoot::recordEvent and AggregateRoot::pullRecordedEvents should not be public. Only the AggregateRoot decides when it records an event! And as long as you don't implement EventSourcing you don't need the pullRecordedEvents method. Simply return a DomainEvent from the AggregateRoot method which handles the action. If you implement EventSourcing later the pullRecordedEvents method should not be public anyway. Pulling the events from the AR would then be the job of an Unit of Work which is normally located in the infrastructure and can use reflection or a decorator to access pending events. Such infrastructure concerns should not pollute the public API of your ARs.
  2. The AggregateRoot::id method is generic. In DDD you want to have explicit identifiers like a UserId, TrackingId, etc. Sure in most cases these VOs will extend the Identifier class but you will end up having two public methods like Cargo::id and Cargo::TrackingId. Question is: Why do you need the method? Your current Entity interface looks good as it is: Entities are compared by identity. That is the important information. No need for a public id method.
  3. Your current event publisher implementation allows only one event per subscriber. You will run into trouble with this when you need to implement a ProcessManager. Normally a PM needs to subscribe to multiple domain events to coordinate follow up tasks and/or track state of a long running process. Also the publisher requires registration of instantiated subscribers. Sooner or later you will need to implement a lazy loading mechanism but that is a different story.
  4. Do you really need to support PHP 5.4? If not you could require PHP 5.5 and use \DateTimeImmutable instead of \DateTime. Then you don't need to clone it before returning it from an event.

That's it. Hope it is useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.