Code Generation

The language Gently serves as a formal specification language, but also as input to the Gently tool, a type checker and generator. The Gently tool performs the following static checks: For correct input, the Gently generator produces the following output code: In order to develop an Interface with Gently, perform the following steps: As an example we will use a realistic model of an online bookshop. The user can browse, put books in a cart, and order that cart in a multistep dialogue. As part of the complete specification we give the Gently code of the shopping cart and the category view of the system in the following. The JSP cart groups together all dialogue methods which lead to a view of the current shopping cart content. The cart example introduces theredirect construct, which is mapped to the redirect mechanism of HTTP. The view of the cart contents is always provided by the show() method. The result page of this method offers to the customer the possibility to change all quantities of ordered items in one step. It calls the changeCart() method for that purpose. The example shows also the usage of the menu construct. This construct may contain link and form declarations, which will be included on every result page. It is further motivated by the considerations in the following chapter. Note that we omit all documentation beyond the formal Gently constructs in the example code just for reasons of space.

jsp Cart{ show(){ called by redirect from Cart.changeCart or called by redirect from Cart.insert or called by redirect from Cart.insertMany or called by viewCart from Home.welcome or called by viewCart from menu and form changeContent calls Cart.changeCart(hidden isbn, textfield number) or link buyCart calls Order.addressForm() or link backHome calls Home.welcome() } changeCart(int[] isbn, int[] number){ called by changeContent from Cart.show and redirect Cart.show() } insert(int isbn){ called by toCart from Category.contents or called by toCart from Search.results and redirect Cart.show() } insertMany(int isbn, int number){ called by toCart from Singleitem.show and redirect Cart.show() } } jsp Category{ contents(String path){ called by browse from Home.welcome or called by subCategory from Category.contents or called by up from Category.contents and // next higher category link up calls Category.contents(aParent) // Categories may contain subcategories or link subCategory calls Category.contents(aChild) // Categories may contain books or link details calls Singleitem.show(isbn) or link toCart calls Cart.insert(isbn) } } menu{ link home calls Home.welcome() or link viewCart calls Cart.show() or form doSearch calls Search.results(textfield aQuery) }