10.01.2015 Views

Teaching formal methods in the context of software engineering

Teaching formal methods in the context of software engineering

Teaching formal methods in the context of software engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

FMET – Formally Reviewed Papers<br />

body. To build up <strong>the</strong>se qualities, he or she must spend<br />

much time and make great efforts <strong>in</strong> <strong>the</strong> basic tra<strong>in</strong><strong>in</strong>g.<br />

Anybody who ignores <strong>the</strong> basic tra<strong>in</strong><strong>in</strong>g will fail to perform<br />

satisfactorily <strong>in</strong> matches..<br />

2.4 <strong>Teach<strong>in</strong>g</strong> Specification Patterns for<br />

Abstraction Skills<br />

Effectively us<strong>in</strong>g a <strong>formal</strong> method requires <strong>the</strong> developer to<br />

have high skills and ability <strong>in</strong> ma<strong>the</strong>matical abstraction,<br />

especially <strong>in</strong> <strong>the</strong> <strong>context</strong> <strong>of</strong> s<strong>of</strong>tware development. How to<br />

help students streng<strong>the</strong>n <strong>the</strong>ir abstraction skills and ability<br />

<strong>the</strong>refore becomes an important issue <strong>in</strong> <strong>formal</strong> <strong>methods</strong><br />

education. While this has been recognized widely as <strong>the</strong><br />

most difficult th<strong>in</strong>g <strong>in</strong> teach<strong>in</strong>g, we have ga<strong>in</strong>ed sufficient<br />

knowledge and understand<strong>in</strong>g through our long time<br />

teach<strong>in</strong>g experience. Consider<strong>in</strong>g <strong>the</strong> fact that <strong>the</strong> basic<br />

operations required <strong>in</strong> a s<strong>of</strong>tware system usually <strong>in</strong>clude<br />

search<strong>in</strong>g, sort<strong>in</strong>g, merg<strong>in</strong>g <strong>of</strong> two collections <strong>of</strong> objects,<br />

add<strong>in</strong>g some elements to a collection <strong>of</strong> objects,<br />

elim<strong>in</strong>at<strong>in</strong>g some elements from an exist<strong>in</strong>g collection <strong>of</strong><br />

objects, updat<strong>in</strong>g some elements from an exist<strong>in</strong>g collection<br />

<strong>of</strong> objects, ma<strong>the</strong>matical computation, and <strong>the</strong>ir<br />

comb<strong>in</strong>ations, we put <strong>the</strong> emphasis on <strong>the</strong> teach<strong>in</strong>g <strong>of</strong> how<br />

to express all <strong>of</strong> <strong>the</strong> above functions us<strong>in</strong>g appropriate data<br />

types and <strong>the</strong>ir related operators. Each <strong>of</strong> such expressions<br />

will form a specification pattern that will rema<strong>in</strong> <strong>in</strong> students<br />

m<strong>in</strong>d and available for application <strong>in</strong> real s<strong>of</strong>tware<br />

development. For example, what are possible specification<br />

patterns for a function which tests that a collection <strong>of</strong><br />

<strong>in</strong>tegers is empty To answer this question, we first def<strong>in</strong>e<br />

a collection <strong>of</strong> <strong>in</strong>tegers as a set and a sequence <strong>in</strong> SOFL (or<br />

VDM), respectively, such as <strong>in</strong>tset: set <strong>of</strong> <strong>in</strong>t and <strong>in</strong>tseq:<br />

seq <strong>of</strong> <strong>in</strong>t. We <strong>the</strong>n discuss <strong>the</strong> most commonly used<br />

specification patterns for each <strong>of</strong> <strong>the</strong> data abstractions. For<br />

example, for <strong>the</strong> set <strong>of</strong> <strong>in</strong>tegers, we can use <strong>the</strong> follow<strong>in</strong>g<br />

patterns to express <strong>the</strong> fact that <strong>the</strong> set is empty: <strong>in</strong>tset = {}<br />

and card(<strong>in</strong>tset) = 0. Of course, we could have more<br />

patterns to express <strong>the</strong> same mean<strong>in</strong>g, but those would be<br />

much more complex and no good for readability. For<br />

<strong>in</strong>stance, a possible pattern can be: forall[x: <strong>in</strong>t] | x not<strong>in</strong><br />

<strong>in</strong>tset. It is up to <strong>the</strong> teacher to decide whe<strong>the</strong>r to discuss<br />

such a complicated pattern with<strong>in</strong> <strong>the</strong> required teach<strong>in</strong>g<br />

time. In <strong>the</strong> case <strong>of</strong> a sequence <strong>of</strong> <strong>in</strong>tegers, we can use <strong>the</strong><br />

follow<strong>in</strong>g patterns to express <strong>the</strong> fact that <strong>the</strong> sequence is<br />

empty: <strong>in</strong>tset = [] and len(<strong>in</strong>tset) = 0.<br />

After each basic specification pattern is mastered by<br />

students, we can <strong>the</strong>n go fur<strong>the</strong>r to expla<strong>in</strong> how such basic<br />

patterns can be applied <strong>in</strong> a more complicated situation. Let<br />

us take an operation to search for an <strong>in</strong>teger <strong>in</strong> a collection<br />

<strong>of</strong> <strong>in</strong>tegers as an example. To expla<strong>in</strong> how such an<br />

operation is specified, we take <strong>the</strong> same approach as <strong>the</strong><br />

one to teach<strong>in</strong>g <strong>the</strong> basic patterns by first def<strong>in</strong><strong>in</strong>g <strong>the</strong><br />

collection <strong>of</strong> <strong>in</strong>tegers as a set <strong>of</strong> <strong>in</strong>tegers and a sequence <strong>of</strong><br />

