logo
Search:

Login:


Forgot Details? Sign-up

forum >> Programming questions >> HTML / XHTML / HTML5 / CSS

Building Objects ( Pg 414) I'm struggling a bit with #5 Changing Values and Properties.

Posted Apr 02 2012 at 10:00 AM by
Pete Woodhead (petewdhd)
Quote:
5. Use the dot syntax to view or change a property.

If the critter object has a name property, you can use critter.name as a variable. Like other variables, you can change the value by assigning a new value to city.name or you can read the content of the property.

Harris, Andy (2010-10-28). HTML, XHTML and CSS All-In-One For Dummies (p. 414). For Dummies. Kindle Edition.

Andy I'm hoping you can clarify this for me. When you switched from critter.name to city.name you kind of lost me. If my understanding is correct critter.name refers to the object critter as having a variable / property which is [i}name[/i]. So if that is correct then where does city.name come in?

This is the kind of silly stuff I keep tripping over. As I mentioned before I've been struggling to relate to all of these "new-to-me" associations (Objects, Properties, Values, Methods, etc.). Something in my dyslexic brain is really making me work for this stuff.

Thanks,
Pete
AuthorMessage
Andy
Posted: Apr 04 2012 kl. 10:20 PM

OK. Gold star for you. You found a typo that nobody else has ever pointed out to me.

It should be critter.name in both places in that section (bullet point 5 midway through page 414.)

I'm very sorry to confuse you. There is enough terminology, and then I throw in something that really makes no sense. My bad.

The crazy thing about OOP is you have new words for things that aren't really new. Variables become properties and functions become methods. But they don't substantially change, except they now have new names because they belong to an object.

Thanks for the catch, and sorry again about any confusion it may have caused.
Pete Woodhead
Posted: Apr 06 2012 kl. 9:30 PM

I half suspected it might be, but you also had examples of cities and distances in the same chapter. It certainly makes more sense as critter.name.

I have some genuine empathy on this. I've been faithfully rewriting every example myself, and really as much through my own typos is all of this new stuff starting to gel in my head. Thank god for all of the examples you've furnished on your website which I am able to refer to when ever the code I copy does not work.

It's always something small, but between your example scripts, Komodo's file compare, Web Developer, Firebug and the other tricks you've passed on in your book, I always manage to patiently find my silly error/s. Usually it involves a misspelled word or a Cap or lowercase in the wrong place; but finding those hidden errors really makes me take the code apart which is helpful in itself.

Regards,
Pete