As usual, pastebins are at the bottom ;-)
[2009/03/03 12:06] Snowdrop Short: have you had time to digest all
the stuff from last time?
[2009/03/03 12:06] Adelle Fitzgerald: ish
[2009/03/03 12:06] Starky Rubble: it was a pretty big meal lol
[2009/03/03 12:06] M1sha Dallin: yes - 'ish
[2009/03/03 12:06] Adelle Fitzgerald: im still tring to get to grips
with classes and objects
[2009/03/03 12:07] Snowdrop Short: yes.. that's the biggie
[2009/03/03 12:07] M1sha Dallin: It helped with teh Thursday class
homework
[2009/03/03 12:07] Starky Rubble: heh heh
[2009/03/03 12:07] Adelle Fitzgerald: it is slowly sinking in
[2009/03/03 12:08] Snowdrop Short: but it is also an important thing
to understand
[2009/03/03 12:08] Adelle Fitzgerald: yeah
[2009/03/03 12:08] Snowdrop Short: maybe we should work some more on
classes and objects today
[2009/03/03 12:08] Snowdrop Short: rather than what I had planned
originally
[2009/03/03 12:08] Adelle Fitzgerald: I am correct in thinking the
class creates the objects, and a class can have more than one object
[2009/03/03 12:08] M1sha Dallin: events?
[2009/03/03 12:08] Adelle Fitzgerald: ?
[2009/03/03 12:08] Starky Rubble: So I am guessing that with the
change from ArrayLists we are nearly done setting up our classes for
the groups module
[2009/03/03 12:08] M1sha Dallin: I'm stuck on events
[2009/03/03 12:08] Snowdrop Short: yes, a class is like a template
[2009/03/03 12:09] Snowdrop Short: that decides what the objects look
like
[2009/03/03 12:09] Adelle Fitzgerald: yes, and the .NET framework is
a library of objects that we call upon
[2009/03/03 12:09] Snowdrop Short: so all objects that are made from
that class have the same properties
[2009/03/03 12:09] Snowdrop Short: actuallly it is a library of
classes
[2009/03/03 12:10] Snowdrop Short: only when you use the word "new"
do you get an object
[2009/03/03 12:10] Adelle Fitzgerald: ahhhh right
[2009/03/03 12:10] Adelle Fitzgerald: that makes a lot of sense
[2009/03/03 12:10] Adelle Fitzgerald: now anyway :D
[2009/03/03 12:10] Starky Rubble: one "instance" of the class
[2009/03/03 12:10] Snowdrop Short: so "new Group()"
[2009/03/03 12:10] Snowdrop Short: creates a new object of the type
Group
[2009/03/03 12:10] Adelle Fitzgerald nods
[2009/03/03 12:11] Snowdrop Short: the confusing thing is that some
of the objects are created behind your back
[2009/03/03 12:11] Snowdrop Short: like the "Console" object we have
been working with
[2009/03/03 12:11] Adelle Fitzgerald: but the system.console is a
class though right?
[2009/03/03 12:11] Snowdrop Short: yes.. System.Console is a class
[2009/03/03 12:11] Adelle Fitzgerald: and its only when we pass it
information that the object is created, i.e. displayed?
[2009/03/03 12:12] Snowdrop Short: do you remember last we talked
about "classifiers" or "statics"
[2009/03/03 12:12] Adelle Fitzgerald: yes
[2009/03/03 12:12] M1sha Dallin: yep - assume Console is static
[2009/03/03 12:12] Adelle Fitzgerald: gotcha
[2009/03/03 12:12] Snowdrop Short: meaning methods that was shared by
all objects made from that class
[2009/03/03 12:13] Snowdrop Short: and "WriteLine" is a static method
on the class "Console"
[2009/03/03 12:13] Snowdrop Short: so you really don't need an object
to use that method
[2009/03/03 12:13] Adelle Fitzgerald nods
[2009/03/03 12:13] Snowdrop Short: since it is shared between all
objects, it even exists if no objects of that kind exists
[2009/03/03 12:14] Snowdrop Short: the developers and architects who
designed the "Console" class
[2009/03/03 12:14] Snowdrop Short: decided that the wanted a static
method "WriteLine" on the Console class
[2009/03/03 12:15] Adelle Fitzgerald: gotcha
[2009/03/03 12:15] Adelle Fitzgerald: okies, i just wanted to clear
those few things up :)
[2009/03/03 12:15] Snowdrop Short smiles, I'm glad to help
[2009/03/03 12:15] Snowdrop Short: because in c# you'll see that kind
of thing quite often
[2009/03/03 12:15] Adelle Fitzgerald nods
[2009/03/03 12:16] Snowdrop Short: but I know, static methods kind of
muddies the picture
[2009/03/03 12:16] Snowdrop Short: because you'd think that methods
could only operate on objects and not classes
[2009/03/03 12:17] Adelle Fitzgerald: i dont really know much
different, so its no muddier than objects themselves to me
[2009/03/03 12:18] Snowdrop Short: lets take a peek on the status of
our work
[2009/03/03 12:18] Starky Rubble: are statics used often in normal
development?
[2009/03/03 12:18] Snowdrop Short: not much
[2009/03/03 12:18] Starky Rubble: ok
[2009/03/03 12:18] Snowdrop Short: but for certain things they are
invaluable
[2009/03/03 12:18] Adelle Fitzgerald: ohhh poo....
[2009/03/03 12:18] Snowdrop Short: e.g. on the type "int"
[2009/03/03 12:19] Adelle Fitzgerald: haha i didnt register my VS
2008...
[2009/03/03 12:19] Snowdrop Short: you have a static method called
"parse"
[2009/03/03 12:19] Snowdrop Short: you don't have to register it
[2009/03/03 12:19] Adelle Fitzgerald: aparently you do!
[2009/03/03 12:19] Adelle Fitzgerald: its asking for a reg key
[2009/03/03 12:19] M1sha Dallin: I didn't
[2009/03/03 12:19] Adelle Fitzgerald: and wont run without it
[2009/03/03 12:19] Snowdrop Short: hmm .. strange
[2009/03/03 12:19] M1sha Dallin: Using the Express version?
[2009/03/03 12:20] Adelle Fitzgerald: You have not yet registered
your copy of Microsoft Visual C# 2008 Express Edition. You must
register the product now before you can continue to use it.
[2009/03/03 12:20] Snowdrop Short: vs 2008 or express?
[2009/03/03 12:20] M1sha Dallin: full VS does
[2009/03/03 12:20] Adelle Fitzgerald: express
[2009/03/03 12:20] M1sha Dallin: curious
[2009/03/03 12:20] Snowdrop Short: strange .. we'll I'm on Linux, so
I hardly use it
[2009/03/03 12:20] Adelle Fitzgerald: its ok, ill just register it
[2009/03/03 12:21] Starky Rubble: hmmmm MSDN is a multilayered
membership thing... or it was anyway - mebbe you triggered a demo
[2009/03/03 12:21] Starky Rubble: there is a free layer tho
[2009/03/03 12:22] Starky Rubble: ok
[2009/03/03 12:22] Adelle Fitzgerald: ok, i got it registered and
working :)
[2009/03/03 12:22] Starky Rubble: where are we?
[2009/03/03 12:22] Starky Rubble: heh
[2009/03/03 12:22] RC: Script running
[2009/03/03 12:23] Snowdrop Short: I thought that maybe we should
take a look at how to create objects
[2009/03/03 12:23] Starky Rubble: ok
[2009/03/03 12:23] Snowdrop Short: we haven't done much of that,
mostly we've talked about classes
[2009/03/03 12:23] Snowdrop Short: and not so much about objects
[2009/03/03 12:23] Snowdrop Short: maybe that'll help firm up the
differences
[2009/03/03 12:24] Snowdrop Short: the thing is... you don't ever see
objects
[2009/03/03 12:24] Snowdrop Short: they are just so many bits inside
the memory of a computer
[2009/03/03 12:24] Snowdrop Short: where as a class can be "seen" via
the source code
[2009/03/03 12:25] Snowdrop Short: that's also why c# uses "class" as
the instruction
[2009/03/03 12:25] Snowdrop Short: for how to define a class
[2009/03/03 12:25] Snowdrop Short: and most development work really
focusses on the classes
[2009/03/03 12:26] Adelle Fitzgerald: so the objects we create are
pretty much a wrapper for the properites we put in them?
[2009/03/03 12:26] Adelle Fitzgerald: and are portable between other
classes
[2009/03/03 12:26] Snowdrop Short:
http://www.pastebin.ca/1352170
[2009/03/03 12:27] Snowdrop Short: that's the version of our work I
have on my hard drive
[2009/03/03 12:27] Snowdrop Short: yes, a wrapper for the data and
code making up the machine instructions for the class
[2009/03/03 12:28] Snowdrop Short: and the code is shared between all
the classes, in order to conserver memory
[2009/03/03 12:28] Adelle Fitzgerald nods
[2009/03/03 12:28] Snowdrop Short: but you can think of it as if each
object carries it's own code and data
[2009/03/03 12:28] RC: Script running
[2009/03/03 12:28] Adelle Fitzgerald: gotcha
[2009/03/03 12:29] Adelle Fitzgerald: Line 3... the GenericM should
be Generic;
[2009/03/03 12:29] Starky Rubble: typo
[2009/03/03 12:29] Adelle Fitzgerald: yes
[2009/03/03 12:29] Snowdrop Short: maybe my cat :-)
[2009/03/03 12:30] Adelle Fitzgerald: hehe
[2009/03/03 12:30] Snowdrop Short: I have two of 'em right now
[2009/03/03 12:30] Snowdrop Short: one on my lap, the other almost on
top of the keyboard
[2009/03/03 12:30] Adelle Fitzgerald: lol
[2009/03/03 12:30] M1sha Dallin: :-)
[2009/03/03 12:31] Snowdrop Short: so .. just as an excercise, how
many classes do we have in this code sample
[2009/03/03 12:31] Adelle Fitzgerald: 3
[2009/03/03 12:31] Starky Rubble: 3 we define
[2009/03/03 12:31] Snowdrop Short: yes,
[2009/03/03 12:32] Snowdrop Short: and how many objects?
[2009/03/03 12:32] Adelle Fitzgerald: 4 if you include
System.Collections.generic
[2009/03/03 12:32] Adelle Fitzgerald: or maybe 6?
[2009/03/03 12:32] Snowdrop Short: how many that we create?
[2009/03/03 12:32] Adelle Fitzgerald: with System and
System.Collections
[2009/03/03 12:32] Adelle Fitzgerald: 3
[2009/03/03 12:32] Snowdrop Short: ok
[2009/03/03 12:32] M1sha Dallin: 3 created
[2009/03/03 12:32] Adelle Fitzgerald: we create 3, and use some
system classes
[2009/03/03 12:32] Snowdrop Short: and their types are?
[2009/03/03 12:33] Adelle Fitzgerald: GroupBase, Group and MainClass
[2009/03/03 12:33] M1sha Dallin: groupbase 1; group 2
[2009/03/03 12:34] Starky Rubble: right
[2009/03/03 12:34] Snowdrop Short: what about "new ArrayList" ?
[2009/03/03 12:34] Snowdrop Short: what is that?
[2009/03/03 12:34] Adelle Fitzgerald: thats an object right?
[2009/03/03 12:34] M1sha Dallin: an object component of another
object
[2009/03/03 12:35] Starky Rubble: dunno
[2009/03/03 12:35] Snowdrop Short: remember objects are created using
"new"
[2009/03/03 12:35] Snowdrop Short: so we create two instances of the
class "ArrayList"
[2009/03/03 12:35] Starky Rubble: and one of WriteConsole
[2009/03/03 12:35] Adelle Fitzgerald looks confused
[2009/03/03 12:36] Snowdrop Short: the class ArrayList is defined in
the namespace "System.Collections"
[2009/03/03 12:36] Adelle Fitzgerald: objects are created using "new"
yet 'we create two instances of the class "ArrayList"'.. so the new is
an object? not a class?
[2009/03/03 12:36] Snowdrop Short: we talked about "WriteLine" being
a static method on the class "Console"
[2009/03/03 12:37] Snowdrop Short: new is an instruction the computer
to create a new object
[2009/03/03 12:37] Snowdrop Short: a new instance of a specific class
[2009/03/03 12:37] Adelle Fitzgerald: and the object created is a
class?
[2009/03/03 12:37] Adelle Fitzgerald: right
[2009/03/03 12:37] Adelle Fitzgerald: ok, got that :)
[2009/03/03 12:37] Snowdrop Short: the object is created
[2009/03/03 12:38] Snowdrop Short: you can think of the sourcecode as
the classes
[2009/03/03 12:38] Adelle Fitzgerald: ok... let em get this clear...
[2009/03/03 12:38] Snowdrop Short: kind of ...
[2009/03/03 12:38] Starky Rubble: sorry - I meant WriteToConsole
[2009/03/03 12:38] Adelle Fitzgerald: so when we use 'new ArrayList'
we are using the class ArrayList to create a new object using it?
[2009/03/03 12:38] Snowdrop Short: WriteToConsole is a method on both
classes
[2009/03/03 12:38] Marcus Llewellyn: Classes are a blueprint. Once
instantiated with the new keyword, they become a working object. :)
[2009/03/03 12:39] Snowdrop Short: yes, we are creating a new
"object" based on the definition described in the class "ArrayList"
[2009/03/03 12:39] Adelle Fitzgerald nods and smiles
[2009/03/03 12:40] Starky Rubble: new ArrayList creates a new object
of 'type' ArrayList in a way doen't it?
[2009/03/03 12:40] Adelle Fitzgerald: so when we use 'new Group' we
are using the Group class to create a new Group object
[2009/03/03 12:40] Starky Rubble: there you go!
[2009/03/03 12:40] Snowdrop Short: yes :-)
[2009/03/03 12:41] Snowdrop Short: that is exactly what happens
[2009/03/03 12:41] Adelle Fitzgerald: okay... it is becoming much
clearer now :)
[2009/03/03 12:41] Adelle Fitzgerald: its such a hard concept for
me... or has been
[2009/03/03 12:42] Snowdrop Short: it is a hard concept for almost
anyone when learing object oriented languages
[2009/03/03 12:42] Snowdrop Short: that's the first major hurdle
[2009/03/03 12:42] Snowdrop Short: we all have had that confusion
[2009/03/03 12:42] Snowdrop Short: but we are also living proof that
it can be learned !!!
[2009/03/03 12:42] Adelle Fitzgerald: the code all of a sudden seems
to make much more sense now
[2009/03/03 12:42] Starky Rubble: cool
[2009/03/03 12:43] Adelle Fitzgerald: :)
[2009/03/03 12:43] Snowdrop Short: on trick question
[2009/03/03 12:43] Snowdrop Short: what about "MainClass" ??
[2009/03/03 12:43] Adelle Fitzgerald: MainClass is the class that
fires before anything, it defines the instructions
[2009/03/03 12:44] Starky Rubble: its a predefined required class
[2009/03/03 12:44] Snowdrop Short: what does the "static" keyword on
the "Main" method in "MainClass" tell you?
[2009/03/03 12:45] Starky Rubble: its universal?
[2009/03/03 12:45] Snowdrop Short: yes
[2009/03/03 12:45] M1sha Dallin: Created once?
[2009/03/03 12:45] Adelle Fitzgerald: it is part of the system class?
[2009/03/03 12:45] Snowdrop Short: and that the framework running our
application, doesn't even bother to create an instance of our
MainClass
[2009/03/03 12:45] Snowdrop Short: it simply calls a static method
directly
[2009/03/03 12:46] Snowdrop Short: without even bothering to call
"new" on our "MainClass"
[2009/03/03 12:46] Adelle Fitzgerald: right
[2009/03/03 12:46] Starky Rubble: ok
[2009/03/03 12:46] Snowdrop Short: it simply loads the code off the
disk, finds the static method called "Main" inside the MainClass
[2009/03/03 12:47] Snowdrop Short: and executes that directly
[2009/03/03 12:47] Starky Rubble: brb... apologies
[2009/03/03 12:47] Snowdrop Short: no fancy footwork, with creating a
new instance, like we do
[2009/03/03 12:48] Adelle Fitzgerald: so the MainClass 'is the'
program and uses the code within it to use other classes to produce
whatever the program is meant to
[2009/03/03 12:48] Snowdrop Short: yes
[2009/03/03 12:49] Snowdrop Short: the Main method is where
everything begins
[2009/03/03 12:49] Snowdrop Short: and ends
[2009/03/03 12:49] Adelle Fitzgerald: okies, i understand that :)
[2009/03/03 12:49] Snowdrop Short: so, lets recount ...
[2009/03/03 12:49] Snowdrop Short: how many objects?
[2009/03/03 12:50] Adelle Fitzgerald: 4?
[2009/03/03 12:50] M1sha Dallin: 7?
[2009/03/03 12:51] Snowdrop Short: lets try to count them
[2009/03/03 12:51] M1sha Dallin: 4
[2009/03/03 12:51] Snowdrop Short: GroupBase b = new GroupBase
(Guid.NewGuid(), "Base Group")
[2009/03/03 12:51] M1sha Dallin: forgot it was groupbase
[2009/03/03 12:51] Snowdrop Short: in line 67
[2009/03/03 12:51] Snowdrop Short: that's one
[2009/03/03 12:51] Adelle Fitzgerald: yep
[2009/03/03 12:52] Snowdrop Short: inside the constructor of
groupbase
[2009/03/03 12:52] Snowdrop Short: none
[2009/03/03 12:52] Snowdrop Short: as I can see it
[2009/03/03 12:52] Adelle Fitzgerald: yep
[2009/03/03 12:52] Snowdrop Short: Group g = new Group("The real
group", "For cool people");
[2009/03/03 12:52] Snowdrop Short: in line 74
[2009/03/03 12:52] Adelle Fitzgerald: thats another
[2009/03/03 12:52] Adelle Fitzgerald: so 2 so far
[2009/03/03 12:53] Snowdrop Short: in the constructor of Group
[2009/03/03 12:53] Adelle Fitzgerald: and in the Group class we have
2 new ArrayList, which is another 2
[2009/03/03 12:53] Snowdrop Short: group inherits from group base
[2009/03/03 12:53] M1sha Dallin: =4
[2009/03/03 12:53] M1sha Dallin: so far
[2009/03/03 12:53] Snowdrop Short: but we know group base doesn't
create any classes
[2009/03/03 12:53] Snowdrop Short: sorry create any objects
[2009/03/03 12:54] Snowdrop Short: not the best of times to make a
type of that kind
[2009/03/03 12:54] Snowdrop Short: 37 and 38
[2009/03/03 12:54] Snowdrop Short: each creates and instance of
"ArrayList"
[2009/03/03 12:55] Snowdrop Short: so that's it
[2009/03/03 12:55] Snowdrop Short: I think
[2009/03/03 12:55] Snowdrop Short: 4 objects
[2009/03/03 12:55] Snowdrop Short: and we define 3 classes
[2009/03/03 12:55] Snowdrop Short: "MainClass", "Group" and
"GroupBase"
[2009/03/03 12:55] Snowdrop Short: but I have a philosophical
question
[2009/03/03 12:56] Adelle Fitzgerald: wheeee
[2009/03/03 12:56] Snowdrop Short: "Group" inherits from "GroupBase"
[2009/03/03 12:56] Adelle Fitzgerald: i got it right!
[2009/03/03 12:56] M1sha Dallin: :-)
[2009/03/03 12:56] Snowdrop Short: and since we created an instance
of "Group"
[2009/03/03 12:56] Snowdrop Short: didn't we at the sametime create
and instance of "GroupBase" ??
[2009/03/03 12:57] Adelle Fitzgerald: no, we created a sub class?
[2009/03/03 12:57] M1sha Dallin: Nope? We extended GroupBase
[2009/03/03 12:57] Snowdrop Short: because a "Group" is both a
"Group" in it's own right and a type of "GroupBase"
[2009/03/03 12:57] Snowdrop Short: that's why I was calling it
"philosophical"
[2009/03/03 12:57] Snowdrop Short: because we only created on object
[2009/03/03 12:58] Snowdrop Short: but that object has two shapes
[2009/03/03 12:58] Snowdrop Short: both the shape of "Group"
[2009/03/03 12:58] Snowdrop Short: and the shape of "GroupBase"
[2009/03/03 12:58] Snowdrop Short: what ever we can do with a
"GroupBase", we can also do with a "Group"
[2009/03/03 12:59] Adelle Fitzgerald: ahh i think i get it
[2009/03/03 12:59] Adelle Fitzgerald: but not the other way round
[2009/03/03 12:59] Snowdrop Short: no, not the other way around
[2009/03/03 12:59] Snowdrop Short: like M1sha said
[2009/03/03 12:59] Snowdrop Short: we extended GroupBase
[2009/03/03 12:59] Snowdrop Short: Group is an extension of GroupBase
[2009/03/03 12:59] Adelle Fitzgerald: so we can apply things to Group
and that will impact on GroupBase too, but anything we apply to
GroupBase, stays with GroupBase
[2009/03/03 13:00] Adelle Fitzgerald: for want of a better
expression ;)
[2009/03/03 13:00] Snowdrop Short: that depends on your view
[2009/03/03 13:00] Snowdrop Short: if we change the code for
"GroupBase" ... that will impact the way "Group" behaves
[2009/03/03 13:01] Snowdrop Short: but any changes we do to "Group"
will not change the way "GroupBase" behaves
[2009/03/03 13:01] Adelle Fitzgerald: yes, thats pretty much what I
emant, just a bad way of explaining it
[2009/03/03 13:02] Snowdrop Short: we say that an object of type
"Group" can have different shapes
[2009/03/03 13:02] Adelle Fitzgerald: ohhh.. but i got the the wrong
way round too
[2009/03/03 13:02] Snowdrop Short: it can have the shape of "Group"
[2009/03/03 13:02] Snowdrop Short: but also the shape of "GroupBase"
[2009/03/03 13:03] Snowdrop Short: does anybody know the ancient
greek word for "shape"?
[2009/03/03 13:03] Empire Monkey: Morph.... something?
[2009/03/03 13:03] Snowdrop Short: yes .. morph
[2009/03/03 13:03] Snowdrop Short: and the ancient greek word for
"several" or "many" ?
[2009/03/03 13:03] M1sha Dallin: poly
[2009/03/03 13:04] Snowdrop Short: yes
[2009/03/03 13:04] Empire Monkey: ...pollywannacrackerus
[2009/03/03 13:04] Snowdrop Short: we say that "Group" is polymorph
[2009/03/03 13:04] Snowdrop Short: it can have several shapes
[2009/03/03 13:05] Snowdrop Short: that capability to have several
shapes is pretty powerful
[2009/03/03 13:05] Snowdrop Short: compared to traditional
programming languages
[2009/03/03 13:05] Snowdrop Short: like lsl
[2009/03/03 13:05] Adelle Fitzgerald nods
[2009/03/03 13:06] Snowdrop Short: later on we'll put that to very
good use
[2009/03/03 13:06] Adelle Fitzgerald: can we create other classes
from classes?
[2009/03/03 13:06] Snowdrop Short: I have another philosophical
question
[2009/03/03 13:07] Snowdrop Short: we talked about new being the
instruction, which caused an object to be created
[2009/03/03 13:07] Snowdrop Short: but what about the keyword "new"
as we use it in line 48?
[2009/03/03 13:07] Snowdrop Short: and 42
[2009/03/03 13:08] Adelle Fitzgerald: thats creating a new class
[2009/03/03 13:08] Snowdrop Short: no, not really
[2009/03/03 13:08] Snowdrop Short: it adorns a method
[2009/03/03 13:09] Snowdrop Short: "WriteToConsole"
[2009/03/03 13:09] Snowdrop Short: and ToString
[2009/03/03 13:09] Snowdrop Short: we used it to break the
inheritance chain
[2009/03/03 13:10] Snowdrop Short: remember what happend when we
executed the program
[2009/03/03 13:10] Snowdrop Short: and noticed what line 80 printed
[2009/03/03 13:10] Snowdrop Short: what did it print?
[2009/03/03 13:10] Snowdrop Short: do you remember?
[2009/03/03 13:11] M1sha Dallin: text from the base class as well as
the local
[2009/03/03 13:11] Adelle Fitzgerald: no
[2009/03/03 13:11] Adelle Fitzgerald: it created a new object of it
[2009/03/03 13:12] Adelle Fitzgerald: hmm
[2009/03/03 13:12] Snowdrop Short: we talked about a built in object
[2009/03/03 13:12] Snowdrop Short: called "object"
[2009/03/03 13:12] Snowdrop Short: and that everything inside c#
inherited from that
[2009/03/03 13:12] Snowdrop Short: and that on the object class there
existed a method called "ToString"
[2009/03/03 13:13] Snowdrop Short: so in line 79 we define a handle
to that very very basic class
[2009/03/03 13:13] Snowdrop Short: and then put the value of the
handle g into it
[2009/03/03 13:13] Snowdrop Short: o = g
[2009/03/03 13:14] Snowdrop Short: we then called the method
"ToString" on that handle
[2009/03/03 13:14] Snowdrop Short: what then happend was that the
framework tried to figure out what to do
[2009/03/03 13:15] Snowdrop Short: because there was a method called
"ToString"
[2009/03/03 13:15] Snowdrop Short: both on "object" on "GroupBase"
and on "Group"
[2009/03/03 13:15] Snowdrop Short: and it tries to execute the most
specialized version it can find
[2009/03/03 13:16] Snowdrop Short: so we'd think that would be line
44
[2009/03/03 13:16] Snowdrop Short: but that method has been adorned
with "new"
[2009/03/03 13:16] Snowdrop Short: so it is a kind of new "ToString"
[2009/03/03 13:17] Adelle Fitzgerald: does it actually create a new
object using 'ToString'?
[2009/03/03 13:17] Snowdrop Short: no, it just executes the code,
defined in the method boby
[2009/03/03 13:17] Snowdrop Short: if the object doesn't exist
already, you have an error
[2009/03/03 13:17] Snowdrop Short: and the runtime will complain
[2009/03/03 13:17] Adelle Fitzgerald: so 'o' isnt an object?
[2009/03/03 13:18] Snowdrop Short: o is a handle to an object
[2009/03/03 13:18] Adelle Fitzgerald: ahhhh
[2009/03/03 13:18] Snowdrop Short: objects just float around inside
the memory of the computer
[2009/03/03 13:18] Adelle Fitzgerald: so what we are craeting is a
new handle?
[2009/03/03 13:18] Snowdrop Short: and with out a handle to it, we
cannot gain access
[2009/03/03 13:18] Snowdrop Short: yes
[2009/03/03 13:18] Adelle Fitzgerald: so ToString can have many
handles?
[2009/03/03 13:19] Adelle Fitzgerald: or even an object can have many
handles?
[2009/03/03 13:19] Snowdrop Short: new Group(....) creates a new
object in line 74
[2009/03/03 13:19] Snowdrop Short: and places a handle to that object
in the variable "g"
[2009/03/03 13:19] Snowdrop Short: that variable "g" is defined to
have the type "Handle to Group"
[2009/03/03 13:19] Marcus Llewellyn: o is a reference to g? Anything
that happens to o, happens to g?
[2009/03/03 13:19] Snowdrop Short: yes
[2009/03/03 13:20] Snowdrop Short: in line 80
[2009/03/03 13:20] Snowdrop Short: both o and g has a handle to the
same object
[2009/03/03 13:20] Snowdrop Short: that object can have 3 different
shapes
[2009/03/03 13:21] Snowdrop Short: "object" , "Group" and "GroupBase"
[2009/03/03 13:21] Snowdrop Short: and any handle which matches one
of these types are valid handles for an object of type "Group"
[2009/03/03 13:22] Snowdrop Short: if line 74 just said:
[2009/03/03 13:22] Snowdrop Short: new Group("The real group", "For
cool people");
[2009/03/03 13:22] Snowdrop Short: and nothing more
[2009/03/03 13:22] Snowdrop Short: we would have crated an object of
type "Group"
[2009/03/03 13:23] Snowdrop Short: but we could never really use it
for much
[2009/03/03 13:23] Snowdrop Short: because we would have no handle to
it
[2009/03/03 13:23] Snowdrop Short: i.e. no way of getting to it's
methods, except for that brief instant where we created it
[2009/03/03 13:23] Adelle Fitzgerald nods
[2009/03/03 13:24] Snowdrop Short: in fact new Group("The real
group", "For cool people").ToString();
[2009/03/03 13:24] Snowdrop Short: would be valid
[2009/03/03 13:24] Snowdrop Short: it would compile and run
[2009/03/03 13:24] Snowdrop Short: but since we never stored a handle
to it
[2009/03/03 13:24] Adelle Fitzgerald: if we create an object without
a handle, the program would not compile?
[2009/03/03 13:25] Snowdrop Short: it would only make sense in some
very special situations
[2009/03/03 13:25] Snowdrop Short: it will compile and run
[2009/03/03 13:25] Snowdrop Short: there is no rule against creating
an object, but never storing the handle anywhere
[2009/03/03 13:25] Marcus Llewellyn: It simply wouldn't be very
useful, mostly. ;)
[2009/03/03 13:26] Snowdrop Short: only rarely will it make sense
[2009/03/03 13:26] Adelle Fitzgerald: yes, and use unnecessary memory
[2009/03/03 13:26] Snowdrop Short: there are special situations where
it makes sense
[2009/03/03 13:26] Snowdrop Short: but those are far between, so lets
ignore that for now
[2009/03/03 13:26] Adelle Fitzgerald: ok
[2009/03/03 13:27] Snowdrop Short: by the way, "handle" is really a
java term
[2009/03/03 13:27] Snowdrop Short: I don't really know if it is used
that much in c#
[2009/03/03 13:27] Adelle Fitzgerald: ok, so to get this straight in
my head...
[2009/03/03 13:27] Snowdrop Short: but I like that name, because it
makes sense to me
[2009/03/03 13:27] Adelle Fitzgerald: we use classes to make objects,
and we use the object by their handle?
[2009/03/03 13:27] Snowdrop Short: yes
[2009/03/03 13:27] Adelle Fitzgerald: literally 'handling' them hehe
[2009/03/03 13:28] Snowdrop Short: yes .. litterally handling the
objects
[2009/03/03 13:28] Snowdrop Short: that is exactly the flow of things
[2009/03/03 13:28] Adelle Fitzgerald: ok, you didnt answer my
question earlier... can you create a class with a class?
[2009/03/03 13:28] Snowdrop Short: that depends on your definition
[2009/03/03 13:29] Snowdrop Short: but a static method can create an
instancec of its own type
[2009/03/03 13:29] Snowdrop Short: e.g.
[2009/03/03 13:29] Snowdrop Short: it would be legal for Main to
contain code like this
[2009/03/03 13:29] Snowdrop Short: MainClass m = new MainClass(null);
[2009/03/03 13:30] Snowdrop Short: that is perfectly legal, an even
used from time to time
[2009/03/03 13:31] Adelle Fitzgerald: what i was thinking is in the
terms of like a function where lots of variables are used from other
objects, to create a new class, but i think i figure it now, that
those objects would be defined as necessary to be used with a specific
class already defined to produce different outputs
[2009/03/03 13:31] Adelle Fitzgerald: if that makes any sense
[2009/03/03 13:32] Snowdrop Short: I think I understand what you are
saying
[2009/03/03 13:32] Snowdrop Short: often you really don't have that
many variables
[2009/03/03 13:33] Adelle Fitzgerald nods
[2009/03/03 13:33] Snowdrop Short: most of the time, you'd simply
hide those variables inside the classes
[2009/03/03 13:33] Snowdrop Short: and then use methods on that class
to do the work
[2009/03/03 13:34] Snowdrop Short: in order for that to work, you
need what it called "separation"
[2009/03/03 13:34] Snowdrop Short: i.e. each class should be
relatively selfcontained
[2009/03/03 13:34] Adelle Fitzgerald: yeah, i think i understand
[2009/03/03 13:35] Adelle Fitzgerald: im probably going way to far
adead right now too
[2009/03/03 13:35] Snowdrop Short: so that all you needed to do was
to "orchestrate" calling methods in the right sequence
[2009/03/03 13:35] Adelle Fitzgerald: gotcha
[2009/03/03 13:35] Adelle Fitzgerald: so...
[2009/03/03 13:35] Adelle Fitzgerald: if you had a class called 'Do'
[2009/03/03 13:35] Adelle Fitzgerald: and had sub classes as 'This'
and 'That'
[2009/03/03 13:36] Adelle Fitzgerald: could you used a variable to
define whether Do.This, or Do.That is called?
[2009/03/03 13:36] Snowdrop Short: no
[2009/03/03 13:36] Adelle Fitzgerald: right
[2009/03/03 13:36] Snowdrop Short: that would depend on how the
inheritance was setup
[2009/03/03 13:36] Adelle Fitzgerald: okies
[2009/03/03 13:37] Snowdrop Short: depending on what you mean
actually
[2009/03/03 13:37] Adelle Fitzgerald: so the Do.This and Do.That
would already have to eb hard coded and then called upon using say an
'if' statement?
[2009/03/03 13:37] Snowdrop Short: beacuse in c# a class can only
inherit from one other class
[2009/03/03 13:38] Snowdrop Short: e.g. Do would ether inherit from
"this" or from "that"
[2009/03/03 13:38] Snowdrop Short: but not both
[2009/03/03 13:38] Snowdrop Short: so it would be clear from the
definition of "Do", whether it would use this or that
[2009/03/03 13:38] M1sha Dallin: Can a class C inherit from B that
inherits from A?
[2009/03/03 13:39] Snowdrop Short: yes
[2009/03/03 13:39] M1sha Dallin: OK
[2009/03/03 13:39] Snowdrop Short: you can nest as deeply as you want
[2009/03/03 13:39] Snowdrop Short: but you cannot have class A
inheriting from both B and C
[2009/03/03 13:39] Adelle Fitzgerald: ahhh
[2009/03/03 13:39] Adelle Fitzgerald: so in my case it would eb
This.Do and That.Do?
[2009/03/03 13:40] Snowdrop Short: yes
[2009/03/03 13:40] Adelle Fitzgerald: righty :)
[2009/03/03 13:40] Snowdrop Short: the concept of A inherting from
both B and C is called
[2009/03/03 13:40] Snowdrop Short: "multiple inheritance"
[2009/03/03 13:40] Snowdrop Short: and c# does not allow that
[2009/03/03 13:41] Snowdrop Short: because it can lead to some very
very confusing situations
[2009/03/03 13:41] Snowdrop Short: e.g.
[2009/03/03 13:41] Snowdrop Short: lets say we have a class
describing animals
[2009/03/03 13:41] Snowdrop Short: and that has a method "Eat"
[2009/03/03 13:41] Snowdrop Short: and we then create a more
specialised class
[2009/03/03 13:42] Snowdrop Short: called "FlyingAnimal"
[2009/03/03 13:42] Snowdrop Short: which overrides the Eat method
[2009/03/03 13:42] Snowdrop Short: and another one
[2009/03/03 13:42] Snowdrop Short: called "Mammal"
[2009/03/03 13:42] Snowdrop Short: which also overrides the method
"Eat"
[2009/03/03 13:42] Snowdrop Short: now lets say we had a class called
"Bat"
[2009/03/03 13:43] Snowdrop Short: which (if c# allowed it) inherited
from both "FlyingAnimal" and "Mammal"
[2009/03/03 13:43] Snowdrop Short: what would Eat do?
[2009/03/03 13:44] Starky Rubble: be confused
[2009/03/03 13:44] Marcus Llewellyn: Hmmm... presumably take the
overriden method of the first or last class listed in the inhertiance
chain.
[2009/03/03 13:44] Snowdrop Short: some languages supports that, but
it leads to some very nasty situations
[2009/03/03 13:44] M1sha Dallin: Redefine the classes?
[2009/03/03 13:44] Adelle Fitzgerald: i think something like it would
eat the bad, causing some kind of bad loop in the program
[2009/03/03 13:44] Adelle Fitzgerald: *bat
[2009/03/03 13:44] Snowdrop Short: it is difficult to implement,
difficult for programmers
[2009/03/03 13:45] Snowdrop Short: so a lot of programming languages,
one of them c# doesn't allow that
[2009/03/03 13:45] Snowdrop Short: sometimes it is a problem
[2009/03/03 13:45] Snowdrop Short: but not as often as you think
[2009/03/03 13:45] Snowdrop Short: and there are ways to get around
it
[2009/03/03 13:46] Snowdrop Short: or at least, take away most of the
problems single inheritance causes
[2009/03/03 13:46] Adelle Fitzgerald: another thing, you ahve used
the trem 'method' a lot more tonight, but i'm a little unclear ats to
what a method is in terms of code, can you point me to a line in the
code we have that is a method please
[2009/03/03 13:47] Snowdrop Short: line 48 defines a mehtod
[2009/03/03 13:47] Snowdrop Short: line 42
[2009/03/03 13:47] Snowdrop Short: line 24
[2009/03/03 13:47] Adelle Fitzgerald: yep yep, i get it now,
thanks :)
[2009/03/03 13:47] Snowdrop Short: a method is what called a function
[2009/03/03 13:47] Snowdrop Short: in some other languages
[2009/03/03 13:48] Adelle Fitzgerald: yeah, i understand now
[2009/03/03 13:48] Snowdrop Short: but in OO, we talk about methods
[2009/03/03 13:48] Snowdrop Short: or in formal language "signals"
[2009/03/03 13:48] Snowdrop Short: you can think of line 71
[2009/03/03 13:49] Snowdrop Short: as sending a signal to the object
b, to perform the method
[2009/03/03 13:49] Snowdrop Short: "WriteToConsole"
[2009/03/03 13:49] Starky Rubble: right
[2009/03/03 13:49] Adelle Fitzgerald nods
[2009/03/03 13:49] Adelle Fitzgerald: thats cleared a lot up, thank
you :)
[2009/03/03 13:50] Snowdrop Short: in some ways, signal is a good way
to think of things
[2009/03/03 13:51] Snowdrop Short: because sending a signal, kind of
implies that the method being signalled is on it's own
[2009/03/03 13:51] Snowdrop Short: and really, a method should always
be focussed on doing one thing
[2009/03/03 13:51] Snowdrop Short: and one thing only
[2009/03/03 13:51] Snowdrop Short: and then sending of other signals,
in order to accomplish that task
[2009/03/03 13:52] Adelle Fitzgerald: from the classes it calls
[2009/03/03 13:52] Snowdrop Short: objects ...
[2009/03/03 13:52] Snowdrop Short smiles
[2009/03/03 13:52] Adelle Fitzgerald: right :P
[2009/03/03 13:52] Adelle Fitzgerald: cos WriteToConsole is an
object, not a class!
[2009/03/03 13:53] Snowdrop Short: WriteToConsole is a method
[2009/03/03 13:53] Snowdrop Short: we can execute on an object
[2009/03/03 13:53] Snowdrop Short: and the definition of that Method
we can find in the class description
[2009/03/03 13:53] Adelle Fitzgerald: yeah, i get it...
[2009/03/03 13:53] Adelle Fitzgerald: i think i do anyway
[2009/03/03 13:53] Adelle Fitzgerald: it will drop in sortly
[2009/03/03 13:54] Adelle Fitzgerald: and just when i thought i had
it with classes and objects hehe
[2009/03/03 13:56] Adelle Fitzgerald: so, GroupBase.Group is an
object, created by the class Group, and the WriteToConsole is a method
used to use the object Groupbase.Object?
[2009/03/03 13:56] Adelle Fitzgerald: *GroupBase.Group
[2009/03/03 13:56] Snowdrop Short: WriteToConsole is a method
[2009/03/03 13:57] Adelle Fitzgerald: thats what i said
[2009/03/03 13:57] Snowdrop Short: yes
[2009/03/03 13:57] Adelle Fitzgerald: :)
[2009/03/03 13:57] Starky Rubble: ok so - lemme state it as I see
it... Classes are templates - specs including any methods - for
objects. An object is an instance - a particular example - of a class.
We assign objects handles (names) so we can refer to them and send
them signals to execute their methods so as to do something.
[2009/03/03 13:57] Adelle Fitzgerald: its getting there now
[2009/03/03 13:58] Snowdrop Short nods
[2009/03/03 13:58] Starky Rubble: ok
[2009/03/03 13:58] Snowdrop Short: yes Starky, that's about it
[2009/03/03 13:58] Snowdrop Short: 4 hours of instruction, boiled
down
[2009/03/03 13:58] Snowdrop Short: I think
[2009/03/03 13:58] Marcus Llewellyn: lol
[2009/03/03 13:58] Adelle Fitzgerald: hehee
[2009/03/03 13:58] Adelle Fitzgerald: i'm 99.9% there now :D
[2009/03/03 13:58] Adelle Fitzgerald: the other 0.1 will come from
practice :)
[2009/03/03 13:59] Snowdrop Short: yes
[2009/03/03 13:59] Snowdrop Short: I'm starting to feel that we are
ready for some new material
[2009/03/03 13:59] Starky Rubble: ok
[2009/03/03 13:59] Snowdrop Short: but lets wait with that until next
tuesday
[2009/03/03 13:59] Adelle Fitzgerald: okies
[2009/03/03 13:59] M1sha Dallin: ok
[2009/03/03 14:00] Snowdrop Short: and then extend a bit more on our
group project
[2009/03/03 14:00] M1sha Dallin: but what is next?
[2009/03/03 14:00] Snowdrop Short: I think we should get our
grouplist back
[2009/03/03 14:00] Starky Rubble: losing THE aRRAYlISTS?
[2009/03/03 14:00] Adelle Fitzgerald: Snowdrop, do you have any new
material already planned? cos I was thinking it would be good if we
could have that code already, so we can study it before next tuesday
[2009/03/03 14:00] Snowdrop Short: and some role
[2009/03/03 14:00] Starky Rubble: oops caps ;o;
[2009/03/03 14:00] Adelle Fitzgerald: unless its different to what we
are doing now
[2009/03/03 14:00] Starky Rubble: lol
[2009/03/03 14:00] Snowdrop Short: and loosing the the arraylists for
some thing better
[2009/03/03 14:01] M1sha Dallin: KeyedCollection?
[2009/03/03 14:01] Snowdrop Short: we should have some propper
collections
[2009/03/03 14:01] Snowdrop Short: both for group members and groups
[2009/03/03 14:02] Snowdrop Short: but I had planned to introduce yet
another base class as well
[2009/03/03 14:02] Snowdrop Short: today we have group base
[2009/03/03 14:02] Snowdrop Short: if you want some home work
[2009/03/03 14:03] Snowdrop Short: I
[2009/03/03 14:03] Snowdrop Short: I'll suggest you look into the
classes defined in the namespace
[2009/03/03 14:03] Snowdrop Short: System.Collections.Generic
[2009/03/03 14:03] Snowdrop Short: especially
[2009/03/03 14:03] Snowdrop Short: "Dictionary" and "List"
[2009/03/03 14:03] Starky Rubble: ok
[2009/03/03 14:03] Adelle Fitzgerald: okies
[2009/03/03 14:03] M1sha Dallin: ok
[2009/03/03 14:04] Adelle Fitzgerald: i've heard 'dictionary'
mentioned before a few times on #opensim-dev
[2009/03/03 14:04] M1sha Dallin: I used it in my first pass at th
eGroups problem instead of ArrayList
[2009/03/03 14:05] Snowdrop Short: in programming, a number of
different standard datatypes are used
[2009/03/03 14:05] Snowdrop Short: a datatype, usually describes both
a way of organizing data, and the operations allowed on them
[2009/03/03 14:06] Adelle Fitzgerald: ohh so dictionary is a
datatype?
[2009/03/03 14:06] Snowdrop Short: a dictionary is something used to
look up something
[2009/03/03 14:06] Snowdrop Short: yes, it is a datatype
[2009/03/03 14:06] Starky Rubble: right
[2009/03/03 14:06] Adelle Fitzgerald: right
[2009/03/03 14:06] Adelle Fitzgerald: cool
[2009/03/03 14:06] Snowdrop Short: but also a class or collection of
classes
[2009/03/03 14:06] Adelle Fitzgerald: like a list with indexing?
[2009/03/03 14:06] Snowdrop Short: yes, you use a key to look up a
value
[2009/03/03 14:06] Adelle Fitzgerald: okies, ill look into them
both :)
[2009/03/03 14:06] Starky Rubble: cool
[2009/03/03 14:07] Snowdrop Short: you can create a dicitionary is
many different ways
[2009/03/03 14:07] Snowdrop Short: but basicaly anything
[2009/03/03 14:07] Snowdrop Short: which allows you to find some
piece of data based on a key
[2009/03/03 14:07] Snowdrop Short: is a kind of dictionary
[2009/03/03 14:07] Starky Rubble: makes sense
[2009/03/03 14:08] Snowdrop Short: so a database can be used as a
dictionary
[2009/03/03 14:08] Snowdrop Short: but also the class
"System.Collections.Generic.Dictionary<...>"
[2009/03/03 14:09] Snowdrop Short: think of it as an in memory
primitive database
[2009/03/03 14:09] Starky Rubble: ok
[2009/03/03 14:09] Adelle Fitzgerald: okies
[2009/03/03 14:09] Snowdrop Short: ok .. time to round up I think
[2009/03/03 14:10] Starky Rubble: yes... and thanks as always!!
[2009/03/03 14:10] Snowdrop Short: you are welcome
[2009/03/03 14:10] Snowdrop Short: it is my pleasure :-)
[2009/03/03 14:10] Adelle Fitzgerald: i think things finially all
slipped into place for me now, thank you :)
[2009/03/03 14:10] Snowdrop Short: you are welcome
[2009/03/03 14:11] Snowdrop Short: have a nice day, for those of you
still having most of the day ahead of you
[2009/03/03 14:11] Snowdrop Short: I'll be heading to bed now
[2009/03/03 14:11] Snowdrop Short: nite
[2009/03/03 14:11] Marcus Llewellyn: G'nite, Snowdrop. :)
[2009/03/03 14:11] Adelle Fitzgerald: okies, sleep well!
[2009/03/03 14:11] Starky Rubble: heh - thanks and gnite
[2009/03/03 14:11] Adelle Fitzgerald: nighty
http://www.pastebin.ca/1352170
using System;
using System.Collections;
using System.Collections.GenericM
namespace Groups
{
public class GroupBase
{
public GroupBase(Guid ID, string name)
{
this.ID = ID;
this.Name = name;
}
public Guid ID;
public string Name;
override public string ToString()
{
return string.Format("ID={0} Name={1}", ID, Name);
}
// Write Bae Details on the Console
public void WriteToConsole()
{
Console.WriteLine(ToString());
}
}
public class Group : GroupBase
{
// Constructor
public Group(string name, string description) : base
(Guid.NewGuid(), name)
{
this._Description = description;
this._PermittedRoles = new ArrayList();
this._Members = new ArrayList();
}
public new string ToString()
{
return string.Format("Description={0}, #of Members {1}",
_Description, _Members.Count);
}
// Write Group Details on the Console
public new void WriteToConsole()
{
base.WriteToConsole();
Console.WriteLine(ToString());
foreach (Group GroupMember in _Members)
GroupMember.WriteToConsole();
}
// Type definitions for the Group Structure
public string _Name;
public string _Description;
public ArrayList _PermittedRoles;
public ArrayList _Members;
}
class MainClass
{
public static void Main(string[] args)
{
GroupBase b = new GroupBase(Guid.NewGuid(), "Base Group");
Console.WriteLine("--------------------------------");
Console.WriteLine(b.ToString());
Console.WriteLine("--------------------------------");
b.WriteToConsole();
Console.WriteLine("--------------------------------");
Group g = new Group("The real group", "For cool people");
Console.WriteLine(g.ToString());
Console.WriteLine("--------------------------------");
g.WriteToConsole();
Console.WriteLine("--------------------------------");
object o = g;
Console.WriteLine(o.ToString());
}
}
}