Timeline for Remove circular dependency
Current License: CC BY-SA 3.0
26 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 27, 2017 at 16:52 | comment | added | X.Otano | @DocBrown here all is done | |
Sep 27, 2017 at 16:52 | vote | accept | X.Otano | ||
Sep 27, 2017 at 16:52 | comment | added | X.Otano | @DocBrown see this new post softwareengineering.stackexchange.com/q/358140/283925 | |
Sep 27, 2017 at 16:50 | comment | added | Doc Brown | @Badulake: not sure what you mean by this comment exactly, but why don't you just follow the recommendation of my answer below? | |
Sep 27, 2017 at 8:38 | comment | added | X.Otano | @DocBrown is a problem if a do a Singleton with injected dependencies? (i pass them in the constructor of the singleton | |
Sep 25, 2017 at 12:01 | answer | added | Emerson Cardoso | timeline score: 0 | |
Sep 22, 2017 at 9:02 | comment | added | Doc Brown | @Christophe: the better approach is often not to use interfaces, but to refactor the code in a way it follows the SRP. See this older SE post for a bigger example. | |
Sep 22, 2017 at 8:40 | history | edited | X.Otano | CC BY-SA 3.0 |
Better code
|
Sep 22, 2017 at 8:36 | answer | added | Doc Brown | timeline score: 9 | |
Sep 22, 2017 at 7:11 | comment | added | Neil | Your DAO classes can indicate success/failure of the inserts/updates without knowing how the errors are handled. You would traditionally handle it through exceptions, but you could also return an object that describes the result of the call as well. | |
Sep 22, 2017 at 6:59 | review | Close votes | |||
Sep 27, 2017 at 3:01 | |||||
Sep 22, 2017 at 6:57 | comment | added | X.Otano | @Neil so your proposal is to remove the Audit calls from DAO classes, so it will respect Single Responsability Principle? My problem then, will be, how to Audit in the way I want, because it depends on the succes/failure of the INSERTS/UPDATES....How can I solve it? (delegates?) | |
Sep 22, 2017 at 6:53 | comment | added | Neil | @Badulake If Audit is not a database class, that's fine. Audit can depend on them, because Audit's role is to persist when an event occurs and so Audit can call on your DAO to persist items. The database classes persist because they are asked to do so and don't need to depend on other classes to do it for them. You'll need to rewrite them entirely with this mindset. Ideally your DAO classes don't require any non-DAO classes to work. | |
Sep 22, 2017 at 6:49 | comment | added | Christophe | This one? stackoverflow.com/a/35134687/3723423 | |
Sep 22, 2017 at 6:47 | comment | added | X.Otano | @Neil how can I refactor the classes so, Audit don't depend on Db classes (Entity) ? Audit needs to sotre them in Database in the AuditEvent method | |
Sep 22, 2017 at 6:45 | comment | added | X.Otano | Audit has similar functionality as a Logger, it should manage some actions, and persist somewhere( in this case helped by event class in the database) The problem is that Event class (and many others) have direct dependency with Audit | |
Sep 22, 2017 at 6:44 | comment | added | Neil | You're confusing Event/Audit/User database entities with other roles that the classes have. Make each class do exactly the CRUD operations for the database and nothing else to preserve single-responsibility status. If you want, those classes can also be responsible for associating its own instance with a child table (one-to-many relationship). Anything beyond this must be put in a separate class. | |
Sep 22, 2017 at 6:44 | comment | added | X.Otano | @Christophe I surfed stackoverflow but I have not found the answer | |
Sep 22, 2017 at 6:43 | comment | added | X.Otano | Event is an action that ocurrs and should be persisted to database | |
Sep 22, 2017 at 6:41 | comment | added | Christophe | I think this programming question belongs to StackOverflow. By the way there are already plenty of answers there for similar issues | |
Sep 22, 2017 at 6:27 | comment | added | Euphoric |
@DocBrown No. They are so bad that extra emphasis is needed. And I believe Event here is domain concept.
|
|
Sep 22, 2017 at 6:24 | comment | added | Doc Brown | Badulake, can you explain what you mean by the term "event" here? Do you use it in a purely technical sense, as in "event driven system", or in a domain sense, like an occasion or a meeting? (I am trying to understand what the responsibility of the Event class might or should be). | |
Sep 22, 2017 at 6:19 | comment | added | Doc Brown | @Euphoric: usage of singletons is as bad as writing sentences in capital letters ;-) | |
Sep 22, 2017 at 6:17 | comment | added | Euphoric | DO. NOT. USE. SINGLETONS! | |
Sep 22, 2017 at 6:17 | review | First posts | |||
Sep 25, 2017 at 19:52 | |||||
Sep 22, 2017 at 6:15 | history | asked | X.Otano | CC BY-SA 3.0 |