Skip to content

2023‐08‐23 SOLID

abenevaut edited this page Aug 7, 2024 · 2 revisions

Le problème

La bonne pratique

  • S. Single responsability principle (SRP)

two definitions:

The definition that something should only have a "single responsibility" is vague, because in that case you can always argue that something has only one responsibility. Yeah sure a repository only mediates between your application and the database. But one level deeper it is responsible for read, write, update, delete...

the definition of Robert C. Martin, which states that SRP means: "There is only one reason to change." This is in my opinion more precise. The repository can change if the write/update changes (auditing), if the read changes (caching) or if the delete changes (challenge before actual delete) and so on.

Repository https://stackoverflow.com/questions/28102970/does-repository-pattern-follow-solid-principles

  • I. Interface Segregation Principle ou ISP

L'explication technique