Question: I am struggling to choose the perfect design pattern for this scenario :

When I click on the Browse button on my swing UI, a specified URL must be opened up on the web browser. This functionality is achieved inside this utility class which looks like this : 

```
//inside action Listener of the browse button I call the openURL method of the below class

class webBrowserUtility(){
    void openURL(String url){
    ........
    }
}

```

**Design Pattern Methods** 

Approach 1) I can go ahead and create new instance of the above class and invoke openURL().

Approach 2) Singleton : Make the WebbrowserUtility class a singleton and retain a static instance of that class in memory to be able to call the method whenever needed. 

Approach 3) static method : Make the openURL() method static and call WebbrowserUtility.openURL(url) as needed.

In my first approach, I am worried that it might be inefficient as, every click on the browse button will create a new instance of the WebBrowserUtility class. I am confused between which approach to adapt between choice 2) and 3). Can you please help me choose the best among these three design patterns for this scenario? Or is there a better design pattern that can be adapted for the same?

Answer: 
Personally I would select approach 3, as so far as the scope of this example extends, there appears not to any need to store an object state and there's a direct usage from the click handler.

Of course the limitations here are that you can't pass around an instance of the class as you might were it a singleton, however even if this were necessary, it's unlikely given its lack of state that there would actually be a *requirement* to limit the number of instances via a singleton, and so you probably shouldn't use a singleton anyway.

I hope this helps.
Do you need to keep state in the WebBrowserUtility class (e.g. member variables, counters, ...)? 

If yes: Do you need this state to be globally available or synchronized? Approach 2 ... otherwise 1)

If no: Then this is a simple static utility class, go with a static method on a static class