not telling <no**@nottelling.com> might (or might not) have written

this on (or about) Wed, 13 Aug 2003 14:56:22 -0600, :

I have a vector class and a matrix class.

The matrix class uses the vector class to implement a matrix.

Within the vector class there is a polynomial curve fit method.

The curve fit method uses matrices to implement perform the curve fit.

Does the fact that the vector class uses the matrix class violate a design

rule?

Why does vector need a curve fit method? Do you really want everyone

who uses vector to have to import the curve-fitting code? This is a

violation of the Single Responsibility Principle (SRP) which states

that a class should have one, and only one, reason to change. By

associating curve fitting with vector, you force vector to change when

new curve fitting algorithms are needed. All users of vector, whether

they use the curve fitting or not, must then update their builds.

Robert C. Martin | "Uncle Bob"

Object Mentor Inc.| unclebob @ objectmentor . com

PO Box 5757 | Tel: (800) 338-6716

565 Lakeview Pkwy | Fax: (847) 573-1658 |

www.objectmentor.com
Suite 135 | |

www.XProgramming.com
Vernon Hills, IL, | Training and Mentoring |

www.junit.org
60061 | OO, XP, Java, C++, Python |