S Single Responsability Principle O Open/Closed Principle L Liskov Substitution Principle I Interface Segregation Principle D Dependency Inversion Principle
SETUP - BLOGPOST CLASS class BlogPost implements BlogPostInterface { public function getTitle() { /* ... */ } public function getContent() { /* ... */ } public function getAuthor() { /* ... */ } public function getSlug() { /* ... */ } }
SETUP - BLOGPOST INTERFACE interface BlogPostInterface { public function getTitle(); public function getContent(); public function getAuthor(); public function getSlug(); }
UITBREIDING - BLOGPOSTINTERFACE interface BlogPostInterface { public function getTitle(); public function getContent(); public function getAuthor(); public function getSlug(); public function getSlugableContent(); }
UITBREIDING - AUTHOR CLASS class Author implements AuthorInterface { public function getFirstname() { /* ... */ } public function getLastname() { /* ... */ } public function getFullname() { /* ... */ } public function getSlug() { /* ... */ } public function getSlugableContent() { /* ... */ } }
UITBREIDING - AUTHOR INTERFACE interface AuthorInterface { public function getFirstname(); public function getLastname(); public function getFullname(); public function getSlug(); public function getSlugableContent(); }
OPLOSSING - BLOGPOST class BlogPost implements BlogPostInterface, Slugable { public function getTitle() { /* ... */ } public function getContent() { /* ... */ } public function getAuthor() { /* ... */ } public function getSlug() { /* ... */ } public function getSlugableContent() { /* ... */ } }
PROBLEEM! Welke Visual Debt constraint toevoegen? public function generateBlogUrl(BlogPostInterface $item) public function generateBlogUrl(Slugable $item)
OORZAAK class BlogPost implements BlogPostInterface, Slugable { public function getTitle() { /* ... */ } public function getContent() { /* ... */ } public function getAuthor() { /* ... */ } public function getSlug() { /* ... */ } public function getSlugableContent() { /* ... */ } }