Hello fellow Rybuists,
One thing I like about C++'s OO is the way in which all class & instance
variables are conveniently “declared” in respective public and private
sections. This makes the code easier to understand, since the
declaration is a good place to comment on the variable, explaining how
it is used.
Ruby has several options regarding this, but nothing of a concensus, it
seems. Public members can be declared with ‘attr’ and friends. But what
about private memberes. For now I find it convenient to preallocate
those in ‘initialize’. What are the approaches you use ?
My aim is to enhance the readability of my class. It won’t affect its
usage, just its comprehension when I return in the future trying to grok
how it works.