Relative Content

Tag Archive for single-responsibility

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.

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.