I’ve been thinking about this question for days, and have yet to come up
with a satisfactory answer. I have deep respect for the “smarts”
available on this list, so I’ll toos the question out here. I’ve been
programming in Ruby for possibly a couple of years, learning what I need
to know to get something done, at the time I need to know it. I don’t
have much time for pure Ruby-study, although I much wish I did. I’m
presently writing database program in ruby, using only ruby (no database
engine), which will manage a network of nodes (labels) and relationships
(also labels). It’s simple, but potentially very powerful, and a great
opportunity for me to push into new territory with Ruby. It’s coming
along well, and I’m much enjoying the experience.
I’m getting it done by writing a number of methods. I keep looking at
other people’s programming, and I see many, many classes. Some of these
classes look pointless to me. A mere method would have done the trick.
Why a “class”? I personally feel no need whatsoever to actually USE one.
I’m getting everything done easily and artfully with mere methods. I
simply don’t get it - about classes. It looks like an elegant idea, and
in more complex programming I can imagine why one might use them,
but…I’ve simply cannot find a reason to bother.
I’ve read a lot about them, but…here’s my question:
Am I missing something? Can anyone give me a compelling reason to write
fewer methods and more classes?
If anyone’s interested, the program to which I referred may be examined
(I had to change the file extension to txt, as ‘rb’ refused to load in
my browser, and might well do that in yours as well.)
As I’ve puzzled about this for days, I’m very interested to see what
better informed people have to say about this question. Please
understand that I do grasp the basics, but do NOT see what the
compelling reason is to use a class in a reasonably simple program.