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 />

completely apply<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> is rarely practical, but<br />

<strong>the</strong> improvement <strong>of</strong> s<strong>of</strong>tware quality can be realized by<br />

equipp<strong>in</strong>g <strong>the</strong> developers with a discipl<strong>in</strong>ed manner and<br />

rigorous way <strong>of</strong> th<strong>in</strong>k<strong>in</strong>g through <strong>formal</strong> <strong>methods</strong><br />

education.<br />

To encourage more students, both <strong>in</strong>experienced and<br />

experienced <strong>in</strong> s<strong>of</strong>tware development, to learn <strong>formal</strong><br />

<strong>methods</strong>, we must first build up <strong>the</strong>ir motivation by<br />

demonstrat<strong>in</strong>g <strong>the</strong> clear benefits <strong>of</strong> <strong>formal</strong> <strong>methods</strong> <strong>in</strong><br />

improv<strong>in</strong>g current s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g practice. While this<br />

is ra<strong>the</strong>r challeng<strong>in</strong>g due to <strong>the</strong> lack <strong>of</strong> reliable quantitative<br />

evidence <strong>in</strong> <strong>in</strong>dustry, many empirical studies, some <strong>of</strong><br />

which were done <strong>in</strong> <strong>in</strong>dustrial sett<strong>in</strong>g [3,4,5], may be used<br />

for this purpose. To let students enjoy learn<strong>in</strong>g <strong>formal</strong><br />

<strong>methods</strong>, excellent teach<strong>in</strong>g styles and techniques, sensible<br />

curriculum arrangements, and academia-<strong>in</strong>dustry<br />

collaboration will be <strong>the</strong> key <strong>of</strong> success. In this paper, we<br />

describe several techniques for teach<strong>in</strong>g students <strong>formal</strong><br />

<strong>methods</strong>, an effective university curriculum, and a<br />

successful program for teach<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> to<br />

<strong>in</strong>dustry. Our fundamental idea is to put <strong>the</strong> <strong>formal</strong> <strong>methods</strong><br />

education <strong>in</strong> <strong>the</strong> <strong>context</strong> <strong>of</strong> s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g, because<br />

our <strong>in</strong>terest is <strong>in</strong> <strong>the</strong> issue <strong>of</strong> how to foster s<strong>of</strong>tware<br />

eng<strong>in</strong>eers for <strong>in</strong>dustry. Of course, as Parnas po<strong>in</strong>ted out [6],<br />

<strong>formal</strong> <strong>methods</strong> should not be restricted to s<strong>of</strong>tware<br />

eng<strong>in</strong>eer<strong>in</strong>g, but l<strong>in</strong>ked to and <strong>in</strong>tegrated <strong>in</strong> general<br />

eng<strong>in</strong>eer<strong>in</strong>g ma<strong>the</strong>matics. S<strong>in</strong>ce <strong>the</strong> issue <strong>of</strong> general<br />

application <strong>of</strong> <strong>formal</strong> <strong>methods</strong> is beyond <strong>the</strong> scope <strong>of</strong> this<br />

paper, we focus our discussions on <strong>the</strong> issue <strong>of</strong> teach<strong>in</strong>g<br />

<strong>formal</strong> <strong>methods</strong> for s<strong>of</strong>tware eng<strong>in</strong>eer<strong>in</strong>g.<br />

The rema<strong>in</strong>der <strong>of</strong> this paper is organized as follows.<br />

Section 2 concentrates on discussions <strong>of</strong> teach<strong>in</strong>g<br />

techniques, <strong>the</strong> most important factor <strong>of</strong> <strong>the</strong> three <strong>in</strong> <strong>the</strong> key<br />

<strong>of</strong> success mentioned above. Section 3 describes <strong>the</strong> current<br />

curriculum arrangement <strong>in</strong> <strong>the</strong> Department <strong>of</strong> Computer<br />

Science at Hosei University, which proves to be effective.<br />

Section 4 presents a successful program for teach<strong>in</strong>g <strong>formal</strong><br />

<strong>methods</strong> to <strong>in</strong>dustry. Section 5 discusses <strong>the</strong> importance <strong>of</strong><br />

cont<strong>in</strong>u<strong>in</strong>g education. F<strong>in</strong>ally, <strong>in</strong> Section 6 we conclude <strong>the</strong><br />

paper.<br />

2. TEACHING TECHNIQUES<br />

In this section, we <strong>in</strong>troduce some specific techniques for<br />

teach<strong>in</strong>g <strong>formal</strong> <strong>methods</strong>. These techniques have been<br />

tested by <strong>the</strong> first author over <strong>the</strong> last fifteen years <strong>of</strong><br />

teach<strong>in</strong>g VDM [7], SOFL [1], and Morgan's ref<strong>in</strong>ement<br />

calculus [8] at universities and companies.<br />

2.1 Start<strong>in</strong>g with Examples<br />

Learn<strong>in</strong>g <strong>formal</strong> <strong>methods</strong> is similar to learn<strong>in</strong>g o<strong>the</strong>r<br />

<strong>the</strong>ories or techniques, students like to start with simple<br />

examples. These examples must come from <strong>the</strong> daily life<br />

and must be able to l<strong>in</strong>k <strong>the</strong> problem <strong>in</strong> practice to a<br />

potential <strong>formal</strong> <strong>methods</strong> solution. This way <strong>of</strong> teach<strong>in</strong>g<br />

will motivate students and build up <strong>the</strong>ir <strong>in</strong>terests <strong>in</strong> <strong>formal</strong><br />

