Jump to content


Photo

Object Oriented Programming Or Traditional Coding?


  • Please log in to reply
43 replies to this topic

#1 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 18 November 2012 - 05:42 PM

Hello everybody
I am going to build and design a new website. This is my first experience in making a website. This website is fully dynamic, with online-payment, registration, user ticketing, file upload and file-center exhibition and many more functionalieties.
How should I go to accomplish the job, Object Oriented or Traditional Way of Coding?
I know both of them bu traditional one naturally is easier for me.
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#2 jcbones

jcbones

    Advanced Member

  • Gurus
  • 2,573 posts
  • LocationNorth Carolina

Posted 18 November 2012 - 08:29 PM

It is a matter of opinion, and what you are most comfortable with. If this is a one time thing, or a website that has a small potential for growth, and I didn't have a large class library at my disposal, I would go the traditional (procedural) way, or go with a specific MVC library like cakePHP.

#3 trq

trq

    Advanced Member

  • Administrators
  • 31,035 posts
  • LocationSydney, Australia.

Posted 18 November 2012 - 08:59 PM

I know both of them


Then you should be able to answer this question yourself.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#4 Iluvatar+

Iluvatar+

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts

Posted 19 November 2012 - 05:30 AM

It is in fact a matter of option however the advantages of OOP in my own options are far greater than the out dated un-structured messy procedural approach. My advice to you is take the project into account if it requires an extensive amount of code them OOP way is prob the best root for you for the following reasons...

- Organization
- Reusability
- Flex ability in frontend development (ability to change allot without messing with the data controllers)
- More secure to use public, private and protected methods (php 5 +)
... the list can go on.

If you require a simple sever side solution on an simple website then i see no floor in using a the procedural method

#5 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 19 November 2012 - 06:56 AM

Then you should be able to answer this question yourself.

Consider the fact that you know both rice cooking and egg cooking, which is harder? this goes here. What indeed tempts me to use OOP is its very clean and neat result. My website would probably turn to be a powerful website due to the service it is going to give visitors and customers.
Traditional coding is easier but a chaotic result is what you get compared with clean well-organized OOP. And the reason why I did ask this question was to know other programmers' taste and experience.
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#6 KevinM1

KevinM1

    Snarkimus Prime

  • Moderators
  • 5,243 posts
  • LocationNew Hampshire, USA

Posted 19 November 2012 - 10:05 AM

So, like trq suggested, you were able to answer the question yourself. ;)

Kidding aside, I think the general rule of thumb is that OOP is the way to go for anything that's not trivial. If you can justify the overhead, use it.

#7 Maq

Maq

    Advanced Member

  • Moderators
  • 9,364 posts
  • LocationPennsylvania, USA

Posted 19 November 2012 - 02:51 PM

Take a step back and read the comments you made about each paradigm:

OOP
- powerful
- very clean and well organized
- neat result

Procedural
- Easier


Given the description of the components & features of your website, it doesn't seem like a trivial task and most likely you will be updating & adding to it. I think you can figure out which one suits your situation.

tjmothy

ini_set ("display_errors", "1");
error_reporting(E_ALL);

#8 Hall of Famer

Hall of Famer

    OOP Fanboi

  • Members
  • PipPipPip
  • 315 posts
  • LocationIthaca

Posted 19 November 2012 - 04:52 PM

Of course OOP, unless you are building an amateur fan site. OOP is the standard for quality programming, and since your site actually has online-payment Id say you will need such professionalism. In a perfect script everything is an object. You cannot be perfect, but you can approach as close as you can.

Edited by Hall of Famer, 19 November 2012 - 05:03 PM.

Welcome to the world of OOPHP! In a perfect script, everything is an object. You cannot be perfect, but you can approach as close as can.

zog841.jpg


#9 Pikachu2000

Pikachu2000

    I hate everything.

  • Staff Alumni
  • 11,378 posts
  • LocationFuture Independent Republic of Texas
  • Age:106

Posted 19 November 2012 - 06:00 PM

You still refuse to accept the fact that procedural is not in any way, shape or form, inherently  "amateur", huh? That makes you the true amateur.

Edited by Pikachu2000, 19 November 2012 - 06:11 PM.

"Java" is to "Javascript" about the same as "fun" is to "funeral".

Why $_SERVER['PHP_SELF'] is bad. || Why ORDER BY RAND() is bad || Every problem can be solved with rm -rf *

Random Quote: "

#10 Psycho

Psycho

    Advanced Member

  • Gurus
  • 10,967 posts
  • LocationCanada

Posted 19 November 2012 - 07:33 PM

Here are a couple of quotes from people that no one could accuse of being amateurish:

Paul Graham (co-founder of what become the Yahoo! Store and known for his work on Lisp)

Object-oriented programming generates a lot of what looks like work. Back in the days of fanfold, there was a type of programmer who would only put five or ten lines of code on a page, preceded by twenty lines of elaborately formatted comments. Object-oriented programming is like crack for these people: it lets you incorporate all this scaffolding right into your source code. Something that a Lisp hacker might handle by pushing a symbol onto a list becomes a whole file of classes and methods. So it is a good tool if you want to convince yourself, or someone else, that you are doing a lot of work.


