Goodbye OOP
Re: Goodbye OOP
I'd like to confirm that it's a difference if You code in a team with various knowledge or do code on Your own or inhouse in a very small team.
And I can confirm that I have mainly seen coders using intellisense with no idea what's involved behind or even what a class or a method is; of course inheritance was not known.
But when I put it down to "organizing code" then I see not very many patterns/ideas to organize procedural code so it can be maintained a long time.
(At the same time, patterns in OOP only repair the annoying things of OOP...)
Any hints for "organizing procedural programs"?
And I can confirm that I have mainly seen coders using intellisense with no idea what's involved behind or even what a class or a method is; of course inheritance was not known.
But when I put it down to "organizing code" then I see not very many patterns/ideas to organize procedural code so it can be maintained a long time.
(At the same time, patterns in OOP only repair the annoying things of OOP...)
Any hints for "organizing procedural programs"?
Re: Goodbye OOP
Brian Will did some good videos on the matter.
The title is a bit clickbaity, but the content is good. He actualy supplies real world examples that he converts from OOP and makes them smaller and easier to read.
https://www.youtube.com/playlist?list=P ... nyDSvAqNJJ
The title is a bit clickbaity, but the content is good. He actualy supplies real world examples that he converts from OOP and makes them smaller and easier to read.
https://www.youtube.com/playlist?list=P ... nyDSvAqNJJ
Re: Goodbye OOP
The one that's defined in jackrabbit, as I said.Shield wrote:Code: Select all
animal.eat(); // Which eat should be called, the one from Rabbit or the one from Antelope?
If you use my code, it gets resolved? What's the issue?
Normally, you can overwrite functions of an inherited class.
I do think that this is valid code in many languages:
Code: Select all
class parent{
function eat(){print 'parent is eating';}
function sleeo(print 'parent is sleeping';)
}
class child extends parent{
function eat(print 'child is eating';)
}
obj= new child();
obj->eat(); //child is eating
obj->sleep(); //parent is sleeping
If however, your jackrabbit inherits from animal as well as the parent animals, your code is bad and animal contains too many functions, or the rabbit and antelope do not properly overwrite them.
And I do not know why you think that this is god or even valid code:
Code: Select all
class_A obj_A = new class_A();
class_B obj_B = obj_A;
Welcome to Javascript
Re: Goodbye OOP
There are lot of ways, but I like the most "logical separation" doing it through code folding.HanPBF wrote: Any hints for "organizing procedural programs"?
There are so called 'regions' in C#, and that's the idea I've adopted for this. In PB similar can be done using ";{" and ";}" to hide whole regions of code.
For example, that's how main file of my game is looking using concept of regions:
http://rgho.st/7wNHrYSVH
The 'regions' of course can be nested too and so on + additional folding is provided by other PB keywords like "if", "for", "select", "procedure"...
Cool & simple, just unfold what you need and edit it not seeing anything else. For me the result of it is very clear and I never encountered problems with code organized such way (I'm working on that game code almost one year already and total its size is large enough, also for this time I wrote lot of other stuff organized the same).
But of course only that is not enough to not drown in long-term perspective. Important parts of the game are separated from others into "subsystems", and they are isolated classes by fact. One subsystem can store local pointer to instance of another [that pointer is received only through subsystem init procedure] and then access its properties by that pointer (there are also additional rules to how they can be accessed). To use other subsystem functions, instance pointer is not needed - I'm just declaring required functions (some internal subsystem code cannot be called such way from another subsystem).
That's all also clear enough and similar is used in large projects on C, so I call it "OOP in C style".
Same can be done using Purebasic modules, which are very close to a classes and truly isolating code (not only "logically"), but I still didn't found a valuable reason to use them - they requiring to be declared, UseModule(), etc, which is additional bureaucracy.
Also subsystems of course are placed in different source files, and all is joined to a project. But all their headers/structures I'm gathering into a single declare file (such also used in C projects, for example lib Leptonica provides only one but very large file "allheaders.h" ^^ which is generally much better that 1000 small files trashing project folders).
Within this file (and basically any other file) also regions are used to organize code the most efficiently (for example, separated region are defined for every subsystem).
In total, the base of my code organization is code folding, and some rules I'm always keeping on, when writing something larger than script-like stuff in only one source file (and also some rules about code documentation, used notations, etc).
You of course should find your own way (in meditation ^^), which will be really better for you.
After all It is fact for me, that procedural code is clearer and is less boring and time-wasting to organize it well, than to write code in OOP languages.
At least, that is fully true when working with PB and it's IDE ^^ (which however lacks several important functions, like "go to definition/declaration", but that's another talk). For C it depends on IDE mainly. I'm not writing much own things on C and have no formed strategy to organize C code, just sometimes learning how others are doing that in large stuff.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: Goodbye OOP
Regarding the diamond problem, consider this:
https://en.wikipedia.org/wiki/Virtual_inheritance
Edit: and yes, diamond structures are almost always a bad idea and indicate a flaw in the design.
This is a fundamental mechanic in OOP languages.
https://en.wikipedia.org/wiki/Virtual_inheritance
Edit: and yes, diamond structures are almost always a bad idea and indicate a flaw in the design.
As I mentioned before, https://en.wikipedia.org/wiki/Liskov_su ... _principleDerren wrote: And I do not know why you think that this is god or even valid code:Code: Select all
class_A obj_A = new class_A(); class_B obj_B = obj_A;
This is a fundamental mechanic in OOP languages.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: Goodbye OOP
Rust is commonly considered a next-gen language or even the programming language to replace all programming languages because it solves so many security and optimization problems transparently and has a lot of developers. It's OOP.
The truth hurts.
Re: Goodbye OOP
From what i read, Rust is multi-paradigm, not just OOP.tj1010 wrote:Rust is commonly considered a next-gen language or even the programming language to replace all programming languages because it solves so many security and optimization problems transparently and has a lot of developers. It's OOP.
However i didnt tried it out yet.
Re: Goodbye OOP
To continue a bit with OOP - here is some real world project I've received today to "fix" it.
By description it takes video and sends it to web-service for analysis, then displays and stores results of analysis.
And as can be seen from sources, it is written in C++ using that qt, widely popular within monkeys nowadays.
Also obviously, that's not even a big project, kind of qt helloworld using prepared frameworks.
As was expected, I've refused from it, after wasting 30 min trying to understand just HOW IT WORKS. I said that man that code is just damn poor and let he throw it back to one who written it.
But a minute later I remembered this thread and it became interesting for me to post code here for fun. How much can YOU understand from that typical product from average OOP-monkey , written fully in OOP with "true expressive power"? ^^
@Shield
http://rgho.st/7Xc2F2mM6
I can surely say the code of same [bad] quality written in C (or especially in PB, which is SO MUCH easier) is about 100 times clearer, even if read it in notepad++, lol.
By description it takes video and sends it to web-service for analysis, then displays and stores results of analysis.
And as can be seen from sources, it is written in C++ using that qt, widely popular within monkeys nowadays.
Also obviously, that's not even a big project, kind of qt helloworld using prepared frameworks.
As was expected, I've refused from it, after wasting 30 min trying to understand just HOW IT WORKS. I said that man that code is just damn poor and let he throw it back to one who written it.
But a minute later I remembered this thread and it became interesting for me to post code here for fun. How much can YOU understand from that typical product from average OOP-monkey , written fully in OOP with "true expressive power"? ^^
@Shield
http://rgho.st/7Xc2F2mM6
I can surely say the code of same [bad] quality written in C (or especially in PB, which is SO MUCH easier) is about 100 times clearer, even if read it in notepad++, lol.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: Goodbye OOP
As have been said about many languages before it.tj1010 wrote:Rust is commonly considered a next-gen language or even the programming language to replace all programming languages...
Probably the reason behind its massively bloated binaries.tj1010 wrote:It's OOP.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
- the.weavster
- Addict
- Posts: 1537
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Re: Goodbye OOP
Perhaps you could point us monkeys to a procedural equivalent to Qt.Lunasole wrote:And as can be seen from sources, it is written in C++ using that qt, widely popular within monkeys nowadays.
Re: Goodbye OOP
TI-994A wrote:As have been said about many languages before it.tj1010 wrote:Rust is commonly considered a next-gen language or even the programming language to replace all programming languages...
Probably the reason behind its massively bloated binaries.tj1010 wrote:It's OOP.
That was all marketing for abstract languages like Python, .NET, and PHP etc..
All those really addressed was development overhead they don't really differentiate from a poorly coded and built c++ binary performance and security wise.
The truth hurts.
Re: Goodbye OOP
And this language is doing the same thing. It claims zero-cost abstraction, when in reality, that cost is being exacted in the form of huge executables.tj1010 wrote:That was all marketing for abstract languages like Python, .NET, and PHP etc..
All those really addressed was development overhead...
Truly low-level languages don't fall victim to that.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: Goodbye OOP
I don't remember any (except myself sometimes ^^). As I said it is anyway not so hard to deal with procedural code (even if it is extremely bad, uses GOTO operators and so on [but well, massive GOTO labels are TOO MUCH, with them code is really very close to such OOP monkey-code by its logic and architecture]).the.weavster wrote: Perhaps you could point us monkeys to a procedural equivalent to Qt.
Maybe that's because writing some more or less complex project in procedural language requires much more coding experience and knowledges to not shoot off own legs or something else mentioned, so those who are begginer procedural coders, just cannot finish such projects and need more practice to success, thus rarely procedural monkey code can be seen in something "commercial-grade" nowadays.
A kind of fool protection, which differs from OOP fool protection greatly, as OOP easily lets any fool to become successful fool by automatically fixing lack of experience and skill, allowing code to be done and formally finished, until someone has to work with that code and call author codemonkey.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: Goodbye OOP
In all honesty, both paradigms have their strong suits.Lunasole wrote:...it is anyway not so hard to deal with procedural code...
...OOP easily lets any fool to become successful fool...
While I am partial to the imperative/procedural architecture, there are times when a well-designed class could be a real boon. But objectivating every conceivable task is simply overkill, unproductive, and even inefficient.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: Goodbye OOP
@TI-994A, exactly. What you said is like an "epilogue" to all I've written before ^^
(if not talk more about codemonkeys, of course :3)
(if not talk more about codemonkeys, of course :3)
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"