J
Jessica
Hi,
I have a question regarding the object-oriented issue. I understand
that a class is a type. I have an array class. Now say that I want
to implement an algorithm A that uses the array class. Does it make
sense to make a class for the algorithm such as
class MyAlg
{
private:
Array A1;
Array A2;
// more data members
public:
// my functions
};
Right now I have my algorithm as an interface to the Array class (i.e.
just a bunch of global functions). The problem is that it gets pretty
messy and unorganized since there are so many parameters associated
with the algorithm. Since I now added a GUI for my algorithm, I
thought that maybe if I wrap my algorithm in a class, the code will be
cleaner. So in short, my current design is 3-tiered:
GUI -> My algorithm as a set of global functions -> Array class
implementation
I want to make it into a 2-tier design:
GUI -> My algorithm as a class (with Array contained in this
class)
Can someone please tell me if this is the right way to do it? I am
puzzled because it doesn't sound semantically correct -- since the
algorithm is not really a TYPE, but rather a method. If I shouldn't
define a class for it, what are my alternatives? I just don't feel
that using a bunch of global functions is the way to go. Thanks a
lot!
Jessica
I have a question regarding the object-oriented issue. I understand
that a class is a type. I have an array class. Now say that I want
to implement an algorithm A that uses the array class. Does it make
sense to make a class for the algorithm such as
class MyAlg
{
private:
Array A1;
Array A2;
// more data members
public:
// my functions
};
Right now I have my algorithm as an interface to the Array class (i.e.
just a bunch of global functions). The problem is that it gets pretty
messy and unorganized since there are so many parameters associated
with the algorithm. Since I now added a GUI for my algorithm, I
thought that maybe if I wrap my algorithm in a class, the code will be
cleaner. So in short, my current design is 3-tiered:
GUI -> My algorithm as a set of global functions -> Array class
implementation
I want to make it into a 2-tier design:
GUI -> My algorithm as a class (with Array contained in this
class)
Can someone please tell me if this is the right way to do it? I am
puzzled because it doesn't sound semantically correct -- since the
algorithm is not really a TYPE, but rather a method. If I shouldn't
define a class for it, what are my alternatives? I just don't feel
that using a bunch of global functions is the way to go. Thanks a
lot!
Jessica