{ "uuid": [ { "value": "4c0b0072-4046-48aa-b481-84515c265ca0" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:10+00:00" } ], "revision_uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "revision_log": [], "status": [ { "value": true } ], "uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "title": [ { "value": "Do you separate your logic?" } ], "created": [ { "value": "2024-06-11T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:10+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2024\/06\/11\/do-you-separate-your-logic", "langcode": "en" } ], "body": [ { "value": "\n

I recently watched a video about separating logic<\/a> into different categories within your custom code.<\/p>\n\n

It wasn't a PHP video, but the concept applies to any programming language or framework.<\/p>\n\n

This was the final structure of the directories:<\/p>\n\n

src\/\n  Controllers\/\n  Domain\/\n  Persistence\/\n  Properties\/\n  Services\/\n<\/code><\/pre>\n\n

It was described as using Controllers<\/code> for presentational logic, Domain<\/code> for domain logic, and Services<\/code> for application logic, and reminds me of a domain-driven design (DDD) approach to organising code.<\/p>\n\n

I remember watching other older videos showing separating business and presentational logic in React into different components (if I remember correctly).<\/p>\n\n

This isn't an approach I see in Drupal code, maybe more-so in other PHP framework-based projects like Symfony or Laravel.<\/p>\n\n

It's something I've been thinking of trying, potentially on my website codebase.<\/p>\n\n

Do you organise your code in this or a similar way?<\/p>\n\n

If so, why?<\/p>\n\n

What advantages does it bring?<\/p>\n\n ", "format": "full_html", "processed": "\n

I recently watched a video about separating logic<\/a> into different categories within your custom code.<\/p>\n\n

It wasn't a PHP video, but the concept applies to any programming language or framework.<\/p>\n\n

This was the final structure of the directories:<\/p>\n\n

src\/\n  Controllers\/\n  Domain\/\n  Persistence\/\n  Properties\/\n  Services\/\n<\/code><\/pre>\n\n

It was described as using Controllers<\/code> for presentational logic, Domain<\/code> for domain logic, and Services<\/code> for application logic, and reminds me of a domain-driven design (DDD) approach to organising code.<\/p>\n\n

I remember watching other older videos showing separating business and presentational logic in React into different components (if I remember correctly).<\/p>\n\n

This isn't an approach I see in Drupal code, maybe more-so in other PHP framework-based projects like Symfony or Laravel.<\/p>\n\n

It's something I've been thinking of trying, potentially on my website codebase.<\/p>\n\n

Do you organise your code in this or a similar way?<\/p>\n\n

If so, why?<\/p>\n\n

What advantages does it bring?<\/p>\n\n ", "summary": null } ] }