Getting started
Setting things up
This tutorial only works with ABEL shipped with EiffelStudio 14.05. You can find the code in the unstable directory.
It is also possible to get the latest code from the SVN directory .
Getting started
We will be using
class PERSON
create
make
feature {NONE} -- Initialization
make (first, last: STRING)
-- Create a newborn person.
require
first_exists: not first.is_empty
last_exists: not last.is_empty
do
first_name := first
last_name := last
age:= 0
ensure
first_name_set: first_name = first
last_name_set: last_name = last
default_age: age = 0
end
feature -- Basic operations
celebrate_birthday
-- Increase age by 1.
do
age:= age + 1
ensure
age_incremented_by_one: age = old age + 1
end
feature -- Access
first_name: STRING
-- The person's first name.
last_name: STRING
-- The person's last name.
age: INTEGER
-- The person's age.
invariant
age_non_negative: age >= 0
first_name_exists: not first_name.is_empty
last_name_exists: not last_name.is_empty
end
There are three very important classes in ABEL:
- The deferred class
PS_REPOSITORY provides an abstraction to the actual storage mechanism. It can only be used for read operations. - The
PS_TRANSACTION class represents a transaction and can be used to execute read, insert and update operations. AnyPS_TRANSACTION object is bound to aPS_REPOSITORY . - The
PS_QUERY [G] class is used to describe a read operation for objects of typeG .
To start using the library, we first need to create a
class START
create
make
feature {NONE} -- Initialization
make
-- Initialization for `Current'.
local
factory: PS_IN_MEMORY_REPOSITORY_FACTORY
do
create factory.make
repository := factory.new_repository
create criterion_factory
explore
end
repository: PS_REPOSITORY
-- The main repository.
end
end
We will use