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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FMET – Formally Reviewed Papers<br />

FEM differs from FM <strong>in</strong> that FM tries to answer <strong>the</strong><br />

question ``what should we do and why’’ <strong>in</strong> s<strong>of</strong>tware<br />

development, but FEM tries to answer <strong>the</strong> question ``what<br />

can we do and how’’. To this end, FEM focuses on<br />

techniques and <strong>methods</strong> for <strong>in</strong>tegrat<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> <strong>in</strong>to<br />

<strong>the</strong> entire process <strong>of</strong> s<strong>of</strong>tware development so that <strong>the</strong><br />

strength <strong>of</strong> <strong>formal</strong> <strong>methods</strong> can be utilized <strong>in</strong> practice and<br />

<strong>the</strong>ir weakness <strong>of</strong> be<strong>in</strong>g complex can be avoided. FEM<br />

<strong>of</strong>fers how s<strong>of</strong>tware systems, <strong>in</strong>clud<strong>in</strong>g all level documents,<br />

are actually created and expressed <strong>formal</strong>ly, not just a<br />

simple mixture <strong>of</strong> <strong>formal</strong> notations with pictures. S<strong>in</strong>ce a<br />

detailed <strong>in</strong>troduction to FEM is beyond <strong>the</strong> scope <strong>of</strong> this<br />

paper, we refer <strong>the</strong> reader to <strong>the</strong> SOFL book [1] for a<br />

comprehensive description <strong>of</strong> FEM.<br />

In fact, <strong>the</strong> same pr<strong>in</strong>ciple <strong>of</strong> FEM can also be<br />

effectively applied to <strong>the</strong> teach<strong>in</strong>g <strong>of</strong> <strong>formal</strong> <strong>methods</strong><br />

courses, s<strong>in</strong>ce teach<strong>in</strong>g is actually a k<strong>in</strong>d <strong>of</strong> s<strong>of</strong>tware<br />

project whose product is educated students. For example,<br />

when expla<strong>in</strong><strong>in</strong>g a ma<strong>the</strong>matical expression, such as Z = X<br />

union Y, we can use a graphical representation (e.g., Venn<br />

diagrams) to illustrate <strong>the</strong> union operation, and at <strong>the</strong> same<br />

time use English, for <strong>in</strong>stance, to expla<strong>in</strong> <strong>the</strong> mean<strong>in</strong>g <strong>of</strong><br />

<strong>the</strong> operation. When <strong>in</strong>troduc<strong>in</strong>g an operation <strong>in</strong> VDM, we<br />

can draw a process as we do <strong>in</strong> <strong>the</strong> SOFL language to show<br />

<strong>the</strong> <strong>in</strong>put, output, and external variables, but <strong>the</strong> details <strong>of</strong><br />

<strong>the</strong> function <strong>of</strong> <strong>the</strong> operation are def<strong>in</strong>ed us<strong>in</strong>g pre- and<br />

post-conditions. With <strong>in</strong><strong>formal</strong> explanations <strong>in</strong> English, <strong>the</strong><br />

mean<strong>in</strong>g <strong>of</strong> <strong>the</strong> whole operation specification can be easily<br />

digested by students.<br />

2.7 Tool Support <strong>in</strong> Education<br />

Almost all <strong>of</strong> us may have experienced us<strong>in</strong>g tools <strong>in</strong><br />

teach<strong>in</strong>g programm<strong>in</strong>g languages, such as Java and C, and<br />

found that it is effective to help students write, execute, and<br />

test programs (<strong>the</strong>y need many pre-def<strong>in</strong>ed packages).<br />

Many <strong>of</strong> <strong>formal</strong> <strong>methods</strong> educators apply this idea to <strong>the</strong><br />

teach<strong>in</strong>g <strong>of</strong> <strong>formal</strong> <strong>methods</strong> courses as well. However, our<br />

experience <strong>in</strong> teach<strong>in</strong>g both VDM and SOFL courses,<br />

which focus on <strong>formal</strong> specification techniques, suggest<br />

that us<strong>in</strong>g tools <strong>in</strong> teach<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> is not<br />

necessarily effective; perhaps less effective than not us<strong>in</strong>g<br />

tools <strong>in</strong> some circumstances. There are two reasons. One is<br />

that learn<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> requires students to learn both<br />

syntax and semantics <strong>of</strong> <strong>the</strong> related specification language.<br />

The most effective way for students to remember <strong>the</strong>m is to<br />

write <strong>formal</strong> specifications by hand, as <strong>the</strong>y learn English<br />

as a foreign language. It is feasible, because exercises<br />

assigned to students <strong>in</strong> classes are <strong>of</strong> small scale. It is also<br />

effective <strong>in</strong> streng<strong>the</strong>n<strong>in</strong>g students' memory <strong>of</strong> <strong>the</strong> syntax<br />

and <strong>in</strong> deepen<strong>in</strong>g <strong>the</strong>ir understand<strong>in</strong>g <strong>of</strong> <strong>the</strong> abstraction<br />

techniques, because students would have no chance to<br />

"copy and paste" without th<strong>in</strong>k<strong>in</strong>g by <strong>the</strong>mselves, as we<br />

