Igor Gaelzer

Joined

110 Experience
1 Lesson Completed
0 Questions Solved

Activity

Posted in Single Responsibility Principle Discussion

Interesting. I'm having trouble knowing how small to make my classes. I've seen different articles saying you should only have one public method per class.

Should I create one PriceCalculator service where I can ask it for things like sale_price, material_cost, fixed cost, variable_cost, production_cost...

Or should I make independant classes for each of these? That way sale_price would be one calling the other classes to get to the final price.

My biggest concern separating them all into classes is that material_cost, for example, is is called in different classes, repeting calculations that I have already done.

Under one big SalePrice class, I avoided calculating the same thing multiple times because I would set class variables that would be accessible by all methods.