-
Posted by Frankaladin on Tue, 17 Jun 2008 22:29:44
First let me say.. This is an excellent book and I highly recommend it. The following comments are to be taken with a huge grain of salt and the understanding that I want "World of Warcraft Programming - The Second Edition" to be even better.
Just a quick comment about the learning curve of the book. The first 50 pages of the book are very easy to follow, variables, strings, operators, and even the conditional controls are clearly explained and the examples are very good. Then we hit page 54... I read down to "Using : to Call Object Methods" and said.. huh? What's an object method? Is an Object Method a function stored in an object (in this case a table)?
The pargraph that follows says " When calling an object's method, you can use a colon instead of a period, and the object will be passed as the first argument to the method." Wow... I feel like I just went from elementary school to college without hitting highschool at all. I'm still re-reading chapter 4, hopefully a couple re-reads will make it clear...
object will be passed as the first argument to the method... ...
P.S. I also realize that this book isn't titled "Teach an old man to program" so if I'm just being dense please disregard.
--Frank
-
Posted by jnwhiteh on Mon, 16 Jun 2008 14:51:51
First let me say.. This is an excellent book and I highly recommend it. The following comments are to be taken with a huge grain of salt and the understanding that I want "World of Warcraft Programming - The Second Edition" to be even better.
Just a quick comment about the learning curve of the book. The first 50 pages of the book are very easy to follow, variables, strings, operators, and even the conditional controls are clearly explained and the examples are very good. Then we hit page 54... I read down to "Using : to Call Object Methods" and said.. huh? What's an object method? Is an Object Method a function stored in an object (in this case a table)?I agree, I could have given a bit more introduction to the way an object oriented program works, so I'll do what I can to post it here.
The pargraph that follows says " When calling an object's method, you can use a colon instead of a period, and the object will be passed as the first argument to the method." Wow... I feel like I just went from elementary school to college without hitting highschool at all. I'm still re-reading chapter 4, hopefully a couple re-reads will make it clear...
object will be passed as the first argument to the method... ...
P.S. I also realize that this book isn't titled "Teach an old man to program" so if I'm just being dense please disregard.
You should first do a bit of reading up on what object oriented programming is on wikipedia. Essentially, OO is a type of programming where everything is modeled as an object, and the actions of the program are a series of calls or changes to these objects. I don't really have an opportunity to give an example right now, but maybe someone else will be able to respond with more information.
The wikipedia page would certainly be a good place to start.
-
Posted by Tunga on Tue, 17 Jun 2008 13:41:21
The previous couple of pages give a brief idea of what Object Oriented programming is and how we can use in in Lua. The example I seem to remember it gives is of a counter. You define the counter once, think of this as a kind of template. Then you can create multiple instances of that same counter and they are seperate and maintain their own count. This is basically what OO design is about - you say "this is what an object will contain and do" and then you create instances of that object, as many as you need.
Then we hit page 54... I read down to "Using : to Call Object Methods" and said.. huh? What's an object method? Is an Object Method a function stored in an object (in this case a table)?
Yes, basically. "Method" is just another word for a function, some languages like Java always call them methods. It tends to get used more in OO languages but the two are really equivalent. I also found this wording to be somewhat out of place given that the term "method" is not used in any other part of the book.
The pargraph that follows says " When calling an object's method, you can use a colon instead of a period, and the object will be passed as the first argument to the method." Wow... I feel like I just went from elementary school to college without hitting highschool at all. I'm still re-reading chapter 4, hopefully a couple re-reads will make it clear...
object will be passed as the first argument to the method... ...
The example immediately after should make it clear. These are identical:
objectName.funcName(objectName, someVariable)
objectName:funcName(someVariable)The colon usage in the second example above is just a shortcut to save you time. All that happens is objectName is automatically passed as the first parameter without you having to specify it.
-
Posted by morlando on Tue, 17 Jun 2008 13:57:06
Yes, basically. "Method" is just another word for a function, some languages like Java always call them methods. It tends to get used more in OO languages but the two are really equivalent. I also found this wording to be somewhat out of place given that the term "method" is not used in any other part of the book.
For what it's worth, I'm sure we use "method" a lot in later parts of the book, especially dealing with widgets. I do wish we had both the room and the time to spare to go into more depth in the early parts of the book, but lines had to be drawn somewhere lest it turn into an entire course on computer science. ;) There's still a few things that are missing from the book, though we hope to fill those gaps with this site and any possible future editions.
Thanks for all the feedback!
-
Posted by Tunga on Tue, 17 Jun 2008 15:01:50
I'm only up to around chapter 18 at the moment so the "method" comment may not apply later on. It did jump out of nowehre for that one paragraph and the disappear again though. Overall the book is great and I'm learning a lot from it so good job :) .
-
Posted by Frankaladin on Tue, 17 Jun 2008 22:29:44
Yes, basically. "Method" is just another word for a function, some languages like Java always call them methods. It tends to get used more in OO languages but the two are really equivalent. I also found this wording to be somewhat out of place given that the term "method" is not used in any other part of the book.
The example immediately after should make it clear. These are identical:
objectName.funcName(objectName, someVariable)
objectName:funcName(someVariable)The colon usage in the second example above is just a shortcut to save you time. All that happens is objectName is automatically passed as the first parameter without you having to specify it.
Thank you Tunga. After reading your comments I am much clearer on the concept of method as it's used here.(re-reading chapter 4 probably helped too.. grin) I am enjoying the book greatly and look forward to writing my addon in the future.
I'd also like to thank jnwhiteh, morlando for the replies. All of your help is greatly appreciated.
--Frank