Class Structure of the DotWiki
The DotWiki project contains three main classes:
- A Web page used to display and edit topic information.
- A business object that reads and saves data from the database.
- A parser that performs translations on the text coming from the database before it is displayed.
shows the class diagram of the DotWiki project. I've drawn the main classes with a blue border.
When users visit the DotWiki, the Wiki loads Default.aspx and automatically loads a topic from the database. When a user clicks on a CamelCase word inside the topic, the Wiki page calls the BusinessObject to load the record corresponding with the clicked CamelCase word. The Default.aspx Web page then calls the Wiki parser to process the topic coming from the business object, and eventually the browser renders the topic.
When a user clicks the Edit button, the Default.aspx
page switches itself to edit mode and displays the content of the topic in a textbox so that the user can make modifications to the text. When the user clicks the Save button, the Wiki page passes the new text to the Business Object so the text can be sent to the database, and finally the Default.aspx
Web page switches back to view mode.
Figure 5 illustrates how these classes interact with each other as a user visits the Wiki.
The DotWiki stores all of its information in a database. Although users can enter many topics and each topic can be as lengthy as a user decides to make it, the database that supports the DotWiki project is very simple.
|Full-Text Search allows you to perform sophisticated text searches where you can find variations of a word and rank the results.|
The DotWiki database contains only two tables: TOPIC and TOPICHISTORY. The TOPIC table stores content information while the TOPICHISTORY table stores the previous version of each of the topics in the database.
When users edit a topic, the Wiki copies the current version in the TOPIC table to TOPICHISTORY and writes the new version in TOPIC table. This way the Wiki stores the most recent version of each topic in the TOPIC database.
Figure 6 shows an entity relationship diagram of the two tables that the DotWiki uses.
|Figure 6: Tables in the DotWiki database.|
Although users see and use Web pages when they visit the DotWiki, most of the actual work happens inside the Business Services class. The Business Services class receives requests from the Web pages, goes to the database to read/write data, and passes back the results to the Web pages.
For example, the Index.aspx Web page calls the GetIndexDS method of the Business Services class to get a list of topics in the database. Likewise, the FileUpload.aspx Web page calls the AddPictureToTopic method of this class to include a reference to a picture in a particular topic.
Figure 7 shows the methods that the BusinessService class implements.