Sometimes, the data in a running program needs to be transferred out of the program, for example to be stored in a file or transmitted over a network. In this module, I will cover the main techniques for serializing object graphs using a variety of frameworks including Java's binary serialization and JavaBeans frameworks and JSON serialization APIs. This module will also conclude the course with an introduction to the agile development practice called refactoring.
After this module you should:
- Understand the basic problems and trade-offs related to the serialization of objects graphs;
- Be able to make an informed decision about the best serialization strategy for a given design situation;
- Be able to serialize simple object graphs in Java using JDK frameworks and a JSON API;
- Know about the concepts of code smells and refactoring
- Be able to recognize common bad smells in code;
- Be able to perform a selection of common object-oriented refactorings;
- Introduction to the JSON format;
- Documentation for XMLEncoders;
- JetUML v1.0 PersistenceService class as an example of XML serialization.
- Chapter 3 and descriptions of refactorings seen in class in Fowler's book
Exercises prefixed with ⭐ are optional, more challenging questions aimed to provide you with additional design and programming experience.
- Serialize the
Corporation
object created inlabtest01.Driver
using the four types of serialization seen in class. Note that saving the graph in CSV will require some hand-crafted encoding conventions, such as repeating field values. Using the debugger, inspect the deserialized object graph to investigate whether the sharing of the identity ofItem
objects is respected or not. - Once you have a file with the serialized version of the corporation in all four formats, add a boolean field to the
Item
class, for exampleaOnSale
. Then, attempt to deserialize the saved versions. What happens then? Solve the problem for each technique using the most appropriate mechanism. - On the Solitaire sample application, use the Eclipse Extract Interface refactoring tool on Deck and extract the methods size and draw. Call the new interface
CardSource
for example. Notice how the tool automatically figures out that the interface to aDeck
instance can be narrowed down to aCardSource
inWorkingStackManager
.
Unless otherwise noted, the content of this repository is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Copyright Martin P. Robillard 2017