PHP Developers Network
http://forums.devnetwork.net/

Why not learn OOP before Procedural?
http://forums.devnetwork.net/viewtopic.php?f=19&t=138081
Page 1 of 1

Author:  dazzy [ Thu Jul 11, 2013 11:53 am ]
Post subject:  Why not learn OOP before Procedural?

Hi

I am learning php and see that most beginner tutorials and books start with procedural programming.

After looking at OOP I am thinking why not just delve into OOB before messing around with procedural programming if OOP will be the eventual goal?

Would it not be better to just go straight into Object Oriented Programming from the start?


Any thoughts on this?

Author:  requinix [ Thu Jul 11, 2013 12:41 pm ]
Post subject:  Re: Why not learn OOP before Procedural?

Same reason you would want to learn to drive on surface roads before you go onto the highway: solid foundations.

Author:  dazzy [ Thu Jul 11, 2013 1:14 pm ]
Post subject:  Re: Why not learn OOP before Procedural?

Still doesn't really answer my question

Is it not possible to learn the solid foundations while using classes and objects?

For example if i call a function inside of a class assigned through a made object rather than just a function on it's own(procedural style). Would it not be better to start learning this way?

Am i missing something here?

Author:  requinix [ Thu Jul 11, 2013 1:22 pm ]
Post subject:  Re: Why not learn OOP before Procedural?

It is, but you're going to be spending most of your effort learning OOP.

I'm not saying you can't do it but that I, personally, would rather people had a solid foundation in procedural PHP before they went off and learned PHP+OOP. Because at some point you're writing procedural/linear code and if you don't know how to do that well enough you'll be writing weird OOP code.

Author:  Christopher [ Thu Jul 11, 2013 4:06 pm ]
Post subject:  Re: Why not learn OOP before Procedural?

I think if you understand the history and definitions a little, you will understand why to start with OOP. By "procedural programming" I think you actually talking about a combination of the initial improvements in Imperative Programming -- which are Structured Programming, Procedural Programming and Modular Programming. Imperative Programming is the style we commonly use in which we describe what the program does, instead of the goal. Structured Programming add the common loop and logical constructs to reduce the need for gotos; Procedural Programming added sub-routines with parameters and return values; Modular Programming added packaging concepts. OOP adds classes and opens up a whole world of new concepts and patterns enabled by having objects (data structures plus the code that operates specifically on them). OOP subsumes Structured, Procedural and Modular Programming, so by learning OOP you are learning "procedural programming" (as you called it) as well.

tl;dr Yes

Author:  dazzy [ Sat Jul 13, 2013 6:48 am ]
Post subject:  Re: Why not learn OOP before Procedural?

Thanks Christopher

That was something along the lines what I was thinking but you expressed it much better.

This view seems hard to find.

Author:  Christopher [ Sat Jul 13, 2013 10:49 am ]
Post subject:  Re: Why not learn OOP before Procedural?


Author:  mecha_godzilla [ Sat Jul 13, 2013 7:18 pm ]
Post subject:  Re: Why not learn OOP before Procedural?


Author:  ragax [ Sun Jul 28, 2013 5:06 pm ]
Post subject:  Re: Why not learn OOP before Procedural?


Author:  BDKR [ Wed Oct 23, 2013 1:55 pm ]
Post subject:  Re: Why not learn OOP before Procedural?

I do believe that there is one big potential problem with focusing on OOP early. That is that it seems to encourage a view point that is purely OOP. By that I mean, there are no algorithmic or lower level considerations.

Lego programming! :D

A small example that I saw only yesterday is where the programmer essentially had 4 steps to do for registering a user with a given system. For each step he instantiated a new object that took care of the particulars of that step. That's not really bad if you ask me. However, each object required the same information. What he did in this case was make a request to the data store 4 times for each object for the same data!

:lol:

So in terms of seperation of concerns he was right on the money, but why not just request that data once then pass copies of it (by reference if needed) to each object at instantiation or right after?

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/