<strong>in</strong>tegers, respectively, and <strong>the</strong>n expla<strong>in</strong><strong>in</strong>g how <strong>the</strong><br />

operation can be specified by comb<strong>in</strong><strong>in</strong>g <strong>the</strong> basic patterns<br />

for each <strong>of</strong> <strong>the</strong> data abstractions.<br />

2.5 Practice through Small Projects<br />

While <strong>the</strong> basic tra<strong>in</strong><strong>in</strong>g is important <strong>in</strong> teach<strong>in</strong>g and<br />

study<strong>in</strong>g <strong>formal</strong> <strong>methods</strong>, we should never forget to give<br />

students opportunities for l<strong>in</strong>k<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> to<br />

s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g. In o<strong>the</strong>r words, <strong>the</strong>y need to be<br />

taught how <strong>formal</strong> <strong>methods</strong> will possibly help <strong>the</strong>m <strong>in</strong><br />

s<strong>of</strong>tware development practice; o<strong>the</strong>rwise, students<br />

(perhaps with some exceptions) will likely to lose <strong>the</strong><br />

motivation <strong>of</strong> learn<strong>in</strong>g or apply<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> <strong>in</strong><br />

practice. The most effective way for this is to let students<br />

conduct small projects. For example, after <strong>the</strong> <strong>in</strong>troduction<br />

<strong>of</strong> VDM-SL and massive exercises on <strong>the</strong> basics, we can<br />

ask students to do one or two small projects. One project<br />

can be <strong>the</strong> construction <strong>of</strong> a <strong>formal</strong> specification for a small<br />

library system, and ano<strong>the</strong>r possibility is to let students<br />

complete a <strong>formal</strong> specification for an ATM s<strong>of</strong>tware.<br />

Through such small projects, students can really feel how<br />

<strong>formal</strong> specifications can be built and organized <strong>in</strong> real<br />

s<strong>of</strong>tware development projects. Of course, such a practice<br />

may also give students an opportunity to f<strong>in</strong>d <strong>the</strong> weakness<br />

<strong>of</strong> <strong>the</strong> specification language <strong>the</strong>y are us<strong>in</strong>g. For example,<br />

lack<strong>in</strong>g an <strong>in</strong>tuitive mechanism for structur<strong>in</strong>g a whole<br />

system <strong>in</strong> a structured manner <strong>in</strong> VDM could be found by<br />

students. The answer to this problem is to <strong>in</strong>troduce <strong>the</strong><br />

SOFL specification language to <strong>the</strong>m, s<strong>in</strong>ce SOFL has<br />

solved this problem by us<strong>in</strong>g <strong>in</strong>tuitive and <strong>formal</strong>ized data<br />

flow diagrams and process decompositions. In fact, many<br />

exist<strong>in</strong>g <strong>formal</strong> notations focus only on one aspect <strong>of</strong> <strong>the</strong><br />

problem <strong>in</strong> s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g and ignore <strong>the</strong> o<strong>the</strong>rs, but<br />

a real s<strong>of</strong>tware project needs to take care <strong>of</strong> all possible<br />

aspects. If a method or technique merely helps solve one<br />

problem but create more o<strong>the</strong>r problems <strong>in</strong> <strong>the</strong> <strong>context</strong> <strong>of</strong><br />

s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g, it is unlikely to be popular among<br />

practitioners and to be applied <strong>in</strong> real projects. In this<br />

regard, <strong>the</strong> SOFL method has shown to be <strong>the</strong> exception,<br />

because it provides a systematic and rigorous process to<br />

<strong>in</strong>tegrat<strong>in</strong>g <strong>formal</strong> techniques <strong>in</strong>to exist<strong>in</strong>g s<strong>of</strong>tware<br />

eng<strong>in</strong>eer<strong>in</strong>g practices and creates no more problems.<br />

2.6 <strong>Teach<strong>in</strong>g</strong> Formal Methods Us<strong>in</strong>g Formal<br />

Eng<strong>in</strong>eer<strong>in</strong>g Methods<br />

The ultimate goal <strong>of</strong> teach<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> (FM) is to<br />

create possibility <strong>of</strong> students apply<strong>in</strong>g <strong>the</strong>m <strong>in</strong> practice.<br />

Formal eng<strong>in</strong>eer<strong>in</strong>g <strong>methods</strong> (FEM) show how FM can be<br />

applied <strong>in</strong> real projects. One <strong>of</strong> <strong>the</strong> very important aspects<br />

<strong>of</strong> FEM is <strong>the</strong> emphasis <strong>of</strong> comb<strong>in</strong><strong>in</strong>g diagrams, <strong>formal</strong><br />

notation, and natural language <strong>in</strong> a coherent and systematic<br />

manner for writ<strong>in</strong>g specifications [1]. The purpose <strong>of</strong> this is<br />

to help developers easily understand <strong>the</strong> specifications <strong>the</strong>y<br />

are writ<strong>in</strong>g and <strong>the</strong> specifications written by o<strong>the</strong>rs.<br />

Visualization is <strong>in</strong>tuitive and suitable for describ<strong>in</strong>g <strong>the</strong><br />

overall idea and system architectures; <strong>formal</strong> notation has a<br />

strength to achieve preciseness <strong>of</strong> statements <strong>in</strong><br />

specifications; and natural language can be used to provide<br />

a friendly <strong>in</strong>terpretation <strong>of</strong> <strong>formal</strong> expressions. In general,<br />

<strong>in</strong>roads — SIGCSE Bullet<strong>in</strong> - 19 - Volume 41, Number 2 — 2009 June

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!