Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7835733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:46:30+00:00 2026-06-02T13:46:30+00:00

I have a generic Vector<T> class and a generic Matrix<T> class and I was

  • 0

I have a generic Vector<T> class and a generic Matrix<T> class and I was wondering if it would be a good idea to have both classes implement an interface.

Basically, I’m implementing two algorithms: AlgorithmA and AlgorithmB, both of which perform very similar operations (reset, average…etc) but with different algorithms and act on different structures:
AlgorithmA uses Vector<double> while AlgorithmB uses Matrix<Complex>.

The design I have so far:

abstract class AlgorithmArray
{
   // Operator overloading
}

class AlgorithmAArray : AlgorithmArray
{
    private Vector<double> _vector;

    // Overrides
}

class  AlgorithmBArray : AlgorithmArray
{
     private Matrix<Complex> _matrix;

     // Overrides
}

I would prefer to have AlgorithmAArray derive from Vector<T> and also implement an interface ‘IAlgorithmArray‘ (instead of the abstract class). Anyway, these algorithms are then used to simulate transmission/receiving between two locations:

public class CommunicationParameters
{
         private AlgorithmArray _transmission;
         private AlgorithmArray _receiving;

         public void Compute()
        {
            if(_transmission != null)
                 _transmission.Compute();

            if(_receiving != null)         
                 _receiving.Compute()

        }
}

Are there better ways to approach my problem ?

Note: The base class AlgorithmArray duplicates many of the operator/cloning…etc methods and I feel this could be avoided, perhaps using generics ?

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:46:35+00:00Added an answer on June 2, 2026 at 1:46 pm

    I would suggest making two Algorithm classes that can take any data structure as a parameter and do their thing. I don’t see a need for all this OOP inheritance, it just adds complexity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic interface IConstrained which is implemented by the generic Constrained class.
I have a class called SpriteX which basically is a generic sprite. I also
I would like to create a generic vector class and create specializations for a
I'd like a generic method for retrieving the data from a vector. I have
I have generic type that looks like: public class GenericClass<T, U> where T :
I want to write in Delphi (2009 - so I have generic dictionary class)
Is there any name for the following DB table design: Basically we have generic
I have a generic class that needs to limit an enum depending on the
I have a templated class Vector<class T, int N> Where T is the type
I have defined a generic tree-node class like this: template<class DataType> class GenericNode {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.