You are here

A small application to help studying vocabulary lessons - design

This article is the second one, in a series of several ones (Smile). The first article is here.

Data model

Our first version will be very simple. Only one table will be used, to store our data:

table name: PAIRS
first column: wordLanguageA (varchar(128))
second column: wordLanguageB (varchar(128))

One index will be created, for each column, so that we can perform optimized searches on words in any language.

A primary key will include the two columns, so that pair of words are displayed in order.

GUI

The application allows the user to define a set of word pairs.

The Graphical User Interface will work as follows:

  • the main window will display nothing for now. It will be used in future versions.
  • using the menu Manage / Words, the user can create a new pair, or edit or delete an existing one.
  • Manage / Words opens a new window, listing existing word pairs, if any, and displaying buttons allowing for addition / edition / deletion / pair edition (see window design below).

The Manage / Words windows is as follows:

  |  wordLanguageA           |  wordLanguageB          |  wordLanguageA  [                ]
| | | wordLanguageB [ ]
| | |
| | | [ Add ]
| | | [ Edit ]
| | | [ Delete ]
| | |
| | |
| | |
| | | [ Validate ]
| | | [ Cancel ]
| | | [ Exit ]

 
When the window is displayed, only following elements are visible:

  • the two word columns
  • the Add button
  • the Edit button
  • the Delete button
  • the Exit button

When Add button is clicked, the two worldLanguageA and worldLanguageB edit boxes are
displayed. The Add, Edit, Delete and Exit buttons are hidden, while the Validate and
Cancel buttons are displayed.

Working for edit operation is similar.
   
Table contents is refreshed after each modification.

Source code conventions

Graphical elements are named according to the following rules:

  • <data><type>
  • <data> describes the use of the element
  • <type> describes the type of the element, as an acronym

Examples:

  • wordLanguageAT, for a Text aimed at letting the user entering a word for language A.

Following type acronyms are used:

  • Btn: Button
  • Cmp: Composite
  • GD: GridData
  • GL: GridLayout
  • Lbl: Label
  • RL: RowLayout
  • Tbl: Table
  • Txt: Text
  • TI: TableItem

Database access

At startup, autocommit is set to false. Thus, all methods modifying tables must perform a
commit (or a rollback) before returning to caller.

DataAccess class provides the interface to the database. Its methods return their result using
an ErrorInfo object, so that the caller can easily test the execution status of the operation,
and get, if needed, extended info about that status.

dataAccess field is created at startup time by Review, the main class. It is passed as a parameter to all
objects that require accessing database.

In query statements manipulating strings, those strings are enclosed between single quotes.
This requires to double every possibly existing single quotes in such strings. This is the
aim of the DataAccess.filterOutQuotes() method.     

Next article: the code.