vsloathe

Persistence...the light comes on. Something clicked. I was rewriting some code to show to our good pal CDC and all of a sudden I had a "duh" moment. It was a function I posted to syndk8 to ping multiple blog search engines, and I decided I'd make it a class. Took me a little bit of time to rehash the whole thing and I uploaded it. Much to my surprise it worked flawlessly with no debugging required - that never happens. Then I totally got it. The way I'd structured the code and the way I could manipulate this new object. Too beautiful for words.

I think I'm getting it Perk.

Sorry for my rambling.

perkiset

Post whatever you want here and let's have a discussion on it.

In '91 I was working with a guy named Ed Snible who took the time to work me through my OO A-Ha moment and it was just a beautiful thing. The whole point of this forum is to repay that gift - and if it's an OO A-Ha more the better.

I'm really pleased for you VS, and for more reasons than just this board Applause

jammaster82

I remember my O-O aHA ... felt like winning at MISSILE COMMAND. Applause

perkiset

Applause Applause

I still use that one you know... did it again for my daughter's high school - they asked me in as a guest speaker for the AP

programming

  class and that's the example I used. Twas great. Betcha I still have that code somewhere... now that I think about it, I believe I ported it to Kylix as well.

I'll look it up and see if I can find it for you Applause

nutballs

Its funny. My ah ha was a little backwards and as a smart ass response to a professor in college. We had to create a game using classes and after much arguing with the professor about how a class does not in itself make a program OO, I did the whole thing in 1 giant ass class. My progam's main was litteraly
Game = new gameclass

That was it.

The prof was pissed but gave me an A anyway.

vsloathe

For reasons I cannot yet mention, I can't post the code here. I expect to be able to in a couple days though. You guys are super.

vsloathe

P.S. I feel bad that I can't post it because I'm inordinately proud of it, but I don't feel as though it would be prudent until certain events transpire.

Suffice it to say I would not want anyone finding it on a public forum and assuming that my real life identity stole the code from my virtual persona.

MISSILE COMMAND!

ha! Don't know if you remember Perk but you told me about that one a couple weeks ago on the phone.

Anyway at risk of sounding dumb, the thing that finally clicked for me was the power of persistence. If I have a function, I can call it with some arguments. Whoop dee doo. When I have a class full of functions relating to that class with properties, I can handle it, manipulate it and use it through the entire "lifespan" of my application. I know, something that should be glaringly obvious, right? I just didn't get it until the other day and when I realized what I was doing I thought it was crazy cool.

perkiset

Actually NBs that's funny for me as well - JM is referencing the fact that I used the old arcade game "Missile Command" as my demonstration for how OO can look. At the highest level, it was literally a game class and you said $game->execute() and that was about it. All the game pieces were classes sitting on a stack that a timer rolled through - the game itself didn't even know what it was doing - it simply took a game object off the stack and said something like $obj->execute() - each game piece had it's own behavior defined but the class hierarichy.

The crowning moment in that demo was when we realize that the game mechanism coulda been Missile command, Asteroids or Space Invaders and nothing about it would change except for the articulation code of the game pieces.

Of course, since I was using those games as examples of OO coding I've just really dated myself as well  Applause

perkiset

quote author=vsloathe link=topic=669.msg4575#msg4575 date=1199134078

P.S. I feel bad that I can't post it because I'm inordinately proud of it, but I don't feel as though it would be prudent until certain events transpire.

Suffice it to say I would not want anyone finding it on a public forum and assuming that my real life identity stole the code from my virtual persona.


You know the vulnerabilities here VS, don't play with fire. We can be proud in absence of the code Applause

nutballs

mine was sperm-wars... LOL
basically a cross between missile command and space invaders, but in a circle defending the egg. Mind you I got an A, but, I ended up in the dean's office to discuss the propriety of of my project choices...

jammaster82

hahah had your guidance counselor only known
you would one day be nutballs... chickens/eggs?

well how about perkiset posts the kylix port of missiles.pas and we can look at that
then at least somebody gets some code.... hahaha

when you immigrate, id love to see it and maybe
a vnc walk through where i am stuck on kylix
install, maybe i have scratched cd or something
and i need a backup. Applause

