bugshaw: (Default)
Bridget ([personal profile] bugshaw) wrote2005-11-05 06:24 pm

Fun with Object Oriented Software Development

Typing up my student's lecture notes this evening (Java objects and classes), I found the following come out onto the page:

mum is an object of the Parent class; son is an object of the Child class.
The mum object sends a message “Pull up your socks” to the son object, who performs the pullUpSox() method. son’s socks are private to him – mum cannot access his socks directly.

Well, it made me laugh.

[identity profile] alexmc.livejournal.com 2005-11-05 07:09 pm (UTC)(link)
It is a really bad idea to have a class called "parent" or a class called child. It is a bit like changing your own name by deed poll to "What is your name"

I automatically assumed that the Child class was a child class of the Parent class whereas you didnt actually say that it was.

Oh, ok, it made me laugh too.

[identity profile] bugshaw.livejournal.com 2005-11-05 07:41 pm (UTC)(link)
I know - the Parent/Child thing confused me when I first looked back at my notes, especially as the first thing he'd talked about was a recap of object relationship types - aggregation and inheritance. Luckily, I was intelligent enough to divine his meaning and hope I have avoided ambiguity in the writeup.

I've just realised what my first LJ entry should have been -

"Hello, world"

[identity profile] bibliofile.livejournal.com 2005-11-06 10:24 am (UTC)(link)
son’s socks are private to him
That's when I laughed. Anyone who's been around younger kids knows that socks are quite public.

[identity profile] bugshaw.livejournal.com 2005-11-06 02:03 pm (UTC)(link)
That moment of absurdity was when I decided to record it in full.

The tutor went on to discuss the potential problem whereby if there were multiple parents and children, anyparent could tell any child to pull their socks up - and how we must implement the code carefully to ensure that parents cannot talk to other people's children like that!