<strong>of</strong>ten do on a computer. Ano<strong>the</strong>r reason is that <strong>the</strong> purpose<br />

<strong>of</strong> writ<strong>in</strong>g a specification is not for a computer to directly<br />

run it, but for people to read and understand. Therefore,<br />

lett<strong>in</strong>g <strong>the</strong>m write a good style <strong>of</strong> <strong>formal</strong> specifications by<br />

hand is much more helpful for learn<strong>in</strong>g than by us<strong>in</strong>g a tool<br />

to automatically improve <strong>the</strong> style and format <strong>of</strong> <strong>the</strong>ir<br />

specifications. In <strong>the</strong> case <strong>of</strong> programm<strong>in</strong>g, without a tool,<br />

such as a compiler, we cannot run <strong>the</strong> program. But <strong>in</strong> <strong>the</strong><br />

case <strong>of</strong> writ<strong>in</strong>g a specification, <strong>the</strong>re is no need to run it, so<br />

without a tool support will not create any significant<br />

<strong>in</strong>convenience. Instead, for some students who do not want<br />

to study <strong>formal</strong> <strong>methods</strong>, tool support will create chances<br />

for <strong>the</strong>m to "copy and paste" without th<strong>in</strong>k<strong>in</strong>g.<br />

Hav<strong>in</strong>g said <strong>the</strong> above, it does not mean that tool<br />

support is not necessary for us<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> <strong>in</strong><br />

practice. On <strong>the</strong> contrary, tool support is crucial for<br />

improv<strong>in</strong>g productivity and reduc<strong>in</strong>g chances <strong>of</strong> creat<strong>in</strong>g<br />

mistakes <strong>in</strong> practical developments. For this reason, we let<br />

students use a support<strong>in</strong>g tool, such as IFAD VDMTools or<br />

SOFL GUI editor, when <strong>the</strong>y carry out a small project, after<br />

a systematic learn<strong>in</strong>g <strong>of</strong> <strong>formal</strong> specification techniques <strong>in</strong><br />

classes. This way also has an effect that students feel<br />

extremely happy with <strong>the</strong> tool <strong>of</strong>fer<strong>in</strong>g high automation <strong>in</strong><br />

both writ<strong>in</strong>g and analyz<strong>in</strong>g specifications. They have this<br />

k<strong>in</strong>d <strong>of</strong> feel<strong>in</strong>g because <strong>the</strong>y have gone through a hard time<br />

<strong>in</strong> learn<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> by hand. This is similar to <strong>the</strong><br />

situation where a person feels happy when he or she has a<br />

chance to eat delicious food after a long time starv<strong>in</strong>g.<br />

2.8 Deal<strong>in</strong>g with Time Constra<strong>in</strong>t<br />

Ma<strong>the</strong>matical concepts and expressions usually require<br />

students to take time to digest, <strong>the</strong> teach<strong>in</strong>g <strong>of</strong> <strong>the</strong>m should<br />

take slow pace with many examples. However, a course is<br />

like a s<strong>of</strong>tware project: it also has time constra<strong>in</strong>t. As a<br />

teacher, we <strong>of</strong>ten face a dilemma. On <strong>the</strong> one hand, we<br />

want to teach more contents which are all important for<br />

study<strong>in</strong>g <strong>formal</strong> <strong>methods</strong>, but on <strong>the</strong> o<strong>the</strong>r hand, we do not<br />

have enough time. To tackle this problem, our experience<br />

suggests that each course should not be too ambitious;<br />

<strong>in</strong>stead, it should be focused. For example, we can teach<br />

<strong>formal</strong> specification, ref<strong>in</strong>ement, and <strong>formal</strong> verification <strong>in</strong><br />

three different courses, and it would be effective to focus<br />

<strong>the</strong> teach<strong>in</strong>g <strong>in</strong> each <strong>of</strong> <strong>the</strong>m on <strong>the</strong> most fundamental but<br />

important parts and give students sufficient time for <strong>the</strong>m<br />

to apply <strong>the</strong> learned techniques. For example, when<br />

teach<strong>in</strong>g SOFL, particularly techniques for writ<strong>in</strong>g <strong>formal</strong><br />

specifications us<strong>in</strong>g pre- and post-conditions, to students,<br />

we usually take <strong>the</strong> <strong>in</strong>terleav<strong>in</strong>g approach: teach<strong>in</strong>g<br />

concepts and ask<strong>in</strong>g students to practice us<strong>in</strong>g <strong>the</strong>m. After<br />

f<strong>in</strong>ish<strong>in</strong>g <strong>the</strong> whole course, we ask students to carry out a<br />

small project <strong>in</strong> which all knowledge learned is required to<br />

use. Such a way provides students with many opportunities<br />

to learn how <strong>the</strong>oretical results can be effectively applied <strong>in</strong><br />

practice.<br />

3. A SYSTEMATIC CURRICULUM<br />

While teach<strong>in</strong>g techniques are crucial to a successful<br />

education <strong>in</strong> <strong>formal</strong> <strong>methods</strong>, a sensible arrangement <strong>of</strong><br />

curriculum concern<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> education also plays<br />

an important role from an overall view <strong>of</strong> education. We<br />

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

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

Saved successfully!

Ooh no, something went wrong!