Tparser is so much cooler than

regular expression

 s.

perkiset

I'll be home in a few days and go see if I can dig it up. the more I think about it the more sure I am about where it is

vsloathe

posted from an

iPhone

 . Perk, I am zoo fishin wasted LOL. Definitely getting an

iphone

  for the wifey.

jammaster82

JOIN  THE

MAC

  TEAM....

    ....TOGETHER YOU CAN RULE THE GALAXY!!!!!......

iPHONE

 z rule they even slip in under my

mac

 
address filter on my router .... cant find it but
neighbor is standing in front of me downloading
off my shit.....

DangerMouse

Even though I've been coding no where near as long as you guys, and I'm still more in the experimental stage I can really empathise with that feeling VS! It's amazing when you build something that 'models' what your trying to achieve elegantly - when everything just slots into place and then even better, you realise that what you have is a generic solution to a problem that can be applied in all sorts of situations. 

Good stuff Applause

DM

nop_90

I think it was in the delphi manual from back when delphi still could only make 16 bit code.
(get perks to dig it up).

For thier OO explanation they give the example of insects (if i remember correctly).
So you make a parent class TInsect (in delphi and later borland builder all class definitions start with letter T(type) a good practice to get into).

parent class TInsect is just for purpose of inheritance. It is not to be used directly

From TInsect you can put basic class methods

class TInsect:
    def moveTo(x,y,z):
    def numberofLegs:
etc

Then you inherit off it like butterfly,ladybug,catipiller etc
For insects that fly you can make another parent class that inherit from TInsect lets say TFlyingInsect and then inherit off that.

OO have very little to do with the language.
Also for the most part "code reuse" is a load of shit also, same can be done with any good library.
The code reuse is something that was made up to sell the idea to managers Applause.
You can make OO in assembler.
Example
The ftplib http://nbpfaus

.net

 /~pfau/ftplib/ writen in C is object oriented.
Notice how when u create a connection it returns a struct, which is then passed to each call.

Biggest weakness of static languages like object pascal (delphi),C++ etc.
Is that in order to do something like app->execute it has to inherit off a common ancestor with a virtual method called "execute".

While with

perl

 ,

python

 ,

php

  etc, the methods are looked up at runtime.
(so you can do all sorts of cool things)
Price ofcourse is in speed (not really an issue with modern processors).

Example:
class Point:
      def __init__(self,x,y): <--- constuctor with 2 class properties x,y
            self.x = x
            self.y = y
      def add(self,other):
            self.x += other.x <---- the object properties x and y are looked up at runtime with dynamic language (basically it is a hash, or dictionary)
            self.y += other.y

So if you have to do lots of calculation with self.x move it into a local variable, then if needs to be updated move back into self.x
(in the case of adding point the cost/complexity of moving into local variable in this case is not worth it, but if you have to do in method 100 caluculations it will be worth it, 1 million calculation it will make big difference) For

python

  you can get mod which will automatically do this for u.

While if you are doing C++/delphi etc
self.x with be a memory location.
self will probably be stored in a register as a memory location.
self.x with me register with an offset which is very fast.
So local variable or using direct it makes no difference.







perkiset

Applause Pretty good Nop - I think that was the Delphi 1 example... and yes, D1 only did 16B as I remember

I'm surrounded by the right people Applause

nop_90

Applause @ perks
All i remember was seeing like tons of articles at the time on how great OO was.
All the amazing things OO could do.
Shit it even could do shit like bring world peace, cure disease etc.
Entire books writen on this subject Applause

But no actual examples on how/what it works.
Thinking back it probably was version 1 of delphi.

Anyway it was a simple 2-3 page example in the manual, with how to do it, not overly complex, but yet it covered all the major principles.
(which leads me to suspect that all those guys who wrote those books/articles had no idea what OO was).
Then came the "religion" wars. Delphi/C++/what ever does not really have OO
Java is OO from design etc. Bad part is I actually bought into that shit.

Anyway as vsloathe showed good design /

programming

  habits lower develpment time etc, because of less need for debugging.


Perkiset's Place Home   Politics @ Perkiset's