Software Engineering discussion

9 views
Code Complete > Organizing Straight-Line Code

Comments Showing 1-5 of 5 (5 new)    post a comment »
dateUp arrow    newest »

message 1: by [deleted user] (new)

This chapter is so short that I am afraid that any comment I would make would be longer than the chapter itself!


message 2: by Aleksander (new)

Aleksander Shtuk | 84 comments In my opinion the very first example where output from one procedure is passed to the next one is the best for indicating execution order to code reader. From code reader’s or modifier’s perspective I would not make any assumptions about code execution order, so at first I thought may be it’s a useless suggestion. But from the constructor’s perspective this is a great idea to make it harder for somebody else to change an order of execution if it’s important to keep it in order. I mean, even if changing order of execution is required to fix a problem, doing more work will require a person to understand the original idea or at least allow more time for consideration.


message 3: by Tom (new)

Tom Sturm | 2 comments Order of execution is sometimes critical, and the programmer should be able to have a mechanism to control it. Consider the following code I show all of my C students:
int main()
{
double a, b, c, x, y, z;

x = 1.2e+30;
y = -1.2e+30;
z = 2.3;

a = x + y;
b = x + z;
c = y + z;

printf("%f %f %f\n", a+z, b+y, c+x);
printf("%f %f %f\n", x+y+z, x+z+y, y+z+x);
return 0;
}
If you don't want to lose the value of z due to roundoff, you need to be able to control the order in which x + y + z is calculated.


message 4: by Erik (new)

Erik | 165 comments I was looking for a solution that somehow factored the accumulation examples in to a new class or a single function.

None of the solutions suggested comments or documentation describing the dependancies either.

The code solution examples didn't seem that great to me. They don't imply a dependant order.

Something like this might even be better than this chapter's examples:

result = AnnualAccumulate( QuarterAccumulate( MonthAccumulate( data ) ) );

I feel this implies imporatnce of order and dependancy more the examples in this chapter.


message 5: by Aleksander (new)

Aleksander Shtuk | 84 comments Erik, what if you need to call 10 functions or 15? :) jk


back to top