I heard that singleton is useful and popular ,but the fact is that I seldom see it appears in open source projects.
Instead,I always see people to static method.
The following one is an example link
public final class IoUtils {
private IoUtils() {
}
public static boolean copyStream(InputStream is, OutputStream os, CopyListener
......
}
}
Singleton Pattern says that just"define a class that has only one instance and provides a global point of access to it".
I think Utils class is suitable to use Singleton because all other classes share to use it.
But Why people nerve use it ?
Aucun commentaire:
Enregistrer un commentaire