OO concepts

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: OO concepts

Post by Eran »

I pay a contractor to build my house. Whether he is the architect, or hires that architect or I bring the architect it makes no real difference.

Software development is not exactly like building houses, in that we do a lot of grunt work in addition to the design. And design is code as well.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: OO concepts

Post by VladSun »

VladSun wrote:
pytrin wrote:I still hold the opinion that complete beginners (as the OP claims to be) should get familiar with the basics of structured programming before jumping into OOP, design patterns and higher level concepts. You need a learning curve for programming like anything else.
I'm not sure it's true. I started programming with Procedural Programming and when the moment of going to OOP had come I had many difficulties to understand why I should use it. I can remember some of my arguments (C/C++):

- an object is simply a structure with function pointers;
- methods are just functions with "this" always passed as an argument to them;
- my "methods" in my structure are always virtual - one can always assign a new pointer to a function in a instance;
- .... etc.

OOP and PP have too different approaches for solving a problem (the whole one, not just parts of it).
Indeed, I switched from PP to OOP only because my friends told me it was better. I did this only because I trusted them, not because I was convinced it was so. After a few months learning and working with Turbo Vision (Turbo Pascal 6.0 With Objects) I gradually convinced myself it was the right way :) (In fact, I was very proud of my Visual TurboVision Editor - there was no such thing on the market :) ).

Then in the university, first course, the C/C++ teacher had to start from programming basics - PP programming again. He gave us a task as an exam - to build a relatively complex software without using the OOP libraries or any OOP (I mean - without even using the keyword "class"). It had to have menus, windows, dialogs, etc (text mode). I had to work with video memory instead of using library functions.

Again, I think it was not a good approach for learning programming. While I had seen OOP, most of the other students had not. And building such a complex software with PP made them thinking the PP way.

It's interesting that I (intentionally) tried to build my OOP-like framework with structures and pointers to functions. I even implemented some inheritance like features. Well, I succeeded building it, but it was very hard.

In fact, this was the moment I was able to see how different PP and OOP could be :)

So, if I had to start learning programming now, I would have preferred to start with pure OOP language like Java,
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: OO concepts

Post by alex.barylski »

Again, I think it was not good approach for learning programming. While I had seen OOP, most of the other students had not. And building such a complex software with PP made them thinking the PP way.
That is why I have always thought post-secondary programming courses/certifications were something of a joke. Yes you can learn some interesting things in computer science but most of what they teach you is strictly from a scientific perspective, but learning more about the business of software would do developers far greater good.

XP, Agile, Design patterns, etc...I have seen very few ciriculum follow this...if anything they usually only introduce developers to the concepts and then go right back to focusing on algorithms and basically studying and implementing things like Longest Common Sub-sequence, etc.

I ask myself now, why would I need to learn or know how Longest Common Sub-Sequence or Huffman compression works, when as a developer I can just find a third party library that does it for me?

From an engineering perspective, it makes sense to teach the student how to think about problem solving at a finite level, thus adavanced algorithms. Unfrotunately I would say 90% of developer jobs are not focused around problem solving at this level (unless you land a gig with google). Instead programmers would be better off learning about the business of software, RAD, open source, methodologies, etc.
It's interesting that I (intentionally) tried to build my OOP-like framework with structures and pointers to functions. I even implemented some inheritance like features. Well, I succeeded building it, but it was very hard.
Gtk+ from what I remember is implemented using C but adheres to some OO practices and principles.

In C/C++ especially, when you have exceptions and RTTI when using objects. It's runtime type information and virtual functions that really make OOP what it is (true polymorphic programming) but that distinction is almost non-existant in PHP as your intrinsically given RTTI, etc by virtue of being a dynamically typed language/interpreted environment.

http://api.drupal.org/api/file/develope ... oop.html/7

The section on polymorphism is interesting.
this is directly analogous to having the class of an object determine its behavior when a message is sent to it. Drupal itself handles the same introspection tasks required of an OOP language's runtime library.
Perhaps, but then why re-invent the wheel? Nodes are quite possibly more than classes, but might include templates and other things which are not easily expressed using objects alone, but the high level concept of polymorphism still applies, so why not take it a step further and make your actual code polymorphic too? If it works at a higher level, why doesn't it work at a lower level as well?

