Coupling and how to reduce it -


in of following lines of code coupling occurs? kind of coupling? problem induced coupling? how can code refactored reduce coupling?

a busy cat

one way approach @ function/method depends upon.

it explicitly depends on arguments - form of control coupling, in case.

however if tried compile method in isolation, can see other objects depends upon:

  • log, , specific methods of log (note seem call both of these methods)
  • ignore_user_requests
  • log_verbosity_level, repeated 4 times in method
  • a specific collector class.
  • mem , 4 attributes (size, startaddress, etc) - form of content coupling

i think argue there several cases of common coupling (shared global variables) there, though it's not terribly clear limited context. , variables may scoped within object or package, not 'global'.

then consider:

  • what happen if wanted change 1 of these items. example, if wanted use different collector implementation, or different logger; or structure of mem changed?
  • how test method?

note can't assess impact of coupling without understanding wider code; if these objects encapsulated within single small class, example, impact less if these objects scattered throughout entire code. similarly, trying refactor code bit tricky in isolation, since can guess might affecting elsewhere in our hypothetical code, , objects free refactor (some may 3rd party libraries, example).


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -