Is it appropriate for a class to only be a collection of information with no logic?
Posted
by
qegal
on Programmers
See other posts from Programmers
or by qegal
Published on 2012-12-10T04:18:24Z
Indexed on
2012/12/10
5:17 UTC
Read the original article
Hit count: 373
Say I have a class Person
that has instance variables age
, weight
, and height
, and another class Fruit
that has instance variables sugarContent
and texture
. The Person
class has no methods save setters and getters, while the Fruit
class has both setters and getters and logic methods like calculateSweetness
. Is the Fruit
class the type of class that is better practice than the Person
class. What I mean by this is that the Person
class seems like it doesn't have much purpose; it exists solely to organize data, while the Fruit
class organizes data and actually contains methods for logic.
© Programmers or respective owner