PHP PHP -OO or Functional for speed/ knowledge demonstration?

AI Thread Summary
The discussion centers on the choice between procedural programming and object-oriented programming (OOP) in PHP for a competition project. The developer is considering using OOP to demonstrate knowledge of the language, despite concerns about increased code length and potential performance issues. Feedback suggests that OOP may not be necessary for this specific project, as it lacks complexity that would benefit from OOP features like polymorphism or inheritance. It is noted that procedural code could be more efficient and concise, especially for a project under 200 lines. Additionally, using regular expressions for validation is recommended as a way to keep the code tight without the overhead of OOP. Overall, the consensus leans towards sticking with procedural programming for this particular application.
jgg
Messages
40
Reaction score
0
My second PHP question this week...:smile:

I'm writing a PHP app which includes things such as form validation and database interaction. So far, almost everything has been written procedurally. However, I started playing around with PHP's OO stuff, and it's cool. Problem is, this app is being submitted for a competition, and it's graded both on speed and how well I know the language. It would make me seem more 'knowledgeable' (I think) if I broke everything up into object, but on the other hand it requires more lines of code than doing it procedurally. So which should I go with? I hear that OO is slower (and thinking about it this makes sense), however I wanted verification.
 
Technology news on Phys.org
...allow me to add the program will barely reach 200 lines (counting comments, not counting HTML code), if even that.
 
You're project doesn't seem like it need the to be OOP, because design wise you don't have anything to gain from using OOP. Don't get me wrong OOP is nice, but it is a waste if it doesn't clean up your code, or use OOP features like polymorphism or inheritance. If you are trying to make you code tight the best way to do that it to avoid clauses on validation and use regular expressions instead.

I programmed in PHP for a few years, there was only one case that it was really convient to use classes.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top