Wednesday, March 23, 2011

Efferent Coupling and Cyclomatic Complexity

http://en.wikipedia.org/wiki/Efferent_coupling

"Efferent Coupling is a metric in software development. It measures the number of data types a class knows about.

This includes inheritance, interface implementation, parameter types, variable types, and exceptions.

A large efferent coupling can indicate that a class is unfocused. It may also indicate brittleness, since it depends on the stability of all the types to which it is coupled."



(my idea of a too much "Efferent Coupled" class is the typical implementation of a Service which does everything on it own, like sending JMS messages, querying the DB, applying all sort of Business Rule referring lot of Domain Objects)


http://en.wikipedia.org/wiki/Cyclomatic_complexity

"It directly measures the number of linearly independent paths through a program's source code"


(the way I see it, a method with a lot of if/then/else, exception handling etc... The great danger is that your unit tests might not address all the possible branches of the code. I find fascinating the idea that you can generate a graph and devise a way to generate tests which exercise each node of the graph)


This "cyclomatic" reminds me of the Cyclops Polyphemus (one cyclops, 2 cyclopes... complex, uh?)



No comments: