Phlip said:
Designing a program means organizing the relations between its structure
in memory and their behavior in time.
OO design is about partitioning that behavior with polymorphism.
Not all classes exhibit polymorphism. How do the so-called concrete classes
fit into your model?
I am aware that the entry-level tutorials describe objects as data and the
functions that operate on them. You can also find tutorials that say "OO
objects are like real-world objects".
What I quoted from is a textbook used at ETH in Zrich. Perhaps you've heard
of the University? It's where Einstein got his degree in Physics.
Why?
It's the same question as before - what is an int's behavior? If it has
only a little, then it's a "value object", and unbeholden to any one
class.
I guess I'm confused about what you mean by shared data. Using set and get
methods is not typically considered sharing data. If I have a class called
Arrow which has different properties such as color, length, position,
rotation, etc., how am I supposed to manipulate objects of that class in
order to change these properties? Am I expected not to be interested in
the current value of these objects at runtime? If I am interested in
observing these values, then how am I expected to access them without 'get'
methods?
If I understand the opinion that I should not use set and get methods, it
means I should not have code such as that shown below. Is that what you
are trying to suggest?
class Light{
//...
virtual const array<GLfloat,4>& ambient() const {return _ambient; }
virtual void ambient(const array<GLfloat,4>& ambient_)
{
_ambient = ambient_;
}
virtual const array<GLfloat,4>& diffuse() const {return _diffuse; }
virtual void diffuse(const array<GLfloat,4>& diffuse_)
{
_diffuse = diffuse_;
}
virtual const array<GLfloat,4>& specular() const {return _specular; }
virtual void specular(const array<GLfloat,4>& specular_)
{
_specular = specular_;
}
virtual const array<GLfloat,4>& ambientModel() const
{
return _ambientModel;
}
virtual void ambientModel(const array<GLfloat,4>& ambientModel_)
{
_ambientModel = ambientModel_;
}
virtual GLenum light() const {return _light; }
virtual void light(GLenum light_)
{
_light = light_;
}
protected:
array<GLfloat,4> _position;
array<GLfloat,4> _ambient;
array<GLfloat,4> _diffuse;
array<GLfloat,4> _specular;
array<GLfloat,4> _ambientModel;
GLenum _light;
};
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell