Skip to content

Instantly share code, notes, and snippets.

@raykolbe
Last active December 15, 2015 07:59
Show Gist options
  • Save raykolbe/5227403 to your computer and use it in GitHub Desktop.
Save raykolbe/5227403 to your computer and use it in GitHub Desktop.
CRUD in Application Service -- Is it a smell? #dddesign
<?php
namespace Application\Catalog\ValueObject;
class AvailableVenues
{
public function __construct($isOnline, $isInClassroom)
{
// set properties as bools
}
public function isOnline()
{
// return bool
}
public function isInClassroom()
{
// return bool
}
}
<?php
namespace Application\Catalog\Service;
class CatalogApplicationService
{
public function getCourse($courseId)
{
// return Application\Catalog\Entity\Course
}
// CRUD-type call because that's how the clients communicate (e.g. this part of the UI is not task-based
// but rather CRUD--a user is able to update a course name, description, and availalble venues in a single
// UI presentation/transaction)
public function updateCourse($courseId, array $data)
{
// $data could be a DTO but we are using native array for this instead
}
}
<?php
namespace Application\Catalog\Entity;
class Course
{
public function __construct($name, $description, $availableVenues)
{
// $availableVenues is a value object
}
public function changeAvailableVenues($availableVenues)
{
// See notes in __construct
// raises an event
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment