Timeline for Is "composition over inheritance" violating "dry principle"?
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 27, 2018 at 9:31 | vote | accept | ocomfd | ||
| Feb 21, 2018 at 3:41 | vote | accept | ocomfd | ||
| Feb 27, 2018 at 9:31 | |||||
| Feb 17, 2018 at 3:36 | history | tweeted | twitter.com/StackSoftEng/status/964705171778539520 | ||
| S Feb 14, 2018 at 4:59 | history | suggested | Allan Pereira | CC BY-SA 3.0 | Improved Formatting |
| Feb 13, 2018 at 23:18 | comment | added | Patrick Roberts | Wouldn't LoginPage make more sense as an interface than a class? | |
| Feb 13, 2018 at 21:32 | review | Suggested edits | |||
| S Feb 14, 2018 at 4:59 | |||||
| Feb 13, 2018 at 12:34 | comment | added | Polygnome | So, make your page being able to be decorated and make your LoginPage a decorator. No more duplication, just a simple page = new LoginPage(new EditInfoPage()) and you are done. Or you use the open-closed-principle to make the authentication module that can be added to any page dynamically. There a lots of ways to deal with code duplication, mainly involving finding a new abstraction.LoginPage is likely a bad name, what you want to make sure is that the user is authenticated while browsing that page, while being redirected to the LoginPage or shown a proper error message if he is not. | |
| Feb 13, 2018 at 6:31 | comment | added | Brian McCutchon | If you have the problem in the last snippet a lot, you might be overusing getters and setters. They tend to violate encapsulation. | |
| Feb 12, 2018 at 22:21 | comment | added | Stack Exchange Broke The Law | But surely your home page also displays news and a signup screen? So you should write public class HomePage extends LoginPage extends SignupPage extends NewsPage. Oh wait, you can't. | |
| Feb 12, 2018 at 16:30 | comment | added | Robert Harvey | None of the code samples you've provided violate DRY. The whole point of DRY is to refactor duplicate code into methods and classes that you can use more than once. | |
| Feb 12, 2018 at 16:12 | comment | added | el.pescado - нет войне | But, with inheritance, you have duplicate extends LoginPage all over the place. CHECK MATE! | |
| Feb 12, 2018 at 9:40 | review | Close votes | |||
| Feb 17, 2018 at 3:04 | |||||
| Feb 12, 2018 at 8:20 | comment | added | Mr Cochese | Why would you want all your pages to be the login page? Maybe just have a login page. | |
| Feb 12, 2018 at 7:22 | answer | added | wasatz | timeline score: 129 | |
| Feb 12, 2018 at 6:30 | answer | added | Doc Brown | timeline score: 12 | |
| Feb 12, 2018 at 6:04 | answer | added | candied_orange | timeline score: 48 | |
| Feb 12, 2018 at 4:36 | comment | added | Erik Eidt | Sometimes you need neither inheritance nor composition, which is to say that sometimes one class with a few objects does the job. | |
| Feb 12, 2018 at 3:04 | history | asked | ocomfd | CC BY-SA 3.0 |