This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hey, I am creating an application which allows users to simulate certain communications protocols. This application would allow users to configure networks using network components such as routers and hosts by dragging and dropping images of them onto a configuration area. Therefore, as an image is dropped onto the area, objects would be created and certain parameters set. One of the requirements of the application is to allow users to save configurations so that there could be loaded in the future. Could anyone give me ideas on how I would be able to save the configurations along with the parameters? Thanks in advance.
Broadly, there are two ways: save the Java objects directly using serialization, or define a structured file format to translate your objects into as they are saved. Serialization is easy, but opaque and potentially fragile if your code changes. Defining and using a custom file format may or may not be difficult. It might be something you define from scratch, or you could just use an established format like XML. The advantage of using something like XML is you can use a pre-existing parser and tools for writing the file format.