Friday, September 5, 2008

Scripts and their representantion - data and view

While working on the implementation of saving/loading I ran into one difficulty that is not allowing me to save the user-generated code. In short, what we call the user-generated code, or the object’s “script,” or in our software “the board,” is currently implemented as a collection of graphic components generated by Netbeans. The “script,” at this point, is not an object itself with data that can be separated from its visual appearance. Appearance and data are the same. For this reason, saving the code means, at this point, saving the collection of graphic components.


However, the original design of some of these graphic components (WhileElsePanel, IfElsePanel, MethodPanel, and so on) used a layout manager (GroupLayout) that can not be saved (it is not serializable), making the graphic component not serializable.


I am considering two alternatives to overcome this. One, is to make serializable all the layouts of the graphic components that constitute “the script.” The advantage of this approach is that the rest of the code Hilmi wrote will not be affected. The disadvantage is that GUI and the data will continue to be extremely integrated, making difficult to change the visual appearance of the code without changing the way it is interpreted and how it is saved, and changing the visual appearance is something that Ron wants to do.


The second alternative is to separate data and visual appearance. It requires the creation of a class CODE or SCRIPT, which is independent of any way to represent it visually, and it contains all the data to create or recreate the script. It also requires the interpreter to use this class, rather than the corresponding graphical components as it is currently done. The advantage of this is that the script can be visually represented in different ways, given that the GUI is separated from the script data. It also makes it easier to save and load every object’s script. The disadvantage is that it will be time consuming.


I want to hear your thoughts about this before deciding what alternative to follow. Maybe any of you see something than I do not. I am also copying this to Hilmi in case he attempted to do something like this in the past, and copying this email to the blog.

No comments: