[Solved] Singleton design pattern [closed]

This is one simple example for your singleton. Feel free to add setters and getters as you need it for the fields. I’m not sure what the set-method in your diagram should do but maybe you don’t need it anyway. public class LibraryInfo { private static final LibraryInfo instance = new LibraryInfo(); public static LibraryInfo … Read more

[Solved] Initializing singleton in class instead of instance? [closed]

This is the non-lazy method of implementing the Singleton pattern for languages that support it. It’s perfectly acceptable to do this, especially since it’s one of the ways of implementing a thread-safe Singleton. However, if your Singleton object is expensive (see lazy initialization) to create, then it might not be appropriate to create it in … Read more

[Solved] Abstract Factory Design Pattern for remote file transfer app [closed]

Since you need to adapt to different mechanics\protocols, you can implement Adapter pattern. Also, adapter can be chosen at runtime, you can also implement Factory pattern to instantiate an adapter. And then Strategy pattern to have adapters and factories. All this being done with IoC to inject dependencies like adapters or factories solved Abstract Factory … Read more

[Solved] singleton is design-pattern or anti-pattern? [closed]

As far as I know, the book AntiPatterns by Brown et al, 1998 may have been the first to popularise the term. It defines an anti-pattern like this: “An AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences.” I think that it’s worthwhile to pay … Read more

[Solved] I am going to create simple logger using C# so what are the design patterns I can use to create this as best practice? [closed]

Well, the obvious choces are Strategy (one logger that can be configured to use different output options) and Composite (multiplex output over several output outions). So something like this (in Java): public class Logger { public interface LogOutput { void out(final String s); } // Composite – use to send logging to several destinations public … Read more