ONJava.com    
 Published on ONJava.com (http://www.onjava.com/)
 See this if you're having trouble printing code examples


SSS (Small, Simple, Safe) SSS (Small, Simple, Safe)

by Alper Coskun
05/26/2004

Java is a popular introductory programming language used in computer science curricula, and is generally considered to be a simple, easy to learn, object-oriented language for teaching programming. So why do students have trouble learning to program with Java? I think it's because the Java language and its framework are tightly coupled. Learning the Java language alongside its framework is a significant part of this problem. A beginner in programming with Java may have difficulty distinguishing between the language and the framework parts (see "An Overview of MiniJava" by E. Roberts, ACM SIGCSE, 2000, for more information on this). Students should be able to examine the framework and the language independently.

Java has a large and complex framework for common algorithms, data structures, and more, which is also called its standard libraries. It is difficult to write a useful program without using the standard libraries. Most beginners suppose that this framework is a part of the language. It is not, however. Standard libraries are designed for professional programmers, not beginners; in fact, beginners usually get confused because of this enormous framework. That is a serious problem in courses with Java.

Unfortunately, the available development environments cannot relieve this problem; if anything, they cause even more confusion. They are also not sufficient for learning the standard libraries. There is no existing tool that helps students to realize the difference between the language and the framework part. On the other hand, some textbooks try to clarify the difference by giving some code examples, but the results are generally less effective than desired. Because they are printed materials, they cannot show the difference as clearly as a specialized tool. Such a tool, targeted particularly at new programmers, could illustrate only the Java framework and basic object-oriented concepts.

What Is SSS?

In this article, I want to introduce an educational tool that mainly addresses the problems above. It is called SSS, which stands for Small Simple Safe, and was written by Dr. Akif Eyler, a professor in the computer science and engineering department at Marmara University in Istanbul. The idea came from an ancestor tool that Professor Eyler had written to inspect the Java framework libraries for easing his own practice with Java. As he realized the gap in this area, he decided to make it a complete environment and created SSS in order to be used by the community.

Related Reading

Head First Java
Your Brain on Java - A Learner's Guide
By Bert Bates, Kathy Sierra

SSS is a simple tool that allows for handling various classes and objects. You can load classes and immediately build objects using public constructors. It allows for very quick access to public methods of any class. Using SSS does not require a knowledge of Java syntax. It allows testing a class just by clicking in the GUI; there is no need to write test code or to compile something with SSS for testing. SSS would be very useful for a beginner while learning standard Java classes such as java.lang.String or java.io.File. An experienced programmer would also benefit from fast learning, testing, and experimentation.

SSS in Detail

Where many Java development environments use their own interface in order to design and develop graphical user interfaces, SSS concentrates on using the user interface to illustrate the Java framework, making it easier to understand. SSS is not concerned with the Java language and its syntax. That said, it helps to be aware of the Java framework and some runtime practices of object-oriented concepts such as class hierarchy, inheritance, overriding, and overloading. Students can see how these concepts work in execution. SSS leads students to realize more easily that the Java framework is not a part of the Java language.

On the other hand, SSS is not only for novice programmers, but also for experienced programmers. They can use this tool for testing their own classes and for inspecting third-party classes. Professor Eyler uses SSS in the laboratory session of his class, "Object-Oriented Software Design", which is a graduate course. SSS also supports assignments of the course and receives favorable comments from the students.

SSS typifies the principles "Small Simple Safe," from which it gets its abbreviated name. It is small, at only 90KB. This contrasts with many Java tools that are too big and require extensive setup. SSS does not require any setup: it is only a JAR file, which can be run with a mouse click. It can be used without knowing Java, so it is simple. And it is safe, because only public members are accessible. Furthermore, SSS is a pure Java application, so it is platform-independent. Provided you have J2SE on your machine, you can use it.

SSS has two windows. One of them is the console, as shown in Figure 1. Every action by the user is written to this window. You can also save your actions, so you can use the console log when writing your actual Java program.

Figure 1
Figure 1. The console of SSS

The main window of SSS is separated into three parts, as shown in Figure 2. The left panel shows a list of classes and objects. The middle panel shows the fields of the selected class or object, and the right panel shows its public methods. The main window also changes its color when a class or object is selected.

Click for larger view
Figure 2. The main window of SSS (You can click on the screen shot to open a full-size view.)

An Example in SSS

When SSS starts up, only two classes, Menu and Small, are loaded by default, and no objects are yet shown. The Menu class allows you to choose capabilities and add them to SSS, as various static methods. The getSystemClass() method of the Menu class is used for choosing a system class, meaning one that begins with java or javax. To load any other class, you can use Menu's loadClass() method. Furthermore, your classes and JAR files can be loaded at runtime, so SSS can be extended dynamically. This feature allows for the testing of your own classes.

For example, let's say you want to create some Strings with SSS. Just use the new String(String) public method of the String class. First, click on the Menu class, and the click on getSystemClass(String) from its public methods. Write "java.lang.String" (with quotes) inside of the pop-up window, as in Figure 3.

Figure 3
Figure 3. getSystemClass() dialog

Now, click on the java.lang.String class, which has appeared in the "Classes & Objects" list, and click on the new String(String) public method. Use the dialog to provide a name and a value for this new String. This step is shown in Figure 4.

Figure 4
Figure 4. Instantiating a String

Assume that we have created three strings, and we want to build up a set with them. Again, with the Menu class' getSystemClass(), we can load the java.util.TreeSet into SSS. Next, we make an empty instance of TreeSet with the new TreeSet() method. Then, using the add() method of TreeSet, we can add our previously created strings into the TreeSet instance, as shown in Figure 1 and 2.

In the end, if we call the size() method of TreeSet, we can see on the console that our TreeSet instance's size is 3. Without SSS, trying out the TreeSet's add() and size() methods would require us to write and compile a new test class. If we wanted to then try another method of TreeSet, we would have to compile our code again.

Menu class has a special method, called teach(). This method can be used for demonstrating any example in a step-by-step manner. It allows you to load a teach file, which has steps in plain text format. All of the steps performed in SSS can be saved, and then can be used as a teach file. There are also some ready-to-use teach files, which are bundled with the downloadable SSS. A similar method, teachSSS(), exists for teaching SSS in step-by-step manner.

Conclusion

This article explored the "Small Simple Safe" tool. SSS is a simple, multi-platform, easy-to-use tool for teaching the Java framework and basic object-oriented concepts. Its main motivation is to solve problems beginners experience in understanding the difference between the framework and the language. It allows users to handle Java classes and objects directly in the GUI. SSS's design goals include simplicity, user-friendliness, and the ability to teach and to test standard libraries and other classes visually.

Alper Coskun is a software engineer and part-time graduate student in Computer Engineering.


Return to ONJava.com.

Copyright © 2009 O'Reilly Media, Inc.