Re: Gigantic Class
Immortal Nephi <Immortal_Nephi@hotmail.com> writes:
However, many small specialized classes are preferred to a bulky
Such metrics look superficial to me. For example, when the
specialized classes are very similar to each other, they
should be combined into a slightly larger but more general
class (DRY). It always depends also on other factors then
just the size in isolation.
members. But bulky classes do get written. Class std::string has a
Yes, yes! Go ahead and write it! It is never a mistake to
write a huge bulky class. It is only a mistake to stop there
and not refactor it. Usually, /after/ the bulky class has been
written one sees oportunities to split it or to extract classes
from it, thus it gets smaller, usually. And in the 0,1 % of all
cases, when there is no reasonable refactor to make it smaller,
it really needs to be that big. Usually, ?god class? is an anti-
pattern, but under rare circumstances it might become a pattern.
A typical cell size is 10 ?m, but the ostrich egg cell is
15 centimetres (5.9 in) long, 13 centimetres (5.1 in) wide,
and weighs 1.4 kilograms (3.1 lb).
class? Inheritance is the answer, but you write derive class to use
This is just one answer. And also seen to be an anti-pattern by
some (as implementation inheritance - not interface inheritance).
You need to know several refactors and apply each of them when
appropriate. There are several refactors that will reduce the
size of a class.