S.I.T.H. Object Creation

One of the most usfull things that can be done in SITH, is to make classes and objects. This tutorial will run though an example of these two functions. This first part will guide you though making the first class. Please have your browser to maximum to make some of the screenshots as clear as possible.


Creating a Class

Starting up SITH there will appear two windows, one on top of the next. You can see that I have moved my windows so that both are visible.

Looking at specifically the Class Table we will right-click on any row button and select add.

After a little delay, the window above will appear. It describes the class you are adding. By changing this description, the class definition will change. Let us first give it a name. Click on the "Name Class" tab.

We are making a Person Class. I will mention that the word "Class" is appended to the name because it is a class object. We can, in the future, distinguish this from other objects, like Person Default, or Person List. Click on the Class Class tab.

The Class Class tab will be the most used tab when creating classes. First we want to add some fields to this class. We notice that in this version of SITH the "Attribute Class.Class" sub-table is the third table down. The location of the tables can change at any time because DBC is unordered, and SITH does not enforce any order. I have scrolled the window a little so the whole Attribute Class table can be seen. Right click on the only row button of this table (it is indicated by three dashes). Once the window appears, click on the menu item "Attribute Class" and select "Field Class".

Here is the window that appears. It has four tabs. Object and Attribute tabs are filled in automatically. We must fill in the Name and the Type of this field. Click on the Name Class tab first.

We will call this field the "Full Name" field. Next, click on the Field Class tab.

We will select "String Class" for the Type select box. Remember that when filtering the table do not use the Shift key, it adds garbage to the filter string.

Above you see the result of selecting the String Class. Selecting one of the primitives types will make SITH act special. It generates a text box for field input compared to a select box. It is more intuitive that way. You will see that during object creation the difference between a primitive field and a standard field. Select Record, then Save.

We have our Full Name field added to the Person Class. We will create another field. As before, right-click on any row button of the Attribute Class.Class table and select Add. Select the Attribute_Class menu option and select Field Class.

We have moved to the Name Class tab and called it the "Mother" field. Select the Field Class tab.

Since Mother's are people,. we will make this field of type Person Class; that is the class we are currently editing, and is a special case. When selecting the class in the select box, we must select it by Primary Key instead of by Name. Technically the name does not exist because the class does not exist. The Primary Key of this class is 182968. You can see above the entry into the filter.

At this point we are complete. We only need to select Record and Save in the menu bar to complete this field definition. The class definition is also complete, we will select Record and Save there too.

You may have notice that during the add of a new class two windows popped up. This second window defines the placement the new class is in the hierarchy tree. The tab we are usually interested in is the Option Class tab.

The option class has two select boxes; the parent and child. It is always autogenerated to inherit directly from the Object Class. In our case, a person is not a specialization of any other class in the DB, so we will change nothing and just Record and Save this.

We are done a single class definition. We can see our new class by filtering the Class Table to show all classes with "people" in the name.

We can also see we get a table that holds instances of the People Class. This table is auto generated by SITH, and is given the same name as the class. Actually SITH cheats and makes the string that is the name of the class the same string that is the name of the table. I would be correct to want to rename this table the Person Table, but because of the dependency on a single string in can not be done without altering the name of the class also. We just leave it as is.


Creating Instances of a Class

Once the Person Class has been created, we make make instances of it. We start this portion of the tutorial with the S.I.T.H. main window. We have added a filter to the list of tables so that only the ones with "person" appear.

We will open this table to see all the people that exist in the DB. Right-click on the Person Class row button, and select "Open".

We can see the table, and all the fields we have added to the Person Class. Let us now create a person. Right-click on the triple-dash row button and select "Add".

SITH reads in the class definition and provided the fields for user entry. We can now see how SITH deals with primitive fields (String Class) compared to standard fields. The primitive fields have more background management to make the user interface easier. We can see that the person we just added has no name, and the mother has been automatically assigned to be itself. Let us make the name be "Mother of Mothers" and then Record and Save.

We have now made our first person. This person is a little different than most other people. We have defined the Mother field to always be a person and have not made provision for the very first person. Solving this problem is a matter of database design and not part of this tutorial. Below we can see I have made a few other people to populate our world with. Some are boys. Note the George's mother is Eve.

That concludes this tutorial on creating classes and objects. We have only covered adding fields to classes, but you have seen that fields are a specialization of attributes, and there are other types of attributes that can be added to classes. The most important is the Handler attribute; important for giving our classes methods to handle messages and performing action.