How do you follow the single responsibility principle in classes responsible for behaviour?
I have many classes in my application responsible for behaviour- views, controllers, models, network- often the state of one class or system depends on another and I’m finding that classes that are primarily responsible for the behaviour for one system inevitably become dependees or dependers of other systems or classes. I’ve tried passing in interfaces of dependencies from the constructor of the system all the way to the class the depends on it and registering for events on it but this gets extremely complex and crazy and definitely violates OCP and SRP at least.
What are the practical ways to implement the SRP?
Simply what are the practical techniques people use to check if a class violates the single responsibility principle?
Does multiple inheritance violate Single Responsibility Principle?
If you have a class which inherits from two distinct classes, does not this mean that your subclass automatically does (at least) 2 things, one from each superclass?
Is there an “ask for only what you need” interface principle?
I have grown into using a principle for designing and consuming interfaces that says basically, “ask for only what you need.”
Low Coupling: Single Responsibility Principle vs Cohesion
I’ve read several articles on SRP and cohesion, and they seem to contradict each other as far as low coupling is concerned.
Questions about identifying the components in MVC
I’m currently developing an client-server application in node.js, Express, mustache and MySQL. However, I believe this question should be mostly language and framework agnostic.
How do I prove or disprove “God objects” are wrong?
Problem Summary:
Architecture Best Practice (MVC): Repository Returns Object & Object Member Accessed Directly or Repository Returns Object Member
Architecturally speaking, which is the preferable approach (and why)?
Design patterns to avoiding breaking the SRP while performing heavy data logging
A class that performs both computations and data logging* seems to have at least two responsibilities. Given a system for which the specifications require heavy data logging, what kind of design patterns or architectural patterns can be used to avoid bloating all the classes with logging calls every time they compute something?
How do I design a DAL when I have to deal with relationships?
Say I’m developing a bug tracker, where a ticket belongs to at most one milestone, and a milestone can have many tickets. When a milestone is deleted (from the database), all tickets associated with that milestone must have their relationship unset (i.e. set to null
). This is a simple relationship.