Pastebin's are at the bottom of the log.
[2009/02/26 13:06] Snowdrop Short: does anybody have any questions
about last time
[2009/02/26 13:06] Snowdrop Short: I don't think we quite had time to
finish up nice and tidy last time
[2009/02/26 13:06] Adelle Fitzgerald: not a question, but I didnt do
my homework... I was concentrating more on understanding opjects
[2009/02/26 13:06] Norse Writer: I hope it is ok I just drop in a
listen?
[2009/02/26 13:07] Adelle Fitzgerald: i think i pretty much
understand it now
[2009/02/26 13:07] Snowdrop Short: you are welcome Norse
[2009/02/26 13:07] Snowdrop Short: good
[2009/02/26 13:07] Snowdrop Short: once you have that understanding
[2009/02/26 13:07] Snowdrop Short: things will get easier
[2009/02/26 13:07] Adelle Fitzgerald nods
[2009/02/26 13:07] Snowdrop Short: it is a difficult concept
[2009/02/26 13:07] Snowdrop Short: remember ... computers were
invented in the 40ies
[2009/02/26 13:08] Snowdrop Short: but it wasn't until late 60ies
beginning of the 70 ies that objects and classes were invented
[2009/02/26 13:08] Snowdrop Short: so it took the best brains in the
world, 30 years to cook up that idea :-)
[2009/02/26 13:08] Adelle Fitzgerald: wow
[2009/02/26 13:08] Snowdrop Short: it you can understand it in 3
weeks, it's good going :-)
[2009/02/26 13:09] M1sha Dallin: Though resources may have played a
part - difficult when you only have 16K Bytes for the whole team to
use
[2009/02/26 13:10] Snowdrop Short: true, but a lot of the basic stuff
were invented way back early
[2009/02/26 13:10] Snowdrop Short: ok
[2009/02/26 13:10] Snowdrop Short: last we looked at a person as a
class
[2009/02/26 13:10] Snowdrop Short: and we defined a relationship
between two classes
[2009/02/26 13:11] Snowdrop Short: that's called an "association"
[2009/02/26 13:12] Snowdrop Short: two person objects would be
associated via a "spouse" relationship
[2009/02/26 13:12] Adelle Fitzgerald nods
[2009/02/26 13:12] Snowdrop Short: and we worked on a method for
calculating the age of that relationship
[2009/02/26 13:13] Snowdrop Short: by introducing a method on the
class called "duration"
[2009/02/26 13:13] Snowdrop Short: and we ran into a problem
[2009/02/26 13:14] Snowdrop Short: because, what should the method
"duration" do if there was no spouse
[2009/02/26 13:14] Snowdrop Short: that relationship is what we call
a "0..1" relationship
[2009/02/26 13:15] Snowdrop Short: either there is no relationship
[2009/02/26 13:15] Snowdrop Short: or there is only one
[2009/02/26 13:16] Snowdrop Short: if we on the other hand had
something called a relationship
[2009/02/26 13:16] Starky Rubble: Soory to be late
[2009/02/26 13:16] Snowdrop Short: that's ok Starky :-) you're
welcome
[2009/02/26 13:17] Snowdrop Short: so if we tied two persons together
using a new class called
[2009/02/26 13:17] Snowdrop Short: "relationship"
[2009/02/26 13:17] Snowdrop Short: then we could simply have
"Duration" on that class
[2009/02/26 13:17] Snowdrop Short: sorry "AgeDifference"
[2009/02/26 13:18] Starky Rubble: or both
[2009/02/26 13:18] Snowdrop Short: or both
[2009/02/26 13:18] Snowdrop Short: that way the operation would
always be valid
[2009/02/26 13:19] Starky Rubble: hmm im not typing lol
[2009/02/26 13:19] Starky Rubble: that stopped it
[2009/02/26 13:19] Snowdrop Short: you are to mee
[2009/02/26 13:19] Snowdrop Short: ok
[2009/02/26 13:20] Adelle Fitzgerald: so a relationship HAS to have
at least 2 objects and a 0..1 can have 0 or only 1 right?
[2009/02/26 13:20] Snowdrop Short: yes
[2009/02/26 13:20] Snowdrop Short: a 0..1 will either exist or not
exists
[2009/02/26 13:20] Snowdrop Short: but there can never be more than
one
[2009/02/26 13:21] Adelle Fitzgerald: so, what happens when there can
be 0, 1 or 2, or more?
[2009/02/26 13:21] Snowdrop Short: and a relationship would have
either two or none
[2009/02/26 13:21] Snowdrop Short: we used a simple "handle" to point
to the spouse
[2009/02/26 13:22] Snowdrop Short: that was ok, because, either there
was "none" or there was "one"
[2009/02/26 13:22] Snowdrop Short: but if you want to have more
[2009/02/26 13:22] Snowdrop Short: you need somekind of a list of
"handles"
[2009/02/26 13:22] Adelle Fitzgerald: so by teh way the program works
it would either use a 0..1 or a relationship depending on what it
was doing?
[2009/02/26 13:23] Snowdrop Short: the way our old program worked
what that a person could have a spouse .. or not
[2009/02/26 13:23] Snowdrop Short: if we created a new program
[2009/02/26 13:23] Adelle Fitzgerald: so the relationship or 0..1 is
defined by our program?
[2009/02/26 13:23] Snowdrop Short: with a class called "relationship"
[2009/02/26 13:23] Snowdrop Short: it would be a 2 or 0 type
connection
[2009/02/26 13:24] Snowdrop Short: that kind of class is special
[2009/02/26 13:24] Snowdrop Short: because it ties two objects
together in an association
[2009/02/26 13:24] Snowdrop Short: the technicla term for such a
class is: "association class"
[2009/02/26 13:25] Snowdrop Short: the interesting thing is
[2009/02/26 13:25] Snowdrop Short: we could have several types of
"relationships"
[2009/02/26 13:25] Snowdrop Short: spouse
[2009/02/26 13:25] Snowdrop Short: friends
[2009/02/26 13:25] Starky Rubble: sibling
[2009/02/26 13:25] Snowdrop Short: children
[2009/02/26 13:25] Snowdrop Short: yes
[2009/02/26 13:25] Snowdrop Short: all sorts
[2009/02/26 13:26] Starky Rubble: members
[2009/02/26 13:26] Snowdrop Short: members
[2009/02/26 13:26] Adelle Fitzgerald: right so 'relationship', '0..1'
and 'association' is the terminology to describe what we are doing
with the program
[2009/02/26 13:26] Snowdrop Short: yes
[2009/02/26 13:26] Adelle Fitzgerald: kk, got it :)
[2009/02/26 13:27] Snowdrop Short: I use the technical words, because
if you go read some teoretical stuff, that's what they use
[2009/02/26 13:27] Starky Rubble: Thats good IMHO thanks!
[2009/02/26 13:28] Snowdrop Short: but some of the names used can be
a little "theoretical"
[2009/02/26 13:28] Adelle Fitzgerald: sometimes, i get confused with
thats terminology and whats actual language, especially as this is
new to me
[2009/02/26 13:28] Snowdrop Short: and difficult
[2009/02/26 13:28] Adelle Fitzgerald: *with whats
[2009/02/26 13:28] Snowdrop Short nods
[2009/02/26 13:29] Snowdrop Short: so I think we should try to
rewrite our little "Person" program
[2009/02/26 13:29] Snowdrop Short: so it can handle our new found
"association class"
[2009/02/26 13:29] Snowdrop Short: the question from me is?
[2009/02/26 13:29] Snowdrop Short: do you want me to present you with
the program in c#
[2009/02/26 13:30] Snowdrop Short: or would you perfer to work on it
your selves?
[2009/02/26 13:30] M1sha Dallin: personally I prefer to study an
example the first time
[2009/02/26 13:30] Starky Rubble: or something a little in between?
[2009/02/26 13:30] M1sha Dallin: else I spend too long looking up the
syntax
[2009/02/26 13:30] Starky Rubble: yes
[2009/02/26 13:31] Adelle Fitzgerald: ill 3rd that
[2009/02/26 13:31] Snowdrop Short: ok
[2009/02/26 13:31] Snowdrop Short: hold on a second... I'll pastebin
[2009/02/26 13:31] Adelle Fitzgerald: kk
[2009/02/26 13:36] Adelle Fitzgerald: its gone quiet..
[2009/02/26 13:36] M1sha Dallin: :-)
[2009/02/26 13:36] Snowdrop Short: sorry about that
[2009/02/26 13:36] Snowdrop Short: a little glitch
[2009/02/26 13:36] Adelle Fitzgerald: its ok, just checking I hadnt
crashed :)
[2009/02/26 13:37] M1sha Dallin: sometimes it is tricky to tell
[2009/02/26 13:37] Snowdrop Short: yes
[2009/02/26 13:37] Snowdrop Short:
http://www.pastebin.ca/1348195
[2009/02/26 13:37] Snowdrop Short: and you never trust OpenSim 100%
[2009/02/26 13:38] Snowdrop Short: that's how that idea looks in c#
[2009/02/26 13:38] Starky Rubble: right
[2009/02/26 13:39] Snowdrop Short: we have a new class "RelationShip"
[2009/02/26 13:39] Snowdrop Short: it's got two handles
[2009/02/26 13:39] Starky Rubble: l & r
[2009/02/26 13:39] Snowdrop Short: I didn't want to call them
"Husband" and "Wife" :-P
[2009/02/26 13:40] Starky Rubble: heh
[2009/02/26 13:40] Starky Rubble: spice/spouse
[2009/02/26 13:40] Snowdrop Short smiles
[2009/02/26 13:40] M1sha Dallin: genericised (is that a word?) the
relationship
[2009/02/26 13:41] Snowdrop Short: now ... you could ask a
philsofical question
[2009/02/26 13:41] Snowdrop Short: is AssingPartner something you do
on a person or on a relationship?
[2009/02/26 13:41] Starky Rubble: hah hah
[2009/02/26 13:41] Snowdrop Short: I don't know really
[2009/02/26 13:41] Starky Rubble: some do
[2009/02/26 13:42] M1sha Dallin: relationship does not exist (in RL)
until there is a partner to add
[2009/02/26 13:42] Snowdrop Short: but the good thing about this is
that we have a guarantee that "AgeDifference" will always work
[2009/02/26 13:42] Starky Rubble: right
[2009/02/26 13:42] Snowdrop Short: so we can simply go to the
relationship and ask it
[2009/02/26 13:43] Snowdrop Short: so this is still a 0..1 one
relationship
[2009/02/26 13:43] Snowdrop Short: but now we've interjected the
"association class"
[2009/02/26 13:43] Snowdrop Short: there is a 0..1 relation ship
between a person and a relationship
[2009/02/26 13:44] Snowdrop Short: it used to be between two persons
[2009/02/26 13:44] Starky Rubble: right
[2009/02/26 13:44] Snowdrop Short: that's all well and fine
[2009/02/26 13:44] Snowdrop Short: have you noticed another thing
[2009/02/26 13:44] Snowdrop Short: most of our methods have very
little code in them
[2009/02/26 13:45] Snowdrop Short: that is a very common thing in c#
[2009/02/26 13:45] Snowdrop Short: most methods are very very simple
[2009/02/26 13:45] Snowdrop Short: often when the code in a method
grows long and complicated, it is a sign that you are not doing it
right
[2009/02/26 13:46] Snowdrop Short: that's when it is time to start
thinking about "refactoring"
[2009/02/26 13:46] Snowdrop Short: meaning making a few new classes,
or maybe re-arrange somethings
[2009/02/26 13:46] Adelle Fitzgerald: for me, a program is nothign
more than math applied to something, and math can be done more than
one
way
[2009/02/26 13:46] Snowdrop Short: there are always many ways to do
it
[2009/02/26 13:47] Snowdrop Short: and it is often impossible to say
"this is the right way"
[2009/02/26 13:47] Adelle Fitzgerald nods
[2009/02/26 13:48] Snowdrop Short: so if we were to extend on that
[2009/02/26 13:48] Adelle Fitzgerald: ok, the thing I dont
understand, or see about that program example is the reference between
the
relationship class and the other classes
[2009/02/26 13:48] Snowdrop Short: in what way?
[2009/02/26 13:48] Snowdrop Short: when you assign a partner
[2009/02/26 13:48] Snowdrop Short: i.e. call "AssignPartner" on a
class
[2009/02/26 13:49] Snowdrop Short: like we do in line 51
[2009/02/26 13:49] Starky Rubble: lets fix that while we're there lol
[2009/02/26 13:49] Snowdrop Short: AssignPartner
[2009/02/26 13:50] Snowdrop Short: operates in the context of the
"Mary" object
[2009/02/26 13:50] Adelle Fitzgerald: oh sorry, i see it now...
[2009/02/26 13:50] Snowdrop Short: it creates a new Relationship
[2009/02/26 13:50] Adelle Fitzgerald: yep, got it
[2009/02/26 13:50] Snowdrop Short: so this refers to the "Mary"
object, and "partner" to the "Paul" object
[2009/02/26 13:51] Snowdrop Short: but this class also demonstrates
one of the beauties of .net/mono
[2009/02/26 13:51] Snowdrop Short: because, we just create a new
object
[2009/02/26 13:51] Snowdrop Short: i.e. we use some memory in the
computer
[2009/02/26 13:52] Snowdrop Short: and assign that to the
"handle" (that's really a java term)
[2009/02/26 13:52] Snowdrop Short: "Spouse"
[2009/02/26 13:52] Snowdrop Short: but what if that person already
was in a relation ship
[2009/02/26 13:52] Snowdrop Short: what would happen?
[2009/02/26 13:52] M1sha Dallin: The 1st would get lost?
[2009/02/26 13:52] Adelle Fitzgerald: it would create a new
relationship, so spouse would have two relationships?
[2009/02/26 13:53] M1sha Dallin: but only one l,r pair
[2009/02/26 13:53] Snowdrop Short: .Net/Mono has something called a
garbage collector
[2009/02/26 13:53] Snowdrop Short: it runs in the background (from
time to time)
[2009/02/26 13:53] Snowdrop Short: and looks for objects which aren't
uses, and then frees that memory
[2009/02/26 13:54] M1sha Dallin: Paul gets dumped
[2009/02/26 13:54] Snowdrop Short: yes .. and now
[2009/02/26 13:54] Snowdrop Short: no, even
[2009/02/26 13:54] Snowdrop Short: it is a bit more complicated in
reality
[2009/02/26 13:54] Snowdrop Short: but think of it this way
[2009/02/26 13:55] Snowdrop Short: the garbage collector looks for
objects, that doesn't have any handles
[2009/02/26 13:55] Adelle Fitzgerald: so wne we use 'new' it dumps
the old
[2009/02/26 13:55] M1sha Dallin: All handles will still exist I think
[2009/02/26 13:55] Adelle Fitzgerald: *when
[2009/02/26 13:56] Snowdrop Short: yes, if there is only one handle,
holding on to the object
[2009/02/26 13:56] M1sha Dallin: p1 and p2
[2009/02/26 13:56] Adelle Fitzgerald: gotcha
[2009/02/26 13:56] Starky Rubble: 0..1
[2009/02/26 13:56] Snowdrop Short: then the garbage collector will
automagicallay clean it up
[2009/02/26 13:57] M1sha Dallin: but if p1 is now in a relationship
with p3 - then p1/p3 are assciated , p2 is stand-alone
[2009/02/26 13:57] Snowdrop Short: that's one of the things I love
with c#, you don't have to worry that much about resource leaks
[2009/02/26 13:57] Starky Rubble: out of curiosity (and knowing it
varies) roughly how often is garbage collected?
[2009/02/26 13:57] Snowdrop Short: usually when the framework detects
that it has either a lot of idle time or when it is running low on
memory
[2009/02/26 13:57] Starky Rubble: ah
[2009/02/26 13:57] Snowdrop Short: or you can force it manually, but
that is not recommended
[2009/02/26 13:58] Starky Rubble: ok
[2009/02/26 13:58] Adelle Fitzgerald: why?
[2009/02/26 13:58] Snowdrop Short: and M1sha your are absolutely
right, we have a problem in the code
[2009/02/26 13:58] Snowdrop Short: with resource leaks
[2009/02/26 13:59] Snowdrop Short: becasue sudden Paul can think he
is a relationship, but in fact Mary might have moved on to Peter
[2009/02/26 13:59] Starky Rubble: happens...
[2009/02/26 13:59] M1sha Dallin: sounds realistic :-(
[2009/02/26 13:59] Snowdrop Short: the internal workings of the
garbage collector, is designed to be left alone
[2009/02/26 14:00] Snowdrop Short: so when you mess with it, you'd
better know what you want of it
[2009/02/26 14:00] Adelle Fitzgerald: ahh right so there is nothing
to just invoke garbage collection
[2009/02/26 14:00] Adelle Fitzgerald: you ahve to set parameters and
stuff?
[2009/02/26 14:00] Snowdrop Short: actually, very few c# developers
really understand the internal workings of the garbage collector
[2009/02/26 14:00] Adelle Fitzgerald: kk
[2009/02/26 14:01] Snowdrop Short: it's pretty easy to do, but it may
have unwanted sideeffects
[2009/02/26 14:01] Starky Rubble: hiding that kind of thing is one of
the points I would think
[2009/02/26 14:01] Snowdrop Short: yes
[2009/02/26 14:01] Snowdrop Short: but we really need to fix the
resource leak we've introduced
[2009/02/26 14:01] Adelle Fitzgerald: yes
[2009/02/26 14:01] Snowdrop Short: because:
[2009/02/26 14:02] Snowdrop Short: 1) the handle "Paul" has prevents
the garbage collector from doing its thing
[2009/02/26 14:02] Snowdrop Short: 2) we're violating and "invariant"
[2009/02/26 14:02] Snowdrop Short: an invariant is something you know
is always true
[2009/02/26 14:02] Starky Rubble: we need to fix AssignPartner
[2009/02/26 14:03] Snowdrop Short: and one thing we assume is that
relationships aren't "messy"
[2009/02/26 14:03] Adelle Fitzgerald: i would think we neet to
deAssignPartner, before a new AssignPartner
[2009/02/26 14:03] Adelle Fitzgerald: *need
[2009/02/26 14:03] Adelle Fitzgerald: or as part of the process of
AssignPartner
[2009/02/26 14:04] M1sha Dallin: deassign the partners partner before
adding th enew
[2009/02/26 14:04] Starky Rubble: right
[2009/02/26 14:04] Snowdrop Short:
http://www.pastebin.ca/1348217
[2009/02/26 14:04] Snowdrop Short: yes, and this is how we do it
[2009/02/26 14:04] Adelle Fitzgerald: ahh
[2009/02/26 14:05] Snowdrop Short: a handle can have a special value
called "null"
[2009/02/26 14:05] Starky Rubble: how do we remove a RelationShip
(that capital S will trip me up)
[2009/02/26 14:05] Adelle Fitzgerald: so both partners are made null
before assigning
[2009/02/26 14:05] Snowdrop Short: meaning, it points nowhere
[2009/02/26 14:05] Adelle Fitzgerald: makes sense
[2009/02/26 14:05] Starky Rubble: figgered
[2009/02/26 14:05] Snowdrop Short: we need to set both to "null"
[2009/02/26 14:05] Snowdrop Short: because we don't know if we're on
the left or the right side of the relationship
[2009/02/26 14:06] Adelle Fitzgerald: gotcha
[2009/02/26 14:06] Snowdrop Short: this way, the old relationship
will be garbage collected, next time the garbage collector runs
[2009/02/26 14:07] Snowdrop Short: it's is one of the few examples
where we need to do something actively to avoid resource leaks
[2009/02/26 14:07] Snowdrop Short: but as you can see, even with a
garbage collector, introducing resource leaks is possble
[2009/02/26 14:07] M1sha Dallin: Would it be cleaner to use a method
in relationship to delete the links, that way person does not need to
know the implementation of the relationship as l and r ?
[2009/02/26 14:08] Snowdrop Short: that is why I asked if setting up
the relationship was someting you did to a person or a relationship
[2009/02/26 14:08] Snowdrop Short: :-)
[2009/02/26 14:08] M1sha Dallin: questions always bite :-)
[2009/02/26 14:08] Snowdrop Short: now we see that it probably should
be in relationship
[2009/02/26 14:09] Snowdrop Short: so we "refactor"
[2009/02/26 14:09] Starky Rubble: right
[2009/02/26 14:11] Snowdrop Short:
http://www.pastebin.ca/1348222
[2009/02/26 14:12] Snowdrop Short: do you notice something very odd
about this implementation?
[2009/02/26 14:12] Starky Rubble: lower l left and upper R Right will
cause trubble later
[2009/02/26 14:13] Snowdrop Short: how so?
[2009/02/26 14:13] Adelle Fitzgerald: Error 2 'Lesson06.RelationShip'
does not contain a definition for 'right' and no extension method
'right' accepting a first argument of type 'Lesson06.RelationShip'
could be found (are you missing a using directive or an assembly
reference?
[2009/02/26 14:13] Starky Rubble: inconsistancies always trip me up
[2009/02/26 14:13] Starky Rubble: also the Spouse
[2009/02/26 14:14] Adelle Fitzgerald: thats what my IDE tells me, so
there is not reference for 'right' and should be 'Right'
[2009/02/26 14:14] Snowdrop Short: always remember to compile :-)
[2009/02/26 14:15] Starky Rubble: is Spouse self-referential?
[2009/02/26 14:15] Snowdrop Short: I had a capital R in rigth
[2009/02/26 14:15] Snowdrop Short:
http://www.pastebin.ca/1348227
[2009/02/26 14:15] Snowdrop Short: case matters :-)
[2009/02/26 14:16] Snowdrop Short: relationship is self referential
[2009/02/26 14:16] Adelle Fitzgerald: so does listening to your
IDE ;)
[2009/02/26 14:16] Snowdrop Short: yes
[2009/02/26 14:17] Snowdrop Short: I was a bit too quick there, sorry
about aht
[2009/02/26 14:17] Snowdrop Short: that, even
[2009/02/26 14:17] Snowdrop Short: notice the way "AssignPartner" is
implemented?
[2009/02/26 14:18] M1sha Dallin: Raises an exception when I run it
[2009/02/26 14:18] Adelle Fitzgerald: right, so it creates a new
object of 'relationship' instead of a relationship between partners?
[2009/02/26 14:19] Snowdrop Short:
http://www.pastebin.ca/1348234
[2009/02/26 14:19] Snowdrop Short: to quote Linus Torwalds
[2009/02/26 14:19] Snowdrop Short: if it compiles it's good
[2009/02/26 14:19] Snowdrop Short: if it runs it is perfect
[2009/02/26 14:19] Snowdrop Short: :-)
[2009/02/26 14:20] Snowdrop Short: it simply creates a new
relationship object
[2009/02/26 14:20] Snowdrop Short: usually you assign the new object
to some handle
[2009/02/26 14:20] Snowdrop Short: but not in this case
[2009/02/26 14:21] Snowdrop Short: because it knows that Spouse will
be assigned during the creation
[2009/02/26 14:21] Snowdrop Short: that's bad "encapsulation"
[2009/02/26 14:21] Snowdrop Short: and bad form
[2009/02/26 14:22] Snowdrop Short: usually a class is supposed to be
ignorant about what is going on behind the scenes
[2009/02/26 14:23] M1sha Dallin: but an association must know that it
exists to link two other objects?
[2009/02/26 14:23] Snowdrop Short: yes
[2009/02/26 14:23] Snowdrop Short: so how do we solve this problem?
[2009/02/26 14:24] Starky Rubble: create al all purpose obeject maybe
[2009/02/26 14:24] Starky Rubble: an
[2009/02/26 14:24] Snowdrop Short nods
[2009/02/26 14:24] Snowdrop Short: good idea
[2009/02/26 14:25] Starky Rubble: use it and fill it later
[2009/02/26 14:25] Snowdrop Short: that's another solution
[2009/02/26 14:25] Snowdrop Short: I think we can solve this a number
of ways
[2009/02/26 14:25] M1sha Dallin: I think I'd create a relationship
object an pass it the two partners
[2009/02/26 14:25] Snowdrop Short: either we leave it up the the
"Person" to rearrange their relationships
[2009/02/26 14:26] Snowdrop Short: or we leave the person completely
out of it, and allow the relationship to take care of things
[2009/02/26 14:26] Snowdrop Short: either way, right now we have a
hybrid
[2009/02/26 14:26] Snowdrop Short: and thatn't not good
[2009/02/26 14:26] Snowdrop Short: that's not good
[2009/02/26 14:27] Snowdrop Short: I would like to introduce you to
someting called a "static"
[2009/02/26 14:27] Snowdrop Short: that's the term for it in c#
[2009/02/26 14:27] Snowdrop Short: in the litterature it is classed a
classifier
[2009/02/26 14:28] Snowdrop Short: because it is something that
operates on the class and not the object
[2009/02/26 14:29] Snowdrop Short:
http://www.pastebin.ca/1348242
[2009/02/26 14:30] Snowdrop Short: I have introduced a new method on
the "RelationShip" class
[2009/02/26 14:30] Snowdrop Short: notice the keyword "static"
[2009/02/26 14:30] Snowdrop Short: it means that it operates on the
class level
[2009/02/26 14:31] M1sha Dallin: much more readable
[2009/02/26 14:31] Snowdrop Short:
http://www.pastebin.ca/1348246
[2009/02/26 14:32] Snowdrop Short: and here I have removed the old
method on "Person"
[2009/02/26 14:32] Snowdrop Short: notice how in line 61 it says
[2009/02/26 14:32] Snowdrop Short: Relationship.Relate....
[2009/02/26 14:32] Snowdrop Short: because we are operating on a
"static" or a "classifier"
[2009/02/26 14:33] Snowdrop Short: static is the day to day term,
most programmers use
[2009/02/26 14:33] Snowdrop Short: "classifier" is more of a "show
off" term
[2009/02/26 14:34] Starky Rubble: ok
[2009/02/26 14:34] Snowdrop Short: remember the term "this"
[2009/02/26 14:34] M1sha Dallin: yep
[2009/02/26 14:34] Snowdrop Short: it refers to the object we're
current in context of
[2009/02/26 14:34] Snowdrop Short: that keyword is invalid in statics
[2009/02/26 14:34] Starky Rubble: yes
[2009/02/26 14:35] Snowdrop Short: anybody care to guess why?
[2009/02/26 14:35] Starky Rubble: beacuse there is no instance
[2009/02/26 14:35] M1sha Dallin: A static object does not exist
[2009/02/26 14:35] Starky Rubble: necessarilly
[2009/02/26 14:35] Snowdrop Short: exactly
[2009/02/26 14:35] Snowdrop Short: it doesn't really exist, but is
shared between all objects of that class
[2009/02/26 14:36] Starky Rubble: makes sense
[2009/02/26 14:37] Snowdrop Short: some of you have noticed that
almost all types used in c# have operations on them
[2009/02/26 14:37] Snowdrop Short: e.g. int.Parse(....)
[2009/02/26 14:37] Snowdrop Short: Parse is a static method on the
"class" int
[2009/02/26 14:38] Starky Rubble: ok
[2009/02/26 14:38] Snowdrop Short: there is a good reason for putting
quotes around "int", but that's stuff for another day
[2009/02/26 14:38] Snowdrop Short: so, we have covered encapsulation
[2009/02/26 14:38] Snowdrop Short: and 0..1 associations
[2009/02/26 14:39] Snowdrop Short: how would we go about arranging
friends?
[2009/02/26 14:40] Starky Rubble: the relationship would have to be
looser to allow more than one or maybe nione
[2009/02/26 14:40] Starky Rubble: so a different tool... like a list
[2009/02/26 14:40] Snowdrop Short nods
[2009/02/26 14:40] Starky Rubble: might be good
[2009/02/26 14:41] Snowdrop Short: arrays?
[2009/02/26 14:41] Snowdrop Short: list?
[2009/02/26 14:41] Snowdrop Short: vector?
[2009/02/26 14:41] M1sha Dallin: list
[2009/02/26 14:41] Starky Rubble: list
[2009/02/26 14:41] M1sha Dallin: arrays have bounds - usually
[2009/02/26 14:41] M1sha Dallin: relationship will be 0..*
[2009/02/26 14:42] Snowdrop Short: most modern languages have self
extension capabilites
[2009/02/26 14:42] Snowdrop Short: but I'm ok with any
[2009/02/26 14:42] Snowdrop Short: what we need is some kind of a
"container"
[2009/02/26 14:43] Starky Rubble: with add and remove methods
[2009/02/26 14:43] Snowdrop Short: arrays, lists, queue, stacks etc.
all go under the name of "container"
[2009/02/26 14:43] Snowdrop Short: because the can hold handles to
more than one object
[2009/02/26 14:44] Snowdrop Short: in programming, a lot of different
containers are used
[2009/02/26 14:44] Snowdrop Short: because they have different
capabilities
[2009/02/26 14:44] Snowdrop Short: e.g. traditional arrays are very
fast
[2009/02/26 14:44] Snowdrop Short: but not very flexible
[2009/02/26 14:45] Snowdrop Short: queue allow you to let objects
wait "in line" for their turn
[2009/02/26 14:45] Snowdrop Short: etc.
[2009/02/26 14:45] Snowdrop Short: I agree that we need a container
for the friends relationship
[2009/02/26 14:46] Snowdrop Short: but if you looks at our
"RelationShip" class it's specialized
[2009/02/26 14:46] Starky Rubble: yes
[2009/02/26 14:46] Snowdrop Short: it assumes some special properies/
rules exists for that relationship
[2009/02/26 14:46] Starky Rubble: appropriate tho - for the task
[2009/02/26 14:47] Snowdrop Short: so it would seem that we need a
new kind of relation ship
[2009/02/26 14:48] Starky Rubble: bff
[2009/02/26 14:48] Snowdrop Short: called a friend
[2009/02/26 14:48] Snowdrop Short: any suggestions on how to go about
that?
[2009/02/26 14:49] Snowdrop Short: here is my suggestion
[2009/02/26 14:49] Snowdrop Short: each of you try to write a new
"Friend" class
[2009/02/26 14:49] M1sha Dallin: ok
[2009/02/26 14:50] Snowdrop Short: and then well share those on
pastebin next thursday
[2009/02/26 14:50] Snowdrop Short: and we can comment on them
[2009/02/26 14:50] Adelle Fitzgerald nods
[2009/02/26 14:50] Starky Rubble: ok
[2009/02/26 14:50] Snowdrop Short: both the good and the bad
[2009/02/26 14:50] Starky Rubble: and the ugly
[2009/02/26 14:50] Snowdrop Short: always remember the good/bad rule
though
[2009/02/26 14:51] Snowdrop Short: at the most, have 25% bad things
to say :-)
[2009/02/26 14:51] Starky Rubble: heh
[2009/02/26 14:52] Snowdrop Short: people usually pour their heart
and souls into their programs
[2009/02/26 14:52] Snowdrop Short: right .. I think it is about time
for bed for me now
[2009/02/26 14:53] Adelle Fitzgerald: okies
[2009/02/26 14:53] Snowdrop Short: it's midnight here
[2009/02/26 14:53] Starky Rubble: thanks
[2009/02/26 14:53] M1sha Dallin: ok - ty Snowdrop
[2009/02/26 14:53] Adelle Fitzgerald: thanks Snowdrop :)
[2009/02/26 14:53] M1sha Dallin: was good tonight
[2009/02/26 14:53] Snowdrop Short: thank you for listening to me :-)
[2009/02/26 14:53] Starky Rubble: see you soon
[2009/02/26 14:53] Starky Rubble: bye
[2009/02/26 14:53] Adelle Fitzgerald: thanks for teaching us!
[2009/02/26 14:53] Snowdrop Short: see you all
[2009/02/26 14:53] Snowdrop Short: bye
[2009/02/26 14:53] Adelle Fitzgerald: byeee
[2009/02/26 14:53] M1sha Dallin: g'night
[2009/02/26 14:53] Norse Writer: Bye, and thanks for the lesson
http://www.pastebin.ca/1348195
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
left = l;
Right = r;
}
public Person left;
public Person Right;
public TimeSpan AgeDifference()
{
return left.Age-Right.Age;
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
Spouse = new RelationShip(this, partner);
partner.Spouse = Spouse;
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
p1.AssingPartner(p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348217
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
left = l;
Right = r;
}
public Person left;
public Person Right;
public TimeSpan AgeDifference()
{
return left.Age-Right.Age;
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
partner.Spouse.left = null;
partner.Spouse.Right = null;
Spouse = new RelationShip(this, partner);
partner.Spouse = Spouse;
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
p1.AssingPartner(p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348222
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
if(l.Spouse != null)
{
l.Spouse.left = null;
l.Spouse.right = null;
}
if(r.Spouse != null)
{
r.Spouse.left = null;
r.Spouse.right = null;
}
left = l;
Right = r;
}
public Person left;
public Person Right;
public TimeSpan AgeDifference()
{
return left.Age-Right.Age;
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
new RelationShip(this, partner);
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
p1.AssingPartner(p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348227
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
if(l.Spouse != null)
{
l.Spouse.left = null;
l.Spouse.right = null;
}
if(r.Spouse != null)
{
r.Spouse.left = null;
r.Spouse.right = null;
}
left = l;
right = r;
}
public Person left;
public Person right;
public TimeSpan AgeDifference()
{
return left.Age-right.Age;
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
new RelationShip(this, partner);
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
p1.AssingPartner(p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348234
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
if(l.Spouse != null)
{
l.Spouse.left = null;
l.Spouse.right = null;
}
if(r.Spouse != null)
{
r.Spouse.left = null;
r.Spouse.right = null;
}
left = l;
right = r;
left.Spouse = this;
right.Spouse = this;
}
public Person left;
public Person right;
public TimeSpan AgeDifference()
{
return left.Age-right.Age;
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
new RelationShip(this, partner);
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
p1.AssingPartner(p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348242
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
if(l.Spouse != null)
{
l.Spouse.left = null;
l.Spouse.right = null;
}
if(r.Spouse != null)
{
r.Spouse.left = null;
r.Spouse.right = null;
}
left = l;
right = r;
left.Spouse = this;
right.Spouse = this;
}
public Person left;
public Person right;
public TimeSpan AgeDifference()
{
return left.Age-right.Age;
}
public static RelationShip Relate(Person l, Person r)
{
return new RelationShip(l, r);
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
public void AssingPartner(Person partner)
{
new RelationShip(this, partner);
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
RelationShip.Relate(p1, p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}
http://www.pastebin.ca/1348246
using System;
namespace Lesson06
{
public class RelationShip
{
public RelationShip(Person l, Person r)
{
if(l.Spouse != null)
{
l.Spouse.left = null;
l.Spouse.right = null;
}
if(r.Spouse != null)
{
r.Spouse.left = null;
r.Spouse.right = null;
}
left = l;
right = r;
left.Spouse = this;
right.Spouse = this;
}
public Person left;
public Person right;
public TimeSpan AgeDifference()
{
return left.Age-right.Age;
}
public static RelationShip Relate(Person l, Person r)
{
return new RelationShip(l, r);
}
}
public class Person
{
public string Name;
public DateTime Age;
public RelationShip Spouse;
public void Print()
{
Console.WriteLine(Name.ToLower() + " " + Age + "\n" + "Spouse:");
}
}
class main
{
public static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "Mary";
Person p2 = new Person();
p2.Name = "Paul";
RelationShip.Relate(p1, p2);
Console.WriteLine(p1.Spouse.AgeDifference());
}
}
}