Hi, first, sorry for the bad English.

Yes, at least, as far as I know, this is the perfect way to do what you
want to do. Think like this: when you instanciate a class, you are
allocating memory. If you don't need any information stored, then you don't
need to allocate memory, right? So, it's is logic to have a class that you
will call only one fragment when you need it, rather than load the entire
class just for one method.

Just be careful to organize your utility methods by by meaning. Don't put a
method that make dating stuff and a method that write a random string in
the same class. By doing so, you are breaking the object orientation
purpose.


2013/9/4 Micky Hulse <mickyhulse.li...@gmail.com>

> Hi all!
>
> Example code:
>
> <https://gist.github.com/mhulse/6441525>
>
> Goal:
>
> I want to have a "utility" class that contain utility methods which should
> have the option of being called multiple times on a page.
>
> I think my main goal is to avoid having to "new" things ... I don't really
> need to create an instance here (there's no need for a constructor in this
> case).
>
> Question:
>
> Is the above simple pattern a good way to have a class that calls static
> methods?
>
> To put it another way, is there any reason why I would not want to use the
> above code?
>
> Basically I want to wrap these simple functions in a nice class wrapper and
> have the ability to call them without having to jump through more hoops
> than is necessary.
>
> Are there any pitfalls to writing a class like this? Or, is this the
> standard way of writing a simple "utility" class for this type of
> situation?
>
> Please let me know if I need to clarify my questions.
>
> Thanks for your time?
>

Reply via email to