Proper use of classes

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.

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

    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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pascal J. Bourguignon wrote:

Tom Cloyd <tomcloyd@comcast.net> writes:
  

[...] 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).
    
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).

    For example, when you write:

    (def m(x)
      (2 * x)
    end)

    you actually instantiate an object of the class Method:

    (Object . method "m") --> #<Method: Class(Object)#m>

    but you do that only when you're talking at a meta-level, here it's
    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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

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/
Twitter: http://twitter.com/RickDeNatale

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.

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...

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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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...

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. (-:

Julian Leviston wrote:

Why does this matter?

Sent from my iPhone

Ah, the irony.

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Joel VanderWerf wrote:

Julian Leviston wrote:

Why does this matter?

Sent from my iPhone

Ah, the iRony.

I fixed it for you!