Static methods vs. plain functions
[email protected] (Simon Dániel)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAL6guK5bbeF-z50mtQRORcfjatJtwTziA3C9yEepDjTEbo=Xfg@mail.gmail.com> |
Hi, I am working on an OOP project, and cannot decide which way to follow when I have to write a simple function. For example, I want to write a function which generates a random string. In an OOP environtment, it is a matter of course to create a static class and a static method for that. But why? Isn't it more elegant, if I implement such a simple thing as a plain function? Not to mention that a function is more efficient than a class method. So, in object-oriented programming, what is the best practice to implement such a simple function?