There are actually three different ways for routine-header layout (Code Complete 2):no conscious layout, endline layout and standard indentation. The preferred method being the standard indentation
No conscious layout
The parameters are laid out one after another, with no arrangement whatsoever
bool ReadData(string employeeName, int employeeAge, int yearsOnJobMarket, bool isOperationSuccesful)
These routines are seen as purely utilitarian in that both computers and humans can read them, but they cause trouble for humans.
Endline layout
bool ReadData(string employeeName,
int employeeAge,
int yearsOnJobMarket,
bool isOperationSuccesful)
This approach is neat and aesthetically appealing. The main problem is that it takes a lot of work to maintain, and that usually means it isn't maintained. For example, if the routine name changes to ReadNewData
, your layout will look like this:
bool ReadNewData(string employeeName,
int employeeAge,
int yearsOnJobMarket,
bool isOperationSuccesful)
so now you either have to manually change the indentation of all the other parameters, or just forget about it and leave it as it is.
Standard indentation
bool ReadData(
string employeeName,
int employeeAge,
int yearsOnJobMarket,
bool isOperationSuccesful
)
Now, in this case, you don't have to change anything if your routine name changes, or you add/delete new parameters. It looks good for the eyes, it's readable and maintainable.
Again, these are not my ideas, but are taken from Code Complete 2 by Steve McConnell