Hints




Document: Software Engineering 1: Lab Exercises

next Session 8: Week 16/17: Projectiles
up Session 7: Week 14/15: Functional Decomposition
gif Exercise 5: Finale (20%)

Hints

When defining a new function, you need to first prepare an adequate specification. This will consist of answers, expressed in plain English, to the following questions:

The idea of defining a new function usually arises in the context of some "higher level" function which you are already writing. Essentially, you want to defer coding some more detailed activity or calculation. This is called "top-down" design, and is a typical strategy for all forms of engineering design, not just software. So, for the time being, you just want to put in a call to a function, which, at some later stage, you will define in detail. The coding of this function call will, implicitly, at least, answer all of the questions we have just raised.

Having answered these questions, you should then enter the skeleton definition of the function:

<return type>  <function name> ( <argument list> )
{
 <function body>
}

You then go back and fill in the slots. For example, suppose we decide to define a function called foo, which will accept one argument of floating_point type, and generate no return value, we can immediately make out the following skeleton:

void foo(floating_point_type arg)
{

}

You need to minimally provide this skeleton, just to allow an invocation of the function to even be compiled properly. You may well temporarily put in a "dummy" body to the function - called a stub - just to allow you to test out the higher level invocation. But, eventually, you must come back and fill in the body of the function definition with the actual C statements which will make it, upon invocation, carry out the activities specified for it.




Document: Software Engineering 1: Lab Exercises

next Session 8: Week 16/17: Projectiles
up Session 7: Week 14/15: Functional Decomposition
gif Exercise 5: Finale (20%)



McMullin@eeng.dcu.ie
Tue Apr 30 14:15:37 GMT 1996