PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Aug 22, 2019 3:10 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Jul 11, 2013 11:53 am 
Offline
Forum Newbie

Joined: Wed Jul 10, 2013 6:26 am
Posts: 5
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?


Top
 Profile  
 
PostPosted: Thu Jul 11, 2013 12:41 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
Same reason you would want to learn to drive on surface roads before you go onto the highway: solid foundations.


Top
 Profile  
 
PostPosted: Thu Jul 11, 2013 1:14 pm 
Offline
Forum Newbie

Joined: Wed Jul 10, 2013 6:26 am
Posts: 5
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?


Top
 Profile  
 
PostPosted: Thu Jul 11, 2013 1:22 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
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.


Top
 Profile  
 
PostPosted: Thu Jul 11, 2013 4:06 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
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

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat Jul 13, 2013 6:48 am 
Offline
Forum Newbie

Joined: Wed Jul 10, 2013 6:26 am
Posts: 5
Thanks Christopher

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

This view seems hard to find.


Top
 Profile  
 
PostPosted: Sat Jul 13, 2013 10:49 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat Jul 13, 2013 7:18 pm 
Offline
Forum Contributor
User avatar

Joined: Wed Apr 14, 2010 4:45 pm
Posts: 375
Location: UK


Top
 Profile  
 
PostPosted: Sun Jul 28, 2013 5:06 pm 
Offline
Forum Commoner
User avatar

Joined: Thu Dec 15, 2011 2:40 pm
Posts: 85
Location: Nelson, NZ


Top
 Profile  
 
PostPosted: Wed Oct 23, 2013 1:55 pm 
Offline
DevNet Resident
User avatar

Joined: Sat Jun 08, 2002 1:24 pm
Posts: 1207
Location: Florida
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group