<strong>methods</strong>. For example, when expla<strong>in</strong><strong>in</strong>g <strong>the</strong> ambiguity<br />

problem <strong>in</strong> <strong>in</strong><strong>formal</strong> specifications and <strong>the</strong> fact that it can<br />

be resolved by <strong>formal</strong>ization, we <strong>of</strong>ten use an operation for<br />

search<strong>in</strong>g for an <strong>in</strong>teger <strong>in</strong> an <strong>in</strong>teger list as an example.<br />

After expla<strong>in</strong><strong>in</strong>g <strong>the</strong> impreciseness <strong>of</strong> <strong>the</strong> <strong>in</strong><strong>formal</strong><br />

requirement statements, we present a <strong>formal</strong> specification<br />

which is both precise and concise. This example helps<br />

students understand <strong>the</strong> potential power <strong>of</strong> <strong>formal</strong>ization.<br />

2.2 Gradual Introduction to Important Concepts<br />

The fundamental concepts are <strong>the</strong> key to understand <strong>the</strong><br />

spirit <strong>of</strong> <strong>formal</strong> <strong>methods</strong>. It is quite effective to help<br />

students understand <strong>the</strong> essential pr<strong>in</strong>ciple <strong>of</strong> <strong>formal</strong><br />

<strong>methods</strong> if sufficient efforts are made to teach <strong>the</strong> concepts.<br />

For example, when <strong>in</strong>troduc<strong>in</strong>g <strong>formal</strong> specifications, we<br />

focus on <strong>the</strong> illustration <strong>of</strong> pre- and post-conditions. An<br />

effective way to teach <strong>the</strong> pre-post concept is by compar<strong>in</strong>g<br />

<strong>the</strong>m with <strong>the</strong> correspond<strong>in</strong>g algorithm and let students<br />

understand <strong>the</strong> real difference and relation between a<br />

specification and an algorithm. The comparison can be<br />

made on <strong>the</strong> basis <strong>of</strong> simple scientific computation. For<br />

example, we <strong>of</strong>ten use <strong>the</strong> operation for yield<strong>in</strong>g <strong>the</strong> square<br />

root <strong>of</strong> an <strong>in</strong>teger as an example. The pre-condition <strong>of</strong> <strong>the</strong><br />

operation is x ≥ 0 and <strong>the</strong> post-condition <strong>of</strong> <strong>the</strong> operation<br />

can be y² = x, where x is <strong>in</strong>put and y is output. But <strong>the</strong><br />

correspond<strong>in</strong>g algorithm would be someth<strong>in</strong>g like y =<br />

Math.sqrt(x). This example gives rise to a problem that<br />

output y produced by <strong>the</strong> algorithm may not satisfy <strong>the</strong><br />

post-condition <strong>of</strong> <strong>the</strong> operation because <strong>the</strong> algorithm<br />

obta<strong>in</strong>s only an approximation <strong>of</strong> <strong>the</strong> real square root <strong>of</strong><br />

some positive <strong>in</strong>tegers. In this circumstance, it is useful to<br />

tell <strong>the</strong> students <strong>the</strong> importance <strong>of</strong> notic<strong>in</strong>g this<br />

<strong>in</strong>consistency between <strong>the</strong> specification and <strong>the</strong><br />

implementation. This is also a good example to show <strong>the</strong><br />

need for us<strong>in</strong>g or build<strong>in</strong>g proper <strong>the</strong>ories <strong>in</strong> <strong>the</strong> application<br />

doma<strong>in</strong>.<br />

2.3 Massive Exercises on Basics<br />

Efficiently writ<strong>in</strong>g accurate <strong>formal</strong> specifications requires<br />

<strong>the</strong> developer to have a good understand<strong>in</strong>g <strong>of</strong> features <strong>of</strong><br />

various data types and high skills <strong>in</strong> apply<strong>in</strong>g <strong>the</strong> welldef<strong>in</strong>ed<br />

operators on <strong>the</strong> data types, such as boolean, set,<br />

sequence, and map types. Therefore, massive exercises on<br />

<strong>the</strong> basic operators must be done by students. The most<br />

effective way to <strong>in</strong>corporate exercises <strong>in</strong>to <strong>the</strong> teach<strong>in</strong>g<br />

program is to let students do exercises immediately after a<br />

data type is <strong>in</strong>troduced. For example, after <strong>the</strong> <strong>in</strong>troduction<br />

<strong>of</strong> <strong>the</strong> set types, students must learn <strong>the</strong> mean<strong>in</strong>g <strong>of</strong> <strong>the</strong><br />

operators, such as union, <strong>in</strong>tersection, card<strong>in</strong>ality,<br />

membership, subset, proper subset, and so on by apply<strong>in</strong>g<br />

<strong>the</strong>m to specific set values. If time allows, a public<br />

discussion on students' results is helpful. Accord<strong>in</strong>g to our<br />

experience, such a discussion can help capable students<br />

f<strong>in</strong>d out <strong>the</strong> reason for <strong>the</strong>ir mistakes and ord<strong>in</strong>ary students<br />

f<strong>in</strong>d out <strong>the</strong> correct way <strong>of</strong> th<strong>in</strong>k<strong>in</strong>g. This tra<strong>in</strong><strong>in</strong>g is similar<br />

to <strong>the</strong> basic tra<strong>in</strong><strong>in</strong>g <strong>in</strong> sports. To be an excellent football<br />

player, for example, one must run fast and have a strong<br />

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

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

Saved successfully!

Ooh no, something went wrong!