Giter Site home page Giter Site logo

trip-planner's Introduction

Trip Planner

A sample code for a DDD application. It's not a complete code ready for production, but it's working. You can follow the building steps, starting from first commit.

The purpose: planning a trip, choosing a leg for every date and a location for every leg.

Domain

  • Trip has a name and at least one Route
  • Trip has an identity; a Route has a name, and an internal identity
  • Route can have one or more Leg; a Leg has a Date and an internal identity
  • A Route can't have two Leg with same Data
  • A Leg has a Location; a Location has a name and a Point
  • Point has coordinates and the logic for distance calculation
  • The Route knows the approximate road distance
  • A route could be duplicated
  • A duplicated Route could be added to the Trip
  • Trade-off: removed InternalIdentity value object
  • Fix: Date::input should be a DateTime
  • Trade-off: we need a custom Event Dispatcher
  • Trade-off: getters on commands, for integration with form

Application

  • Command Handler: manages the flow "Command -> Use Case"
  • CreateTrip Command and UseCase
  • We need the Repository for Trip
  • AddLegToRoute Command and UseCase
  • UpdateLocation Command and UseCase
  • We need validation: command validation using external service is a good trade-off
  • Mmmh too many exceptions ... we need uniform responses
  • Finally Events and Event Dispatcher

Infrastructure

  • Framework's revenge: Symfony 2.5 and Doctrine 2.5
  • InfrastructureBundle
  • Mapping entities and value objects ... ops, Doctrine seems not work with a Value Object (with strategy auto) as identity for another entity
  • Configuring services and creating Infrastructure services: Repository, Adapter for Validator, Validation ... ops, the Symfony's dispatcher does not fit

Presentation

  • A simple controller with a form
  • Symfony2 Form requires getters for the mapped entity

trip-planner's People

Contributors

leopro avatar

Watchers

 avatar

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.