Voici quelques petites choses qui vous seront très utiles !
PS : si certains termes (ou expréssions) vous parraient "etranges", wikipedia vous aidera !
Coupling
Coupling or dependency is the degree to which each program module relies on each one of the other modules
- Types
- No
- Modules do not communicate with each other
- Message
- Modules are not dependent instead they use a public interface to exchange parameter-less messages or events
- Data
- TODO: simple data/internal
- Stamp
- a modules share composite data structure but requires only part of it(through say field name structured data/internal
- Control
- a module controls logic of antother by passing it information on what to do(what-to-do flag)
- External
- modules share externally imposed data format( ie using mysql api instead wrapping it in db api) simple data/external
- Common
- modules share common data(ie global variable) structured data/external
- Content
- module relies/depends on implementation details of another module
Cohesion
Cohesion is a measure of how strongly-related or focused the responsibilities of a single module are
Types
- Coincidental cohesion (worst)
- grouped arbitrarily.. (e.g. a module of frequently used functions).
- Logical cohesion
- logically categorised to do the same thing, even if they are different by nature (e.g. grouping all I/O handling routines).
- Temporal cohesion
- during run-time (e.g. a function which is called after catching an exception which closes open files, creates an error log, and notifies the user).
- Procedural cohesion
- always follow a certain sequence of execution
- Communicational cohesion
- operate on the same data
- Sequential cohesion
- output from one part is the input to another part
- Functional cohesion (best)
- contribute to a single well-defined task of the module
Connascence
Two pieces of software share connascence (or relation) when a change in one requires a correspoiding change in the other Like coupling but in operational way instead just levels
Types
- Static
- Of Name
- Of Type
- Of Meaning
- Of Algorithm
- Of Position
- Dynamic
- Of Execution
- Of Timing
- Of Value
- Of Identity
- Contranascence
Rules
- Locality: higher connascence for smaller scope
- Degree: convert high degrees of connascence into weaker forms of connascence
Corelation To Other Principles
TODO:
Like:
- DRY: CoA
- Law of demeter: CoT
- KISS:
- Single responsibility
Modularity Ry Jim Weirich