3

I writing system following hexagonal architecture.

I have asynchronous commands and synch query objects split in UseCase.

My src folder look like:

-src
--Entity
---Task.php
--UseCase
---Command
----CreateTask
-----CreateTaskUseCase.php
-----CreateTaskCommand.php

My Question is: What i can/should use to send data via Command in constructor of UseCase\Command\CreateTask\CreateTaskCommand

  • \Entity\Task
  • create UseCase\Command\CreateTask\Request\Task that would have all needed data
  • only string/int/float

This is trivial example to show problem.

Right now i'm using object from Domain (Entiti\Task etc) In real situation, i have UseCase\Command\CreateProcess that need

  • Uuid
  • Instance[id, name]
  • Source[node_id, node_name, leaf_id, leaf_name]
  • Resource[id,name,type etc. normal types Person[name,lastname]]

By following DDD, Process is my aggregate. All entities exists only due construct Process(Node,Leaf,Resource,Person). Then i don't want separate way, to create the others entities, because that way works my business logic.

Due that problem, question is: what should i to choose? Breaking some rules?

Problems:

  • bind command with Object from inside Domain, will bind higher layer more to core. Any change in core, will chain react with all layers
  • Creating Request\* make me alot of classes, but clear way of use command, and much more work - unitTest etc.
  • Using only standard type(int,string etc.) will make __counstruct with 20 arguments. I don't want multilevel array, as will no be clear of use this command.

Thanks for help.

kayess
  • 3,384
  • 9
  • 28
  • 45
timiTao
  • 1,417
  • 3
  • 20
  • 34
  • 1
    Ddd is mainly about The journey and a structure that your business walks about. I doubt they talk about a usecase/process/task structure but more about a person doing things. Also look into valuetypes to.bundle arguments – Batavia Oct 13 '16 at 15:27
  • 1
    You are right, will remove DDD Tag :) – timiTao Oct 14 '16 at 10:36
  • Rolled back your edit because you have added the same text to your question as to your answer. – kayess May 16 '17 at 12:48
  • 1
    @kayess, i simply wanted to mark my question, as resolved :) Thank for edit. – timiTao May 16 '17 at 12:51

1 Answers1

1

After some time, and experience - Best option is to use standard data from PHP. Eventually, it is good to create objects for that Command (second option), but this will consume time to create classes and tests.

Never use something from domain - this is huge drawback in future.

timiTao
  • 1,417
  • 3
  • 20
  • 34