Na that sounds ok, since I wasn't too inclined about Singletons either -  
it is true that abuse is possible.

> In the discussed case I do not see why those methods should be available
> across all levels and objects.

Ok, first let me make sure we are talking about the same context here:

// --- start of code snippets ---

public interface ModeController implements [...]
{
   [...other methods...]
   public MindMap createMap();
   public void closeMap();
   /*
     save/load methods NOT declared here since not all/most ModeControllers  
are expected to support it. So it should not, for example, be possible to  
invoke saveMap or loadMap methods on arbitrary ModeController objects  
without proper casting.
   */
}

public interface SaveableMapsModeController extends ModeController
{
   public void saveMap(MindMap,Writer);
   public void loadMap(MindMap,Reader);
}

public class DefaultModeController implements SaveableMapsModeController
{
   [... other methods ...]
   public void saveMap(MindMap map,Writer out) { MapXML.saveMap(map,out); }
   public void loadMap(MindMap map,Reader in ) { MapXML.loadMap(map,in ); }
}

public class MapXML
{
   public static void saveMap(MindMap,Writer) { ... actual implementation  
... }
   public static void loadMap(MindMap,Reader) { ... actual implementation  
... }
}

// ---- End of code ---

Firstly, if they are not made static, the only difference I see is the  
addition of a few "new MapXML()" statements. It exposes the exactly same  
set of methods either way, so there is no encapsulation problems raised  
explicitly by "static". And by making these functions publicly available,  
we allow the kind of "Export MM file" to directly use them. Secondly,  
saveMap/loadMap is a process that really does not depend on the actual  
ModeController being used. They do not modify the states of any object,  
does not access any global variable in MapXML, or anything else. Objects  
usually have a state.


Reasamp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freemind-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemind-developer

Reply via email to