I use classes when it makes sense from a readability point of view. Whenever I find myself writing a bunch of functions that are related, take in similar or same inputs (i.e. a bunch of related functions all depending on similar variables) then I think you can move this to a class.
This allows you to group your functions together, and reduce or eliminate the arguments they take, as they can use properties set by the constructor.
You can achieve exactly the same by not using a class. You can write lots of functions in a module, or simulate a class behaviour with a closure. You can always get the same result by not writing classes, but I would challenge if they are as readable as a simple class.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I use classes when it makes sense from a readability point of view. Whenever I find myself writing a bunch of functions that are related, take in similar or same inputs (i.e. a bunch of related functions all depending on similar variables) then I think you can move this to a class.
This allows you to group your functions together, and reduce or eliminate the arguments they take, as they can use properties set by the constructor.
You can achieve exactly the same by not using a class. You can write lots of functions in a module, or simulate a class behaviour with a closure. You can always get the same result by not writing classes, but I would challenge if they are as readable as a simple class.