OOP tutorial added to the nxSoftware site!

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

OOP tutorial added to the nxSoftware site!

Post 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.
I may look like a mule, but I'm not a complete ass.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: OOP tutorial added to the nxSoftware site!

Post 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 :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: OOP tutorial added to the nxSoftware site!

Post 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! :)
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

An excellent tutorial! I've been looking forward to this for a long time. Thank you for sharing. :D
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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:
--Kale

Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8422
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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)
BERESHEIT
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post 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:
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks flaith - well spotted! :)

Updated version uploaded.
I may look like a mule, but I'm not a complete ass.
User avatar
Rings
Moderator
Moderator
Posts: 1427
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

well written, hands up !
SPAMINATOR NR.1
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post by flaith »

Now I've got no excuses to make program in OOPB :D
“Fear is a reaction. Courage is a decision.” - WC
User avatar
idle
Always Here
Always Here
Posts: 5018
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

Very nice Srod, that deserves a beer!
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4746
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: OOP tutorial added to the nxSoftware site!

Post 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
Amateur Radio, D-STAR/VK3HAF
Psych
Enthusiast
Enthusiast
Posts: 228
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post by Psych »

Thanks ;)

Helped me alot to get my head around it all.

Good job :P
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

So a Pure Object Oriented Program would be called "POOP"!

;)

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Amiga5k wrote:So a Pure Object Oriented Program would be called "POOP"!

;)

Russell
Now that one is older than I am!!! :)
I may look like a mule, but I'm not a complete ass.
Post Reply