|
Re: Is getWatchdog() required in RobotTemplate.java?
I personally use Watchdog.getInstance() in my code.
Watchdog scruffy = Watchdog.getInstance(); //for instance
getInstance() is a common method provided in Singleton classes or classes that are mean to NOT be instantiated. A good example is the Math class in Java SE 7 (Does not have getInstance()... meaning "REALLY do not get this instance"). Another example is the Java SE 7 Toolkit class which some games use for getting the screen width of your computer. It has a method called Toolkit.getDefaultToolkit() which might as well be Toolkit.getInstance().
That method ensures only ONE instance of the class EVER exists. You wouldnt want two logging classes posting to the console (in most cases) so you make it a singleton with getInstance() capability. Only one Watchdog will EVER exist. That is all that means.
You can freely use getInstance to have your own reference to the Watchdog object just so you are familiar. Like mine is named Scruffy.
|