Page 1 of 2

OOP tutorial added to the nxSoftware site!

Posted: Mon Feb 02, 2009 12:36 am
by srod
Hi,

just thought I'd let you know that I have just added the first tutorial to the nxSoftware site (in the form of a downloadable zip file).

This one kind of came at me by request and it interested me enough to cobble together a few words lacking in any kind of wisdom! :)

The tutorial aims to show how to use simple OOP techniques using nothing but native Purebasic code (i.e. no pre-processors etc.) It doesn't try to discuss general OOP techniques or program design or convince anyone that they should be using OOP above all other paradigms etc. It is simply intended to show how to implement a basic class in Purebasic etc.

This interested me because I now use OOP in all of my Purebasic programs; finding that PB's simplicity and clarity means that it's basic OOP is, for me at least, very effective and a boon for maintaining my code! :)

For those who use some of my OOP utilities and have studied the code therein, there will be no need at all to look at the tutorial as there will be nothing new in there for you. Ditto for those who have already used OOP in PB for themselves.

I hope it is useful in some way, but apologise in advance if it turns out to be a pile of unlaundered pants! :wink:

Regards.

Stephen.

Re: OOP tutorial added to the nxSoftware site!

Posted: Mon Feb 02, 2009 8:39 am
by eesau
srod wrote:This interested me because I now use OOP in all of my Purebasic programs
I do too, and it has boosted my productivity ten times over. Thanks for the tutorial -- interesting stuff :)

Re: OOP tutorial added to the nxSoftware site!

Posted: Mon Feb 02, 2009 10:47 am
by srod
eesau wrote:
srod wrote:This interested me because I now use OOP in all of my Purebasic programs
I do too, and it has boosted my productivity ten times over. Thanks for the tutorial -- interesting stuff :)
Aye, I would claim a similar boost in productivity simply because OOP forces me to think in far more depth about my program's design etc. Gone are the days of leaping head first into an application only to code myself around the equivalent of a u-bend to then have fangbeast come along and flush the toilet!

In a strange way I am glad that PB has not gone down the OOP path because with things the way they are it is just all so simple and, dare I say it, logical! :)

Posted: Mon Feb 02, 2009 11:04 am
by Mistrel
An excellent tutorial! I've been looking forward to this for a long time. Thank you for sharing. :D

Posted: Mon Feb 02, 2009 12:44 pm
by Kale
Amazing that people are starting to learn more about the benefits of OOP. See, it's not an elitist thing, it really does help. :wink:

Maybe Fred can start to think about PB v5 being fully OOP? :wink:

*Can open ...again* :twisted:

Posted: Mon Feb 02, 2009 1:16 pm
by netmaestro
*Can open ...again*
Hehe, not really such a huge can I guess as long as it would be OOOP - "optional object oriented programming" 8)

Posted: Mon Feb 02, 2009 1:30 pm
by flaith
:D thanks a lot srod

**edit*** inside rectangleclass.pbi, the last line :

Code: Select all

;-VIRTUAL TABLES.

DataSection 
  VTable_RectangleClass: 
    Data.i @RectangleClass_Area()
    Data.i @RectangleClass_Destroy()
    Data.i @RectangleClass_GetLength()
    Data.i @RectangleClass_GetWidth()
    Data.i @RectangleClass_IsSquare()
    Data.i @RectangleClass_LengthOfDiagonal()
    Data.i @RectangleClass_SetLength()
    Data.i @RectangleClass_SetLength()
EndDataSection 
change to

Code: Select all

;-VIRTUAL TABLES.

DataSection 
  VTable_RectangleClass: 
    Data.i @RectangleClass_Area()
    Data.i @RectangleClass_Destroy()
    Data.i @RectangleClass_GetLength()
    Data.i @RectangleClass_GetWidth()
    Data.i @RectangleClass_IsSquare()
    Data.i @RectangleClass_LengthOfDiagonal()
    Data.i @RectangleClass_SetLength()
    Data.i @RectangleClass_SetWidth()
EndDataSection 
:wink:

Posted: Mon Feb 02, 2009 1:52 pm
by srod
Thanks flaith - well spotted! :)

Updated version uploaded.

Posted: Mon Feb 02, 2009 4:51 pm
by Rings
well written, hands up !

Posted: Mon Feb 02, 2009 10:37 pm
by flaith
Now I've got no excuses to make program in OOPB :D

Posted: Tue Feb 03, 2009 2:26 am
by idle
Very nice Srod, that deserves a beer!

Re: OOP tutorial added to the nxSoftware site!

Posted: Tue Feb 03, 2009 3:56 am
by Fangbeast
Gone are the days of leaping head first into an application only to code myself around the equivalent of a u-bend to then have fangbeast come along and flush the toilet!
I would flush it but your head is still stuck firmly down the s-bend!!! Were you fishing for you steaming g-strings again??? :evil: :evil: :twisted: :twisted: :D :D :D :D :D :D :D

Posted: Tue Feb 03, 2009 12:32 pm
by Psych
Thanks ;)

Helped me alot to get my head around it all.

Good job :P

Posted: Fri Feb 06, 2009 6:55 pm
by Amiga5k
So a Pure Object Oriented Program would be called "POOP"!

;)

Russell

Posted: Fri Feb 06, 2009 7:27 pm
by srod
Amiga5k wrote:So a Pure Object Oriented Program would be called "POOP"!

;)

Russell
Now that one is older than I am!!! :)