Modularity Flashcards
(23 cards)
what is module
each of the set of standardized parts that are used to create more complex structure
how is modularity being measured
by using three factors - cohesion, coupling and connascence
what is cohesion
cohesion is an indication of the extent to which parts of a module should be kept together, inside the module
what is coupling
coupling is an indicator of how much calls a module needs to make to another module so as to be able to perform any meaningful transaction
what are the varieties of cohesion
functional (best), sequential, communicational, procedural, temporal, logical, coincidental (worst)
what is LCOM measure of cohesion
LCOM or Lack of Cohesion Measurement is a part of Chidamber and Kemerer suit of Object - oriented metrics. It represents the sum of the methods not shared via sharing of a common field; so for example, in a class if there are 3 out 10 methods that shares common attribute, would have lower LCOM score (and therefore less cohesion, which is usually bad) than the class that has 7 out of 10 methods that uses the shared common attribute.
what is afferent coupling
number of inbound calls
what is efferent coupling
number of outbound calls
what is abstractness
the ratio between number of abstract methods to concrete method is the measure of abstractness
what is instability
the ratio between efferent coupling / sum of afferent & efferent coupling; higher value indicates that there are lot of outbound calls that a class makes, thereby making it susceptible to breakage in case any of the called classes break
what is distance from main sequence
distance from main sequence = |abstractness + instability - 1|; if abstraction scores high, a class falls to zone of uselessness, if instability is very high then the class falls to zone of pain
what is connascence
two components are connascent if change in one, requires changing in the other, to ensure that the system functions correctly
what is the difference between static and dynamic connascence
static connascence indicates source code level coupling and dynamic connascence indicate runtime coupling
what are the variety of static connascence
static connascence indicates the degree to which multiple components agree on the name, type, meaning, position, algorithm of a given entity
what is the use of connascence as a tool
connascence is a measure that needs to be minimized across module boundaries, by the use of encapsulation; the connascence within a module should be made high
what are 7 typical code review sections
Style, Correctness, Complexity, Design, Security & Coverage
what are to be used for consistent styling
checkstyle & .editorconfig
what are to be used to ensure code correctness
spotbugs, pmd, checker, error prone etc. can find potential coding issues
what is used to measure code complexity
code complexity are of two types, cyclometric complexity, which if higher makes testing more difficult and cognitive complexity, which if higher makes understanding code more difficult
what is used to find design flaws
checkstyle, pmd validates design issues with class, method, parameter and source code level design issues
what is the way to find security vulnerability
using findsecbugs and sonarquebe
how to measure code coverage
by using Jacoco
what are some advanced mechanism to find design flaws
PMD’s LawOfDemeter — Law of Demeter is a simple rule that can help in reducing tight coupling between classes.
Checkstyle’s DesignForExtension — based on Effective Java 3rd Edition book by Joshua Bloch, Item 17: Design and document for inheritance or else prohibit it.
PMD’s CouplingBetweenObjects — detects tightly coupled classes that are difficult to test, analyze and extend by measuring its number of unique attributes, local variables and return types.
jPeek — you can use this tool to measure the cohesion of our classes and as a result, help to keep the high cohesion of classes, modules, packages.