Some notes after my first PureBasic experience

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Some notes after my first PureBasic experience

Post by Lunasole »

I wish to clarify what I think about OOP (maybe this time I'll be able to write my thoughts in english 100% correctly :)) - if using full OOP everywhere, it is very bad. One class inherits another random class which calls some unknown method of other unknown class which calls another class which inherits one more class referenced to 5 more classes, and you getting such a bullshit as result that you only can write you code once and forget about it, cause you'll never more remind or understand how exactly it all works, not even saying about tries to debug it.

But there is another way, implemented in MS Visual Basic.
VB offers 3 main file types used in projects:
.bas - regular files with source code, called "modules". thats like regular ".pb" files
.frm - forms, they have some restrictions but also used for code
.cls - very-very restricted kind of "classes", called "Class Module"

Those .cls are that what I understand as basic and useful level of OOP support, which gives enough advantages, but don't makes so much problems and not causes brain deformation like full OOP usage does in C++.
In other words, those classes in VB6 are exactly just like modules in PB, but they also allow to dynamically create and destroy multiple instances of them each separated from others.

So:
- If you define module Test in PB and need 2 samples of it, you must define Test2 with the same code and stucture or do something other which smells and looks bad taking an inordinate amount of lines
- but after defining class module Test in VB-style, you later just using keyword like "new" to create and use as many separated samples of Test as you want

Over the years I convinced that such minimalistic level of OOP is "enough for all" (I can't describe all the rules of how it works, anyway it is very limited and not allows doing any stupid or confusing OOP mess) and the system MS used in VB6 is just perfect and working perfectly with procedural paradigm also (VB6 is [or was] first of all procedural language with set of low-level abilities which may be accessed using hacks of it runtime library).
That oop system is what I mean when saying about "connecting OOP and procedures".

@Fred, it is interesting what do you thing about such concept of "class modules"? ( of course if you even read this thread after 4 pages of some weird posts 8) )
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Some notes after my first PureBasic experience

Post by c4s »

@Lunasole
Great idea! At first I wrote a direct reply but then I thought creating a separate feature request would be better. So here it is: "Class Modules" (Create Instances of a Module)

A small wish: Before someone feels triggered to reload the anti-OOP cannon or to fish out old quotations, let's keep the general discussion in this thread so that the whole concept of "class modules" can be discussed in a fresh environment (with a non-biased mindset). Thank you. 8)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Some notes after my first PureBasic experience

Post by User_Russian »

Lunasole wrote:In other words, those classes in VB6 are exactly just like modules in PB, but they also allow to dynamically create and destroy multiple instances of them each separated from others.
I suggested this. http://www.purebasic.fr/english/viewtop ... 95#p454795
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Some notes after my first PureBasic experience

Post by HanPBF »

The discussion moves too fast in one direction.

OOP does not mean You definitely have classes.

What is with prototype based OOP?
What about CLOS' multi-methods; an approach I would prefer.


You can not ask for OOP without asking for a type system.
We don't have a type system in PB; we have some numbers, strings and pointers.
And the pointers are typeless.

If PB is changed in whatever "OOP" direction it will become a mess in a very short time.

Instantiation of a module?
Take a concept used for a little modularization, call it class and make it somehow "instantiable"... Sounds not very far thought for me...

For me the worst problem with OOP is the (needed) use of a hierarchy.
MyApp.Users.sort.up
Users.of.MyApp.sort.up
sort.up.MyApps.Users

The "Me" namespace in VB.Net is showing the problem with large, hierarchical structures.
Post Reply