I thought I was finally getting good at this "Java" thing, and then someone suggests to me that I use a singleton and factory class. I'd never heard of these before so I set off googling it. Now, I get the gist of singleton and factory classes, but I still have some more questions.
Here's some background info:
For my own fun little project, I'm creating this program which will read in commands from the terminal and execute the appropriate commands, just like UNIX. So, I'm basically trying to implement some way of essentially having a dictionary which derives the meaning of each word, and then performs the correct actions on the correct objects in accordance with the user's wishes. This is where someone suggested I use a singleton factory class.
So, I understand that singletons can only be implemented once. Question: What is the necessity of this? If I don't want another class to create an instance of it, then I just won't program it so that it will. Also, can someone provide me with a simple example of how to implement it?
I'm a little more hazy on factory classes. Do they create instances of other classes depending on the parameters that are passed to them? Why is this necessary and how does that differ from other classes? An example of implementation would be appreciated.
Thanks for your help.