Skip to main content

Coupling....

I've been thinking about coupling for a while now.  It's more than just one class or process knowing about another class or process, that happens all the time.  It's about using the minimum amount of coupling in a program for it's operation.  

Coupling is not a 'one size fits all' issue where there is a right and a wrong way to use it.  It's more of understanding when to use it, when it happens by accident and in general, being aware of the repercussions when too much coupling exists.

In my mind, coupling exists when there is a specific relationship between two classes or processes.  This relationship must be explicit where one class must be coupled by another into for some operation to be viable.  This is not the same as just passing data from one object to another where the data couple be in the form of a third data object (a model, strings, streams, etc) where the two objects are not really bound together but there data is.  This is about objects like a View having access to a model in the MVC pattern but the Model does not have access to the view.   

Coupling can be reduced by providing dynamic patters to abstract away direct coupling, but this has side effects.  Using multiple levels of indirection to avoid coupling can lead to logic that is hard to understand or maintain by other programmers later in the projects lifecycle.  Abstracting connections without a firm business needs may make the code overly complex and hide the classes relationships.   You can see this patten when using reflection that may then load a configuration file that loads a class that...... you get the picture.  Not fun to modify or debug.

On the other side the coin is how indirect coupling can be created by over use of patterns like dependance injection where annotations spread through the source files with little thought on the tangled relationships that ensue throughout the code.  Dependance injections is wonderful but not if it obfuscates the is-a and has-a relationships into a mass of dependancies.  Dependance injection does not replace the design and understanding of the class relationships and operation.

Coupling issue are not limited to source code.  The same could be said of build projects, unit tests and other supporting aspects of a project.  

  

Comments

Popular posts from this blog

A Process

Once in a while I take photos of a work in progress.  This is for me as well as others as the work moves from stage to stage.  And it is done in stages with defined processes for each step.  On this walkway overpass up in Spruce Pine, I've done both an ink / marker and an Ink / Wash on the same piece. This is the finished watercolor of the work.  To start the process I did an ink drawing of it and then took a tracing from that.  It's the tracing where I did another ink drawing but this time on watercolor paper. Tracings of a work is done with standard tracing paper.  I get mine from CheapJoes.com and use the 8x10 size as that covers most of my needs.  The tracing is done with a 0.3 ink pen (Winsor & Newton Fineliner).  Once I have the tracing I can then use it for other paper or to do another work of the same subject. The tracing is just a start as I still need to get it transferred onto other paper.  For that you need a very bright light...

Still Life

 Life is never still, at least I don't think you would want it to be.  That's why so many of us (i.e., retired care free people) travel.  Keep seeing new things and places.   Well the Hurricane so far inland was a new thing and one I would have rather forgone but life is what happens.  Life keeps moving. Except a still life is forever and captures a slice of time frozen in a painting.  This is from a wooden bowl of pears onboard our ship during dinner one nice.  Again, just thought it looked nice. Enjoy.

A Trip Abroad

 Just back from our trip abroad as Asheville continues to recover from the hurricane.  This trip has been planned for a long time and we almost didn't make it because our dog sitting business will be closed for a while. But make it we did and now we are back. We love Amsterdam.  What a fun place to visit.  So many things to too and do there.  The weather was not the best but it did not have an impact on our visit.  Just bundle up. Got some quick painting in while on the boat (i.e., Viking) as we moved from port to port.  This painting is of a garden at a heritage site of windmills.  I thought it looked nice. Nice time on the trip to de-stress from what was happing back home.  We were fine back home but not everything is well with many others.