Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
If you don't know cohesion, you might be a crappy coder
Message
From
30/05/2021 15:24:48
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
30/05/2021 14:30:05
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680834
Message ID:
01680836
Views:
40
>What is cohesion? It means that a module is internally cohesive. I want to make an electric kettle. I want to detach the power cord when I want to carry the kettle. The power cord is a standard part. The connector in the kettle is a standard part. The heating element and electronics can be a standard part. The kettle with all of these things become a physical part.
>
>At design time - which is what programming is - a blue print of this kettle is made. If an engineer spent time laboriously copying every detail of the components of the kettle into a single blueprint - especially when the other components already have their own blueprints, he would be in huge trouble.
>
>This is what some programmers do and they call it cohesion. They think the blueprint must be a single unit containing exact copies of all the code in a library. Absolutely wrong. There is no reason to have several copies of any reusable module. This goes contrary to the purpose of modularity and violates the don't repeat yourself (DRY) principle.
>
>On the main blue print of the kettle, all that is needed is to refer to the power cord, the connector, the heating module.
>
>If a new heating module is designed to fit the power connector and the mounting point in the kettle and accept the wall power from the cord, new kettles can be produced and the old blueprint need not change at all. We can simply name the newer heater module the same as the old one and instantly upgrade the kettles and new better products ship. It's even easier in code than in a physical assembly line.
>
>Each module is highly cohesive. They have simple connections to each other, which is called loose coupling. The question of what drawer the blueprints are kept in is ludicrous except to the designer. If he happens to have a full memory of the blueprints in his mind, he can just visualize them. That is a power we have also. That would mean each blueprint would be magically available without even having to specify what classlib/procedure library it is in. That is the job of the Build exe. It literally does not care what classlibs or procedure libraries you use. All we and it needs is the names of the modules to render something functional.
>
>If I give a copy of the blueprint to a friend, and he does not have the blueprint for the heating module, then I need to copy that for him - but I never ever need to make another copy of the heating module within the design team.
>
>At assemble time - in the kettle production line - they work with physical modules - they don't need the blueprints. Likewise in code, we can ship external modules that will be combined when needed at execution time. That is a godlike power only programmers have, and few ever seem to use it.

I person constantly naming other people crappy is crap. Simply shut up. You are a whimsy.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform