Home

 

Getting Started with Elisa

Using EDS

Demo's

Tutorials

 

Language Description

1. Lexical Elements
2. Basic Data Types and Expressions
3. Definitions
4. Streams
5. Backtracking
6. Statements and Special Expressions
7. Arrays
8. Lists
9. Descriptors
10. Components
11. Collections
12. Generic Components
13. Terms
14. Categories
15. Types 

16. Built-in Definitions
17. Higher-order Definitions

18. External Interfaces

Index

Data Structures

1. Sequences
2. Examples involving Lists
3. Trees
4. Graphs
5. Searching State Spaces
6. Language Processing
7. Knowledge Representations          

 

Metaprogramming

1. Introduction
2. What are Domain Definitions?

3.  Sorts of Domain Definitions

4.  Manipulations of Domain Definitions

5.  Translating Domain Definitions

6.  Dialogue Sessions

7.  Example of Concentric Circles

8.  Example of Domain Substitution applied to Concentric Circles

9.  Example of an Order Processing Application

10.Example of an Airport Information System

11.Example of a Rental Boat Business

12.Benefits of Domain Definitions

   

Back Home Up Next


9.  Example of an Order Processing Application 

We will now demonstrate more sophisticated capabilities of metaprogramming. Therefore we will develop a mini-application using database modeling. Let us use, as an example, the operations of a bookshop. A bookshop has customers that are ordering books, and suppliers, which are sending books to a bookshop after purchase orders have been received. Thus, the key concepts of a bookshop are: customers, orders, articles, invoices, purchase orders, suppliers.


 

<< Order Processing Application  >>

 

Customer          = Name + Address;

Order                = Customer + Article + Quantity;

Article               = Description + Code;

Invoice               = Order + Amount;

PurchaseOrder = Supplier + Article + Quantity;

Supplier             = Name + Address;

Supply                = Supplier + Article + Price + Quantity;

Inventory           = Article + Supplier + Price + Quantity;

 

Database = Customerset + Articleset +  Orderset

                    + Inventoryset + Invoiceset +  PurhseOrderset;

Articleset                 = collection (Article);

Customerset            = collection (Customer);

Orderset                  = collection (Order);

Inventoryset            = collection (Inventory);

Invoiceset                = collection (Invoice);

PurchaseOrderset  = collection (PurchaseOrder);

 

Name            = text;

Address        = text;

Quantity      = integer;

Description  = text;

Amount        = real;

Price             = real;

Code             = integer;

integer          = predefined;

real               = predefined;

text                = predefined;  


Figure 9:  Domain definitions for an Order Processing Application

We start with a set of domain definitions based on these key concepts. In addition, also a database is defined.. See Figure 9. These domain definitions will be input for the metaprocessor. The result is a skeleton file, called "OrderProcessing.txt". Based on this skeleton information it is now possible to set up an initial database and to introduce a first Customer with a first Order. Let us further assume that the same Customer decides to place a second Order for the same Article (Figure 10).


include "OrderProcessing.txt";

 

db = newDatabase( alist(Customer),

                  alist(Article),

                  alist(Order),

                  alist(Inventory),

                  alist(Invoice),

                  alist(PurchaseOrder));

 

Cust1 = newCustomer("Alex", "Addr1");

add(Cust1, getCustomerset(db));

 

Art1 = newArticle("Pencil", 123);

add(Art1, getArticleset(db));

 

Order1 = newOrder(Cust1, Art1, 15);

add(Order1, getOrderset(db));

 

Order2 = newOrder(Cust1, Art1, 30);

add(Order2, getOrderset(db));  


Figure 10: Example of Initializing the Order Processing Application

In this session the following functions are defined by the skeleton program: newDatabase, newCustomer, getCustomerset,  newArticle, getArticleset, newOrder, getOrderset. The alist and the add functions are built-in Elisa functions. A session shows the data after the initialization phase.  (Figure 11).


db?
Database:[Customerset = { Customer:[Name = "Alex";
                                    Address = "Addr1"]};
          Articleset = { Article:[Description = "Pencil";
                                  Code = 123]};
          Orderset = { Order:[Customer = Customer:[Name = "Alex";
                                                   Address = "Addr1"];
                              Article = Article:[Description = "Pencil";
                                                 Code = 123];
                              Quantity = 30], 
                       Order:[Customer = Customer:[Name = "Alex";
                                                   Address = "Addr1"];
                              Article = Article:[Description = "Pencil";
                                                 Code = 123];
                              Quantity = 15]};
          Inventoryset = { };
          Invoiceset = { };
          PurchaseOrderset = { }]

Figure 11: Data after the initialization of Figure 10.

 Let us further assume that the database manager wants to inspect all the orders in the database. He uses therefore the following expression:

items(getOrderset(db))?

  This expression uses the built-in Elisa function items. This function is a multi-value function that will return all the elements of a list. In this example it will  return all the Orders in the Orderset. For the time being there are only two orders in the database. (Figure 12).


items(getOrderset(db))?
Order:[Customer = Customer:[Name = "Alex";
                            Address = "Addr1"];
       Article = Article:[Description = "Pencil";
                          Code = 123];
       Quantity = 30]
Order:[Customer = Customer:[Name = "Alex";
                            Address = "Addr1"];
       Article = Article:[Description = "Pencil";
                          Code = 123];
       Quantity = 15]

Figure 12: Example of the result of a query based on the input of Figure 11.

 

Back Home Up Next

  Part 6: Metaprogramming   9. Example of an Order Processing Application

            
Introduction

Home | Highlights of Elisa | Integrating Different Paradigms | Getting Started with Elisa | Demo's  | What is Domain Orientation | Bibliography | Copyright | News | Contact | Contents

Language Description:

Lexical Elements | Basic Data Types and Expressions | Definitions | Streams | Backtracking | Statements and Special Expressions | Arrays | Lists | Descriptors | Components | Collections | Generic Components | Terms | Categories | Types | Built-in Definitions | Higher-order Definitions | External Interfaces | Index 

Data Structures: Sequences | Examples involving Lists | Trees | Graphs | Searching State Spaces | Language Processing | Knowledge Representations
Domain Modeling:

Domain Modeling | Concepts | Domain Definitions | Domain Operations | Domain Implementations | Systems | Case study: an Order processing system | Case study: an Airport Support system | Domain Orientation versus Object Orientation

Design Patterns:

Introduction | Abstract Factory | Builder | Factory Method | Prototype | Singleton | Adapter | Bridge | Composite | Decorator | Facade | Flyweight | Proxy | Chain of Responsibility | Command | Interpreter | Iterator | Mediator | Memento | Observer | State | Strategy | Template Method | Visitor 

 

click tracking

This page was last modified on 19-05-2015 14:03:52   

free hit counter