markjaquith / feedback

Ask @markjaquith anything!
42 stars 4 forks source link

Mixing Object Oriented Programming & Functional Programming #32

Closed MickeyKay closed 8 years ago

MickeyKay commented 9 years ago

What are your thoughts on best practices for mixing OOP and functional programming in projects? As a newcomer to OOP still trying to learn best practices, I was operating under the impression that if I'm going to create an OOP, pretty much every bit of functionality should exist within an object.

Lately, however, I've come across various plugins that mix a foundation built on classes with various files that contain functions outside of any object scope. Can you speak to reasons for mixing like this, instead of just enclosing the functions within a utility class or something of the sort? Any insights? Thanks!

markjaquith commented 8 years ago

I would generally just enclose things inside an object, just for encapsulation, reduction of global symbols, and shorter method names. $this->get() reads better than my_awesome_plugin_get().