srp - Disadvantage of Single Responsibility Principle -



srp - Disadvantage of Single Responsibility Principle -

i have read several books , hear lecture regarding software design. don't know how resolve problems caused next oo design priciples.

here situation. start design simple single class (classa). after that, classa grows similar responsibilities. according single responsibility priciple, extract logic classa classb. classa becomes simple plenty again. however, responsibility of classa maybe similar responsibility of classb, classa , classb have references each other fellow member fields or properties cooperate. in other words, seperation of classes create complexity. interaction between seperated classes. fromafter, each of classa , classb may grows more complex responsibilites, , classes(classc or classd) may seperated classa or classb. now, interactions between classes become much more complex. each of classes may have references other classes memeber fields or method parameters.

as single class become simpler, number of classes increase, complexity of relationship , interaction between classes increase.

in fortunate case, solved design patterns. in many case, however, seperation of classes create relationship of classes more complex. , create tendency generate classes having many references other classes members. class having many references other classes members hard test.

i have read several oo design books. of them talk simple class good. none of them, however, focus on complexity of classes interaction caused srp.

do miss something? how can resolve problem?

the responsibility means 1 reason change.

you may need alter class due 1 reason, , accidentally alter behavior of responsibility in class a. sometime need 1 of functionality of class utilize or test, need create whole class a.

if don't separate class class a, b, c, , d, interactions between responsibilities still exist hidden in class a.

to create classes more coherent , interactions more explicit allow code more maintainable.

srp

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -