Last active
December 15, 2015 07:59
-
-
Save raykolbe/5227403 to your computer and use it in GitHub Desktop.
CRUD in Application Service -- Is it a smell? #dddesign
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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