r/PHP • • Sep 25 '21

Developing with procedural PHP.

Not all of us are fans of OOP boilerplate and ceremony. PHP is a perfectly fine procedural language and a well-organised procedural codebase can be easier to manage in many ways. So, is anyone developing with procedural PHP beyond single-file scripts?

0 Upvotes

114 comments sorted by

View all comments

5

u/zmitic Sep 25 '21

well-organised procedural codebase can be easier to manage in many ways

To be honest, I doubt you understood the point of OOP. You could put procedural functions in classes and call it OOP but that is not the point of all.

Not all of us are fans of OOP boilerplate and ceremony

This is not a matter of being a fan of something, it is a matter of maintenance and readability. Use some existing library as reference, not those famous and useless class Dog extends Animal examples.

1

u/boringuser1 Sep 26 '21

I've never seen a good example of OOP in production code. Also, never seen anybody like yourself coherently elucidate the philosphical difference between procedural code and OOP. There isn't one.

3

u/[deleted] Sep 26 '21

[removed] — view removed comment

0

u/boringuser1 Sep 26 '21

A philosphical difference. It's an illusory difference.

3

u/[deleted] Sep 26 '21

[removed] — view removed comment

-1

u/boringuser1 Sep 26 '21

It's more than a little irritating that you're calling me a "beginner" when I'm a literal professional developer. It makes me doubt that you are.

3

u/[deleted] Sep 26 '21 edited Sep 26 '21

[removed] — view removed comment

2

u/boringuser1 Sep 26 '21

All programs follow a "procedure". There are no exceptions to this. The notion that there could be a program that doesn't follow a series of steps to carry out goes against basic philosophical logic.

The only difference is that OOP is a methodology that forces loosely favorable procedural conventions. This is more or less not offensive and maybe even acceptable, but to claim that significant, irreplicable advantages are derived from this is wrong. Often, class syntax is overly verbose, has its own conventions syntactically different from the language, and is overloaded with features that good developers don't use.

Yes, OOP in PHP is more or less necessary because the language isn't designed with proper support for other programming patterns. This doesn't mean that OOP is philosophically advantageous, just that the literal class syntax has home field advantage.

If OOP had proper functional support, factory functions are far more intuitive and flexible than class based syntax.