Hacker News new | ask | show | jobs
by catnaroek 3677 days ago
Could you explain GoF's design patterns to your 11-year-old daughter? Reflection and metaprogramming? Heck, would she be able to understand why the concept of object identity matters for some types (say, any user-defined type in Java) but not others (say, integers)? Are you proposing that we ban those things too?
1 comments

Re: GoF. Interesting. And GoF got their ideas from the influential philosophical works by Christopher Alexander on architecture didn't they? (Which I haven't read, maybe I should. Christopher Alexander I mean, not GoF) So I could talk to her about patterns _in general_, but could I then make the leap to object-oriented patterns? I don't know. Tricky. I remember several light-bulb aha moments going off when I read that work. It'd be amazing to try to instil that type of wonder in her.

Re: Reflection and metaprogramming. I guess you're suggesting teaching her some variant of Lisp? In the Coder Dojo I brought her too they/we were doing either HTML/CSS/JS or Scratch or Python. And all simple examples. I guess a version of reflection and metaprogramming exist in Python (I don't know off the cuff (I'm a Rubyist) but I presume so).

I had to Google object identity. Is this [http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes...] what you mean?

> Re: Reflection and metaprogramming. I guess you're suggesting teaching her some variant of Lisp?

I wasn't talking about Lisp specifically. Many libraries and frameworks written in “mundane” languages like Python and Ruby make use of metaprogramming facilities to great effect. Now, you can't say with a straight face that monoids are scary but metaprogramming is not.

> I had to Google object identity.

In most object-oriented programming languages, every object has a unique identity, which is assigned when the object is constructed, and from then onwards can't be mutated. The uniqueness of these object identities can get in the way when you want to program with compound values, for example, the Java expression `new Point2D(2,3) == new Point2D(2,3)` evaluates to `false`, simply because the objects have different identities.

> Is this [http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes...] what you mean?

Yes.