I'm not ctually asking anyone, I'm just saying, polymorphism is obviously a natural solution to a problem, so much so, Drupal has emulated the behavior, but as I understand at one layer/level higher than brick and mortar classes.
So, if I had to start learning programming now, I would have preferred to start with pure OOP language like Java,
While it makes little sense these days to write anything in assembler, I don't nessecarily consider the experience a total waste. Certainly it taught some practices which would be considered bad these days, and in some cases totally futile (ie: bitshift for division/multliplcation by factors of two) like any experience, it's given me a certain appreciation for low level architecture that I otherwise wouldn't have.

That being said, I don't regret learning C/C++ and/or even ASM...procedural and/or OOP. I do however regret wasting time learning Cobol, Pascal and other vertical market languages which did nothing but introduce me to a different syntax. Learning a different paradigm on the other hand, was a good experience.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: OO concepts

Post by VladSun »

PCSpectra wrote:I ask myself now, why would I need to learn or know how Longest Common Sub-Sequence or Huffman compression works, when as a developer I can just find a third party library that does it for me?
It's good to know the algorithms at abstract level (i.e. not implemented in some particular programming languages) because it will help you solve similar problems.
PCSpectra wrote:
So, if I had to start learning programming now, I would have preferred to start with pure OOP language like Java,
While it makes little sense these days to write anything in assembler, I don't necessarily consider the experience a total waste. Certainly it taught some practices which would be considered bad these days, and in some cases totally futile (ie: bitshift for division/multiplication by factors of two) like any experience, it's given me a certain appreciation for low level architecture that I otherwise wouldn't have.

That being said, I don't regret learning C/C++ and/or even ASM...procedural and/or OOP. I do however regret wasting time learning Cobol, Pascal and other vertical market languages which did nothing but introduce me to a different syntax. Learning a different paradigm on the other hand, was a good experience.
I think that I'll be misunderstood here. I'm not saying that people should not learn the basics of computers (i.e. boolean algebra, PC architecture, etc.) - I even think that they must. I'm just saying that going from PP to OOP is a way harder than the opposite. And from that point of view I would have preferred starting with the OOP concepts instead of learning the PP implementations.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: OO concepts

Post by alex.barylski »

I'm just saying that going from PP to OOP is a way harder than the opposite
It is harder, yes. Probably because you have OOP zealots who advertise in PP forums about how OOP is great, but the reverse is not usually true, because PP zealots have usually never experienced OOP enough to offer critical arguments in favour of PP, whereas OOP developers usually start in PP and have a better or more clear perspective of both paradigms.

Maybe we should start a revolution and introduce yet another paradigm called: POOP (Procedural Object Oriented Programming) :lol: :lol:

I wonder if that would end flame wars and senseless arguments. :P

Cheers,
Alex
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: OO concepts

Post by Chris Corbyn »

PCSpectra wrote:Maybe we should start a revolution and introduce yet another paradigm called: POOP (Procedural Object Oriented Programming) :lol: :lol:

I wonder if that would end flame wars and senseless arguments. :P

Cheers,
Alex
You see it in terribly written Java code:

[java]class Application {   public static void main(String[] args) {    /* insert mammoth wodge of code here */  } }[/java]

POOP indeed.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: OO concepts

Post by alex.barylski »

main() is a death wish in C as well -- much like index.php with PHP -- it's where the application starts so you might as well keep everything in there 'type mentality' :P
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: OO concepts

Post by Christopher »

PCSpectra wrote:It is harder, yes. Probably because you have OOP zealots who advertise in PP forums about how OOP is great, but the reverse is not usually true, because PP zealots have usually never experienced OOP enough to offer critical arguments in favour of PP, whereas OOP developers usually start in PP and have a better or more clear perspective of both paradigms.
You have unwittingly acknowledged the fact that Procedural is a subset of OOP. It would be impossible to learn OOP and then learn Procedural because you would already know it.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: OO concepts

