As described on this website,
A module with (only) procedural cohesion is one supporting different and possibly unrelated activities, in which control passes from one activity to the next. Page-Jones gives an example of a module (whose name might be something like, ``Prepare for Holiday Meal:''
- Clean Utensils from Previous Meal
- Prepare Turkey for Roasting
- Make Phone Call
- Take Shower
- Chop Vegetables
- Set Table
Now my question is, if each of those activities, ie make phone call, are extracted into their own method, but all are still called in that same order ie
private void PrepareForHolidayMeal()
{
CleanUtensilsfromPreviousMeal();
PrepareTurkeyforRoasting();
...
SetTable();
}
is this method still an example of procedural cohesion? Or is it functionally cohesive as it supports the activites for the execution of one problem related task, in this case preparing for a meal?
The phone call is left out in your example for good reason. It's one of the unrelated tasks. If you assume the phone call is still in "..." than the whole thing would loose its cohesion again. Otherwise you might argue that all the other activities are necessary for preparing a meal. This might start a discussion whether "CleanUtensilsfromPreviousMeal" is actually valid here because this activity might only be necessary in the circumstance that there was no cleanup before. StackExchange questions are not for such discussions thow ... so we would need a far clearer example for the decision to be agreed on by multiple software architects. Otherwise some people might argue different than others.