A Question about structure...

N

not telling

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?
 
G

Gianni Mariani

not said:
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?

No.
 
E

E. Robert Tisdale

not said:
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?

Take a look at
The C++ Scalar, Vector, Matrix and Tensor class Library (SVMTL)

http://www.netwood.net/~edwin/svmtl/

High Performance Embedded Computing Software Initiative (HPEC-SI)

http://www.hpec-si.org/

Object Oriented Numerics Web Page

http://www.oonumerics.org/
 
U

Uncle Bob (Robert C. Martin)

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 |
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top