Editorials

OOP Basics Coupling

SSWUG-TV
With Stephen Wynkoop

Is your data out of control? Find some helpful tips in this edition of SSWUG-TV where we gather insights from data management experts Thomas LaRock, Sarah Barela and Malathi Mahadevan.
Watch the Show

OOP Basics – Coupling
Yesterday we talked about the cohesion of functions in OO Programming. Cohesion defines how specific a function is to a single task. Today we are going to look at coupling of functions; how functions interact with one another.

Functions interact well together when they are properly coupled; there are no direct dependencies between functions. In a perfect world, the implementation of one function may be changed without impacting the code of a calling function.

As you build member functions using good cohesion practices (breaking down the work into smaller pieces), it becomes more important to losely couple your functions, allowing them to be modified without breaking other depenent functions. Idealy, you should be able to take your functions and plug them together in different orders without un-intended results.

Here are some guidelines for good function coupling:

  • Good coupling has few shared connections (parameters)
  • On the other hand, in good coupling shared connections are preferred over local, or (God forbid) global variables, because other functions and/or threads may change the state of variables, whereas passed parameters generally remain constant during function execution
  • Good coupling provides visibility into the function’s requirements and results. Using global variables does not clearly define requirements for a function to execute correctly, nor the end result of what the function performs

We’ll talk about levels of function coupling tomorrow.

These have been some simple principles for the use of methods in your programs. I’m surprised at the impact this little study has already made on my personal coding techniques. I hope you are finding the same experience. You can let me know what you think by writing in to btaylor@sswug.org.

Cheers,

Ben


Be a SSWUG.ORG Beta Tester!
By late Jan. 2012, SSWUG.ORG will be launching a new version of our site. We’ll have a fresh new look with some new cool features. However, we want to make sure it ready for the masses.

If you want to be one of the first to see the new SSWUG.ORG, and help determine it’s final look, you can participate in our CTP, and receive a free year of premium membership for your effort.

To be eligible to participate you need to complete this survey in totallity by Dec. 23.


$$SWYNK$$

Featured White Paper(s)
How to Implement an Effective SharePoint Governance Plan
Written by AvePoint

Moving past the "what" and "why" of governance, an even… (read more)

Featured Script
List index information for the current database
List index information for the current database… (read more)