Turning cohesion into functional cohesion?

As described in this website ,

A module with (single) procedural connectivity is support for various and possibly unrelated actions in which control transfers from one action to another. The Jones page gives an example of a module (whose name may be something like: "Preparing for the holiday meal:"

  • Clean dishes from previous dishes
  • Prepare Turkey for roasting.
  • Make a phone call
  • Take a shower
  • Chop vegetables
  • Set table

Now my question is: if each of these actions, i.e. makes a phone call, retrieves in their own method, but they are all still called in the same order i.e.

private void PrepareForHolidayMeal() { CleanUtensilsfromPreviousMeal(); PrepareTurkeyforRoasting(); ... SetTable(); } 

Is this method still an example of procedural cohesion? Or is it functionally cohesive, as it supports actions to perform one task related to a problem, in this case preparing for food?

+4
source share
2 answers

The phone call in your example is not specified. This is one of the unrelated tasks. If you assume that the phone call is still at "...", all this will again lose its cohesion. Otherwise, you can argue that all other activities are necessary for cooking. This may start a discussion of whether "CleanUtensilsfromPreviousMeal" is really here, because this activity may only be needed if there was no cleaning before. StackExchange questions are not for such discussions ... so we will need a much clearer example for a solution to be agreed upon by several software architects. Otherwise, some people may argue differently than others.

+1
source

This is a very interesting question, and yes, the answer is relative and depends on how we understand things [written in the article] and how they correspond to what the author had in mind.

In particular, there is a slight difference between procedural and functional connectivity: procedural cohesion is something that contains steps that are not related to each other, i.e. there is no β€œgoal” for a procedure that is something repeatable and necessary for its correction is defined and reused. While functional cohesion is basically a function (it may take an input and give an output) that can be used for different inputs and will produce the correct output (depending on the input) when reused.

The conclusion according to your question: no, putting each in separate methods and calling them in the same order does not change it from a procedural to a functional one, unless your procedure becomes a function that really has some "purpose".

+1
source

Source: https://habr.com/ru/post/1439934/


All Articles