Eric Lippert (principal developer on the C# compiler team)

What I sometimes see when I interview people and review code is symptoms of a disease I call Object Happiness. Object Happy people feel the need to apply principles of OO design to small, trivial, throwaway projects. They invest lots of unnecessary time making pure virtual abstract base classes -- writing programs where IFoos talk to IBars but there is only one implementation of each interface! I suspect that early exposure to OO design principles divorced from any practical context that motivates those principles leads to object happiness. People come away as OO True Believers rather than OO pragmatists.


The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#11 akphidelt2007

akphidelt2007

    Advanced Member

  • Members
  • PipPipPip
  • 154 posts

Posted 19 November 2012 - 08:59 PM

As long as your client is happy it doesn't matter how you write it. BUT, that means if there is a problem in the future and it takes you days to pile through a mess of procedural code than your client probably will not be happy. If you write it neat and tidy and you have good documentation of how the site works than there is nothing wrong with how you write it. Just in my personal experience, OOP makes all the tedious, redundant work easy and let's you get to the meat of the code and all the fun stuff right away... which also greatly improves your efficiency.

#12 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 19 November 2012 - 11:28 PM

Take a step back and read the comments you made about each paradigm:



Given the description of the components & features of your website, it doesn't seem like a trivial task and most likely you will be updating & adding to it. I think you can figure out which one suits your situation.

Yes exactly...But read my post, I told this is my first web experience..so it means that I want to know more about methods being employed these days


akphidelt2007

That is my own web and I am going to establish a CMS.
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#13 Hall of Famer

Hall of Famer

    OOP Fanboi

  • Members
  • PipPipPip
  • 315 posts
  • LocationIthaca

Posted 20 November 2012 - 12:16 AM

Yes exactly...But read my post, I told this is my first web experience..so it means that I want to know more about methods being employed these days


akphidelt2007

That is my own web and I am going to establish a CMS.


Well if this is your first time into web development, you'd probably want to start off with procedural programming unless you really know what you are doing with PHP. I do recommend you to learn OOP while developing your site, since it is one huge step for amateurs to turn into professionals. Someday you may want to go full OO once you are good at it, and that your site gets bigger and more complex. Good luck, theres always enough to learn in the world of programming.

Edited by Hall of Famer, 20 November 2012 - 12:17 AM.

Welcome to the world of OOPHP! In a perfect script, everything is an object. You cannot be perfect, but you can approach as close as can.

zog841.jpg


#14 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 20 November 2012 - 12:36 AM

I'm amateur in PHP but not in Programming. I'm programmer in MEL script, a branch of C++ in Animation and Visual Effects. Now I have no problem in using OOP in my project, that's the reason I asked it. Thanks
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#15 Hall of Famer

Hall of Famer

    OOP Fanboi

  • Members
  • PipPipPip
  • 315 posts
  • LocationIthaca

Posted 20 November 2012 - 12:47 AM

I'm amateur in PHP but not in Programming. I'm programmer in MEL script, a branch of C++ in Animation and Visual Effects. Now I have no problem in using OOP in my project, that's the reason I asked it. Thanks


No worries, if so I am more than certain that you should be using OOP, a non-amateur programmer should be fine with OOP and should stick to it. PHP is much more similar to Java and C#, although C++ is not that much different. Can be a bit tricky if you are so used to using friend classes/properties/methods though.

Edited by Hall of Famer, 20 November 2012 - 12:48 AM.

Welcome to the world of OOPHP! In a perfect script, everything is an object. You cannot be perfect, but you can approach as close as can.

zog841.jpg


#16 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 20 November 2012 - 04:00 AM

SO WELCOME OOP
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#17 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 20 November 2012 - 04:58 AM

I wouldn't put too much stock in Hall of Famer's posts when it comes to OOP vs anything, as some others have hinted towards above. Just so you know.

Personally I prefer a mixture of procedural and OOP. The two methods have their own set of benefits and detractions, after all.
Procedural is perfect for small and simple tasks that (might) needs to be repeated, where you don't really need to group a whole lot of logic together. Like validating user input, for example. OOP, on the other hand, is great when you have complex tasks with a lot of associated logic. As a couple of examples you have template engines, database interaction, and similar stuff.

However, the most important factors are planning and organisation. No matter which coding style you prefer. :)
Keeping it simple.

#18 mostafatalebi

mostafatalebi

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts

Posted 20 November 2012 - 07:50 AM

I wouldn't put too much stock in Hall of Famer's posts when it comes to OOP vs anything, as some others have hinted towards above. Just so you know.

Personally I prefer a mixture of procedural and OOP. The two methods have their own set of benefits and detractions, after all.
Procedural is perfect for small and simple tasks that (might) needs to be repeated, where you don't really need to group a whole lot of logic together. Like validating user input, for example. OOP, on the other hand, is great when you have complex tasks with a lot of associated logic. As a couple of examples you have template engines, database interaction, and similar stuff.

However, the most important factors are planning and organization. No matter which coding style you prefer. :)

As most parts in Computer Science, techniques complete their tasks but not similar to each other!
I can code my site traditionally since basically it has user authentication of two types: customer, translator. And just a file upload for customer and file download for translator and vice verse, but the fact is that within a month or two significant features would be incorporated into the site that needs a highly organized foundation. Such as commercial dictionary, direct chatting with administrator, custom dictionaries, adding-word to the dictionary and many more features...all of them after a year would turn to make a super-functional site in translation services.
Visual Effects Programming

Autodesk Maya, Autodesk Mudbox, Nvidia Mental Images Mental Ray, Adobe Photoshop, Adobe Illustrator, Adobe After Effects, CorelDraw

#19 Iluvatar+

Iluvatar+

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts

Posted 20 November 2012 - 09:15 AM

If you ask for an opinion you’re going to get an opinion and most likely a justification. You have stated you’re a programmer who is competent in both methods of development therefore you should know the pros and cons of both.
If you are unaware of the pros and cons take these options and justifications as good advice from people who do understand the vast difference between the two methods.

#20 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 20 November 2012 - 10:11 AM

To be perfectly honest, I'd probably use both. If the shoe fit's, so to speak. I don't think, personaly, it is always in the overall best interests to hold vehemently to a single paradigm unless the language its self forces you to. I have found it quite convenient in the past to mix both OO and Procedural into a single application.
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com