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.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
Back
Top