Post by alex.barylski »

You have unwittingly acknowledged the fact that Procedural is a subset of OOP. It would be impossible to learn OOP and then learn Procedural because you would already know it.
Haha...yes I guess so...to a degree. I can see this going completely off topic if I replied in depth. :P

Technically PP is a subset of OOP, in the case of C and C++ and perhaps PHP. I guess because at the lowest level they both use statements and general constructs, right? But if you look at OOP from a paradigm perspective, I dunno if that same rule applies.

Thinking in objects 'should' change the way you develop software, more focus on keeping things simple, dependency free, and promoting best practices. I guess it's a person to person basis but I tend to think in terms of abstraction when I think OOP whereas I tend to think more algorithm problem solving when working with just functions.

I think as more DSL's are introduced/discovered an object fluent interfaces become more common place, the idea of statements and constructs might slowly disappear and a natural language syntax will take its place. Where we have sentances instead of statements.

Either that, or the next big paradigm will be drag and drop type development where you move around UML type objects in a CAD program and build software in a very abstract manner, completely removing the developer from the picture. I don't imagine that is coming any time soon and we have a ways to go before software is abstract enough to accomplish that task without developer intervention like RAD generators sort of do today.

Perhaps as more and more problem domains are studied, understood and developed, the more specialized software development will become. There will be no general purpose languages like C (except for system development I suppose) instead you'll have languages especially suited for niche vertical markets, which is already happened I realized, but eventually I see it being exclsuive.

Cheers,
Alex
User avatar
sergio-pro
Forum Commoner
Posts: 88
Joined: Sat Dec 27, 2008 12:26 pm

Re: OO concepts

Post by sergio-pro »

Hi

>>Chris Corbyn: Way more often you can see it in a PHP code, smth like:

Code: Select all

 
<html>
<?
PHP code
blablabla 
?>
html code
<?
PHP code
blablabla 
?>
 
Without even defining any own function in a whole damn script. Even not a PP concept in some way :)

>>PCSpectra: There is already a new paradigm: http://www.jetbrains.com/mps/index.html
I cant say it is perspective - due to its complexity. But in some way its a glance in to the future maybe
diG1tY
Forum Newbie
Posts: 17
Joined: Sun Feb 01, 2009 2:50 pm

Re: OO concepts

Post by diG1tY »

PCSpectra wrote:main() is a death wish in C as well -- much like index.php with PHP -- it's where the application starts so you might as well keep everything in there 'type mentality' :P
What do you mean about the index.php in PHP? I didn't get it :?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: OO concepts

Post by Chris Corbyn »

diG1tY wrote:
PCSpectra wrote:main() is a death wish in C as well -- much like index.php with PHP -- it's where the application starts so you might as well keep everything in there 'type mentality' :P
What do you mean about the index.php in PHP? I didn't get it :?
I think he was just stating that many novice developers try to bundle all code into a really massive PHP file rather than making it more modular. In PHP there's no concept of main() (well, not that we need to worry about) like some languages where main() forms the bootstrap for the application.
diG1tY
Forum Newbie
Posts: 17
Joined: Sun Feb 01, 2009 2:50 pm

Re: OO concepts

Post by diG1tY »

So it's better to have an index file, where you include your other files(footer,header, etc.) ?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: OO concepts

Post by Chris Corbyn »

diG1tY wrote:So it's better to have an index file, where you include your other files(footer,header, etc.) ?
I wouldn't personally include the header and footer in my index.php file, but yes many people do.

The index.php should really only serve as an entry point to your web application. Within that file you can look up the code for whatever page has been requested and load that (front controller pattern).

I'm not sure this is the best article on the subject since I haven't read it, it just came out in my Google Search:

http://www.phppatterns.com/docs/design/ ... er_and_php
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: OO concepts

Post by JAB Creations »

Chris Corbyn wrote:I think he was just stating that many novice developers try to bundle all code into a really massive PHP file rather than making it more modular.
diG1tY, see this thread for an example of my PHP file system.
Post Reply