# Proper use of classes

**URL:** <https://rubytalk.org/t/proper-use-of-classes/51414>\
**Category:** ruby-talk\
**Created:** [29 January 2009 00:33 UTC](https://rubytalk.org/t/proper-use-of-classes/51414 "2009-01-29T00:33:30Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![Matt\_Lawrence1](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@Matt\_Lawrence1](https://rubytalk.org/u/Matt_Lawrence1)\
**Post date:** [2 February 2009 21:11 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/21 "2009-02-02T21:11:32Z")

</div>

English does not borrow from other languages. English follows other languages into dark alleys, knocks them over, and rifles through their pockets for loose vocabulary.

-- Matt  
It's not what I know that counts.  
It's what I can remember in time to use.

> **···**
>
> On Mon, 2 Feb 2009, Eleanor McHugh wrote:
> 
> > I like to think of Ruby as being the English of programming languages. It's got a large and flexible vocabulary that makes it very powerful to work with, but unlike Perl or Lisp or C it's also a very easy language to get to grips with.

---

<div class="post-metadata">

**Author:** ![Tom\_Cloyd2](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tom\_Cloyd2](https://rubytalk.org/u/Tom_Cloyd2)\
**Post date:** [31 January 2009 21:16 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/22 "2009-01-31T21:16:56Z")

</div>

Robert Klemme wrote:

> > BTW, I was puzzled for years by the mathematical notion of a function. It just eluded me. Baffled me. Then, as I was learning to program in Fortran, years ago, I began to wonder if there was any relation between Fortran functions (hope you know a little Fortran) and mathematical functions. Of course, there is. Fortran functions was no problem at all to grasp, and once I realized they were just another way of expressing a mathematical function (or perhaps I should say that a math function can be expressed as a Fortran function, and in fact that was what they were for), I was seriously rageful.
> 
> IMHO there is an important distinction though which makes Fortran functions a bad example: mathematical functions usually do not have side effects, i.e. they can be completely described in terms of input and output. I view them as a relationship (or call it a mapping) which assigns particular output values to particular input values. If I'm not mistaken, a Fortran function can have side effects on arguments (and probably global variables). A closer analogy are functions in - you guessed it - functional languages.
> 
> Kind regards
> 
> &nbsp;&nbsp;&nbsp;&nbsp;robert

Robert - I absolutely agree, and I can to that (or THOSE) understanding(s) in my first pass through grad. school. The idea of a function being a rule that associates two sets of numbers seems to me the most useful. However, the initial breakthrough for me was to see a function as a little program - a process: put something in, get something out. So easy. For some reason, that view it escaped me throughout high school, etc. (I was a writer, not a calculator!).

Thanks for your thoughts, as always. I always enjoy what you have to say!

Tom

> **···**
>
> > On 31.01.2009 10:02, Tom Cloyd wrote:
> 
> --
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist  
> Bellingham, Washington, U.S.A: (360) 920-1226  
> \<\< tc@tomcloyd.com \>\> (email)  
> \<\< TomCloyd.com \>\> (website) \<\< sleightmind.wordpress.com \>\> (mental health weblog)  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---

<div class="post-metadata">

**Author:** ![Tom\_Cloyd2](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tom\_Cloyd2](https://rubytalk.org/u/Tom_Cloyd2)\
**Post date:** [31 January 2009 21:18 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/23 "2009-01-31T21:18:05Z")

</div>

Pascal J. Bourguignon wrote:

> Tom Cloyd \<tomcloyd@comcast.net\> writes:  
> &nbsp;&nbsp;
> 
> > [...] My problem was simply that as I was trying to introduce classes into my project code, I didn't know when I really SHOULD create a class. I had gotten the impression somewhere that major methods should virtually always be reconceptualized as classes. I didn't arrive at that notion by thinking. I'd given up on that, as I didn't have enough material to work with.
> > 
> > But, that perception didn't really make a lot of sense. Still, I couldn't find any explicit guidance anywhere regarding the fundamental question I kept asking: WHEN is it the thing to do to make a class? I did find those two sentences in Thomas (3rd ed) - but that's sparse pickins, and I didn't find them until AFTER my weekend disaster in which I spend a pile of time converting a complex method into a class, getting completely exasperated with the experience, and converting it back. So, I wasn't overthinking at all. I was mis-perceiving, in the presence of an absence (ha!) - an absence of clear guidance about the WHEN-do-classes issue. The best sense I could make of things was that "big stuff oughta be classes" (bad idea). I didn't yet "get it" (understatement).  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > First you write a problem statement.  
> > Then you identify the important words in it.  
> > Nouns will become classes.  
> > Verbs will become methods.  
> > (approximatively).
> 
> The idea is that what has nouns in natural language are the objects  
> that have some stability in the real world, and what has verbs are the  
> actions.
> 
> Of course, you can have reification of the actions or the  
> associations, when you start to speak about verbs (notice that "verb"  
> is a noun, not a verb).
> 
> &nbsp;&nbsp;&nbsp;&nbsp;For example, when you write:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;(def m(x)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2 \* x)  
> &nbsp;&nbsp;&nbsp;&nbsp;end)
> 
> &nbsp;&nbsp;&nbsp;&nbsp;you actually instantiate an object of the class Method:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;(Object . method "m") --\> #\<Method: Class(Object)#m\>
> 
> &nbsp;&nbsp;&nbsp;&nbsp;but you do that only when you're talking at a meta-level, here it's  
> &nbsp;&nbsp;&nbsp;&nbsp;the level of the Ruby language, not that of your problem domain.
> 
> Instead of reifying the "big stuff", you should rather try to reify  
> the \_stable\_ stuff. A Person is something that is table, from her  
> birth to her death. On the other hand, eating, sleeping, working,  
> reproducing, breathing, are temporary actions. There even are actions  
> that cannot be done during all the life time. For example, a baby  
> Person has no walk method. This method is programmed during the first  
> few years.
> 
> Objects encapsulate state and methods.
> 
> When your problem domain (cf the problem statement) considers a Person  
> only in her relations with the surrounding world, then the methods of  
> a Person will be Ruby methods. You won't need to reify these methods.
> 
> On the other hand, if your problem statement is to implement a Person  
> simulator, then it's possible that the methods of a Person need to be  
> reifed, so you can add, change and remove these methods. Imagine  
> having to write a Person simulator that starts in the baby state, and  
> that should evolve a walk method. In this case, you could have a  
> MotorMethod class, and a Walk subclass, as well as classes such as  
> Muscle, Bone, Nerve, etc. But these kind of classes would be named in  
> the problem statement (at least latently, sometimes problem statements  
> are brief).

Pascal,

This is a simply lovely exposition. I'll add it to the other in this very helpful thread. And, I'm returning to my code, with these thoughts in mind, to see what I can learn.

Thanks for taking the time to make these things so clear. Much appreciated.

Tom

> **···**
>
> --
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist  
> Bellingham, Washington, U.S.A: (360) 920-1226  
> \<\< tc@tomcloyd.com \>\> (email)  
> \<\< TomCloyd.com \>\> (website) \<\< sleightmind.wordpress.com \>\> (mental health weblog)  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---

<div class="post-metadata">

**Author:** ![Juan\_Zanos](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@Juan\_Zanos](https://rubytalk.org/u/Juan_Zanos)\
**Post date:** [2 February 2009 22:36 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/24 "2009-02-02T22:36:31Z")

</div>

English, unlike other languages, is very consistent and straightforward. For example, the plural of boot is boots and the plural of foot is foots. Ok. Maybe I need a better example.

1100

> **···**
>
> On 2 févr. 09, at 16:11, Matt Lawrence wrote:
> 
> > On Mon, 2 Feb 2009, Eleanor McHugh wrote:
> > 
> > > I like to think of Ruby as being the English of programming languages. It's got a large and flexible vocabulary that makes it very powerful to work with, but unlike Perl or Lisp or C it's also a very easy language to get to grips with.
> > 
> > English does not borrow from other languages. English follows other languages into dark alleys, knocks them over, and rifles through their pockets for loose vocabulary.
> > 
> > -- Matt  
> > It's not what I know that counts.  
> > It's what I can remember in time to use.

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [3 February 2009 01:00 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/25 "2009-02-03T01:00:50Z")

</div>

Actually, I'd say quite the opposite, English vocabulary is the result of a  
long history of the English language being raped by the Languages of  
whatever happened to be the latest invaders. Those words were injected into  
the language rather than being pick-pocketed.

> **···**
>
> On Mon, Feb 2, 2009 at 4:11 PM, Matt Lawrence \<matt@technoronin.com\> wrote:
> 
> > I like to think of Ruby as being the English of programming languages. It's
> > 
> > > got a large and flexible vocabulary that makes it very powerful to work  
> > > with, but unlike Perl or Lisp or C it's also a very easy language to get to  
> > > grips with.
> > 
> > English does not borrow from other languages. English follows other  
> > languages into dark alleys, knocks them over, and rifles through their  
> > pockets for loose vocabulary.
> 
> --  
> Rick DeNatale
> 
> Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
> Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)

---

<div class="post-metadata">

**Author:** ![Gary\_Wright](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@Gary\_Wright](https://rubytalk.org/u/Gary_Wright)\
**Post date:** [3 February 2009 01:08 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/26 "2009-02-03T01:08:58Z")

</div>

I'd say that English is more like the Borg. Resistance is futile. You will be assimilated.

Gary Wright

> **···**
>
> On Feb 2, 2009, at 8:00 PM, Rick DeNatale wrote:
> 
> > Actually, I'd say quite the opposite, English vocabulary is the result of a  
> > long history of the English language being raped by the Languages of  
> > whatever happened to be the latest invaders. Those words were injected into  
> > the language rather than being pick-pocketed.

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [3 February 2009 03:34 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/27 "2009-02-03T03:34:49Z")

</div>

Juan Zanos wrote:

> > English does not borrow from other languages. English follows other languages into dark alleys, knocks them over, and rifles through their pockets for loose vocabulary.
> 
> English, unlike other languages, is very consistent and straightforward. For example, the plural of boot is boots and the plural of foot is foots. Ok. Maybe I need a better example.

"Okay" is a real word. "OK" is an historical bacronym. (The published  
dictionaries have this one wrong.) Okay means "emphatic yes" in Wolof, one of  
the languages English... knocked over. "Banana" and "hippie" come from the same  
source...

---

<div class="post-metadata">

**Author:** ![Tom\_Cloyd2](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tom\_Cloyd2](https://rubytalk.org/u/Tom_Cloyd2)\
**Post date:** [4 February 2009 06:57 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/28 "2009-02-04T06:57:55Z")

</div>

Juan Zanos wrote:

> **···**
>
> > On 2 févr. 09, at 16:11, Matt Lawrence wrote:
> > 
> > > On Mon, 2 Feb 2009, Eleanor McHugh wrote:
> > > 
> > > > I like to think of Ruby as being the English of programming languages. It's got a large and flexible vocabulary that makes it very powerful to work with, but unlike Perl or Lisp or C it's also a very easy language to get to grips with.
> > > 
> > > English does not borrow from other languages. English follows other languages into dark alleys, knocks them over, and rifles through their pockets for loose vocabulary.
> > > 
> > > -- Matt  
> > > It's not what I know that counts.  
> > > It's what I can remember in time to use.
> > 
> > English, unlike other languages, is very consistent and straightforward. For example, the plural of boot is boots and the plural of foot is foots. Ok. Maybe I need a better example.
> > 
> > 1100
> 
> I propose that we allow 'foots'. to be a subclass of foot - for those of us who secretly wish English had the lucidity of Spanish, or, if we dare to dream, Ruby....
> 
> t.
> 
> --
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist  
> Bellingham, Washington, U.S.A: (360) 920-1226  
> \<\< tc@tomcloyd.com \>\> (email)  
> \<\< TomCloyd.com \>\> (website) \<\< sleightmind.wordpress.com \>\> (mental health weblog)  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---

<div class="post-metadata">

**Author:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://rubytalk.org/u/Julian_Leviston)\
**Post date:** [3 February 2009 03:48 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/29 "2009-02-03T03:48:02Z")

</div>

Why does this matter?

> **···**
>
> Sent from my iPhone
> 
> On 03/02/2009, at 2:34 PM, Phlip \<phlip2005@gmail.com\> wrote:
> 
> > Juan Zanos wrote:
> > 
> > > > English does not borrow from other languages. English follows other languages into dark alleys, knocks them over, and rifles through their pockets for loose vocabulary.
> > > 
> > > English, unlike other languages, is very consistent and straightforward. For example, the plural of boot is boots and the plural of foot is foots. Ok. Maybe I need a better example.
> > 
> > "Okay" is a real word. "OK" is an historical bacronym. (The published  
> > dictionaries have this one wrong.) Okay means "emphatic yes" in Wolof, one of  
> > the languages English... knocked over. "Banana" and "hippie" come from the same  
> > source...

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [3 February 2009 04:04 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/30 "2009-02-03T04:04:53Z")

</div>

Julian Leviston wrote:

> Why does this matter?

> > > Ok. Maybe I need a better example.

> > "Okay" is a real word.

Following up on a joke - someone needed a better example. (-:

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [3 February 2009 17:47 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/31 "2009-02-03T17:47:01Z")

</div>

Julian Leviston wrote:

> Why does this matter?
> 
> Sent from my iPhone

Ah, the irony.

> **···**
>
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [3 February 2009 18:09 UTC](https://rubytalk.org/t/proper-use-of-classes/51414/32 "2009-02-03T18:09:43Z")

</div>

Joel VanderWerf wrote:

> Julian Leviston wrote:
> 
> > Why does this matter?
> > 
> > Sent from my iPhone
> 
> Ah, the iRony.

I fixed it for you!

[Previous page](https://rubytalk.org/t/proper-use-of-classes/51414.md?page=1)
