A Question about structure...

Discussion in 'C++' started by not telling, Aug 13, 2003.

  1. not telling

    not telling Guest

    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?
    not telling, Aug 13, 2003
    #1
    1. Advertising

  2. not telling wrote:
    > 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.
    Gianni Mariani, Aug 13, 2003
    #2
    1. Advertising

  3. not telling wrote:

    > 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/
    E. Robert Tisdale, Aug 13, 2003
    #3
  4. not telling <> 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 |
    Uncle Bob (Robert C. Martin), Aug 15, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Excluded_Middle

    Pointers to structure and array of structure.

    Excluded_Middle, Oct 24, 2004, in forum: C Programming
    Replies:
    4
    Views:
    732
    Martin Ambuhl
    Oct 26, 2004
  2. Leo Nunez
    Replies:
    3
    Views:
    1,183
    Neil Kurzman
    Feb 9, 2005
  3. Replies:
    2
    Views:
    586
  4. Replies:
    9
    Views:
    25,224
    Lal Bahadur Singh
    Nov 11, 2011
  5. meisterbartsch
    Replies:
    2
    Views:
    760
    meisterbartsch
    Jun 12, 2007
Loading...

Share This Page