Question about planning domain design

I am new to DDD. I have a PROFILE class and a REPONITORY PROFILE class. The PROFILE class contains the following fields:> Id, Description, ImageFilePath

Therefore, when I add a new profile, I upload the image to the server and save the path to it in my db.

When I delete a profile, the image must also be deleted from my file system.

My question is:

Where to add logic for this. My profile repository has a Delete method. Should I add this logic here. Or should I add a service to encapsulate both actions.

Any comments would be appreciated ...

thanks

+3
source share
3

"", . "" "" . , . ( ) .

, , . , ( ), . , , .

, . . , , , - . .

, , . , . , , .

, . , . ( , ). , . ( ), . , "ImageRepository" "ImageServices", , . ImageServices Delete(), Find(), . find FindBy...() (, FindByKey(), FindByName() ..).

, , , . - ( , , ). . "ImageManagementService". ( , ) . "DeleteImageFile()".

- , . "ImageManagementService". "RemoveImage". :

  • ( ).
  • , ( ).
  • , ( , ).

, , RemoveImage() "ImageManagementService". "RemoveImage()" "FindBy..()" "ImageServices", . DeleteImageFile() "ImageManagementService". "Delete()" "ImageService", .

, , , ( ), , , . . , SOC, DDD, " Onion Architecture".

, . , , . , , , . , . , . , ! , . . , . , , .

, . , , .

+2

@joseph.ferris: " , , ".

, . .

( ) , , NDepend, .

+1

, , ImageRepository. , , "" "" , , " , " adagio.

When at a later stage of the project you feel that this solution is not very good, and you feel that you need a more complex (and possibly cleaner) solution similar to the joseph.ferris proposal, then you can always refactor it.

It’s easier to reorganize a simple solution and then reorganize a complex solution. :)

0
source

Source: https://habr.com/ru/post/1718013/


All Articles