[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Requesting Suggestions for intermediate/advanced book on Lua
- From: Sean Conner <sean@...>
- Date: Thu, 3 Oct 2013 12:11:34 -0400
It was thus said that the Great Jay Glascoe once stated:
>
> I realize now I need the community to help me understand what kind of Lua
> book they could look at and recommend to a hacker friend. Perhaps together
> we can write the next Snakes on a
> Plane<http://en.wikipedia.org/wiki/Snakes_on_a_plane> :
> o)
I took a look at what you have and my initial reaction was "an OO example
using animals? Why?"
While I think OO is overused (personal preference), if you are going to
teach OO principles, then please, please, please, use a real world example
of OO and not some abstract nonsense version of it using shapes, vehicles or
animals. There are plenty of real-world examples of OO design. One I might
suggest (and this can be done as a simple example) are devices. Windows,
Linux, Mac OS-X, all have a hiearchy of devices. At the base you have a
base (virutal if you are using C++) class Device that supports two methods:
read()
write()
>From there, you have three major branches---block devices, which transfer
data in fixed size blocks, so it adds
seek()
total_size()
block_size()
character devices, which stream data and might add methods such as
get_speed()
set_speed()
ready_to_send()
data_available()
and the third branch is network (for lack of a better example), which can't
seek, you really can't set the speed, but does transfer data in blocks that
can vary in size, so you might get
max_block_size()
min_block_size()
ready_to_send()
data_available()
And finally, you get the classes that actually provide implementations, like
a IDE drive, or a SCSI drive, or a serial port, keyboard, ethernet card and
so on.
It's something tangable. It's based on a real-world example. And you
could show, for instance, that a serial port IS-A character device, but a
keyboard HAS-A serial port (to handle the actual IO).
But please, get away from the traditional OO examples of shapes, vehicles
and animals.
-spc