PHP -OO or Functional for speed/ knowledge demonstration?

In summary, the conversation discusses the use of procedural versus object-oriented programming in a PHP app. The individual is considering using OOP to make their code appear more knowledgeable, but is concerned about the potential decrease in speed. However, it is mentioned that in this particular project, there may not be much benefit to using OOP and it may be more efficient to stick with procedural programming. Additionally, it is suggested to use regular expressions instead of validation clauses for tighter code. The individual also mentions their previous experience with PHP and how OOP was only useful in one specific case.
  • #1
jgg
40
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
  • #2
...allow me to add the program will barely reach 200 lines (counting comments, not counting HTML code), if even that.
 
  • #3
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.
 

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

1. What is the difference between PHP -OO and Functional programming?

PHP -OO (object-oriented) programming is a programming paradigm that focuses on creating objects and classes to encapsulate data and behavior, while functional programming is a programming paradigm that focuses on writing functions that perform specific tasks without relying on global state or mutating data.

2. Which programming style is faster for PHP -OO or Functional programming?

It is difficult to determine which programming style is faster for PHP -OO or Functional programming as it depends on the specific implementation and optimization of the code. Both styles have their own advantages and disadvantages and can be equally fast when implemented correctly.

3. How does PHP -OO or Functional programming demonstrate knowledge of programming concepts?

PHP -OO or Functional programming demonstrate knowledge of programming concepts by showcasing the ability to think logically, problem solve, and write efficient and organized code. In PHP -OO, knowledge of classes, objects, and inheritance is demonstrated, while in Functional programming, knowledge of higher-order functions, recursion, and immutability is showcased.

4. Which programming style is more commonly used in web development?

PHP -OO is more commonly used in web development as it allows for easier handling of complex web applications and is supported by popular web development frameworks such as Laravel and Symfony. However, Functional programming is gaining popularity in web development due to its ability to handle asynchronous programming and scalability.

5. Can I use a combination of PHP -OO and Functional programming?

Yes, it is possible to use a combination of PHP -OO and Functional programming in a project. This is known as mixed programming and can provide the benefits of both styles, such as the organization and structure of PHP -OO and the efficiency and scalability of Functional programming.

Similar threads

Back
Top