I.T. Discussion Community!
-Collapse +Expand
Coder
Search Coder Group:

Advanced
-Collapse +Expand Coder Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Coder Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCoding & OO BoardCoding Techniques Topic   Print This     

coupling and cohesion

coupling and cohesion in Coding Techniques topic (part of our Coding & OO group).

Quick Search: coupling   cohesion   coupling cohesion  
cvduk
south wales
Need a little help. Have the question "How has OOD helped with coupling and cohesion?" Can find plenty of definitions but no real answers. Any help would be greatly appreciated.
 Posted 19 years ago (Thread Starter)
Comment Quote
About cvduk -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread but email is NOT VERIFIED.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6166, 1 replies
Thread Started 5/9/2002 7:40:00 AM
View Counter=6778
Last Reply Posted 6/26/2007 3:51:33 PM)
Location=south wales  
Joined=19 years ago   MB Posts=1  
Most Recent Post
Adam Lum
Prestwood IT
Citrus Heights, CA

Low coupling, high cohesion, that’s what we all aim for right (or have been instructed to aim for by Software engineering books and instructors).

 

For argument’s sake, my definition of coupling is one component’s dependency on how another component is implemented.  As a developer, low coupling is desired because without the dependency on another component you can reuse your code more easily.  As a person who has to go in and debug or update an application it is easier to focus on one component’s behavior.  When you view the design of your application in terms of objects acting upon one another hopefully the ability to decouple components becomes easier.  Take for example if you created a game with a character whose movements were controlled by the user.  If the code to move the character looked something like:

 

moveCharacter(int movementNumber)

{

            if (movementNumber == 1)

            {

                        // move left

            }

            else if(movementNumber == 2)

            {

                        // move right

            }

           

           

}

 

Then any other component in this game is forced to know the different numbers which move this character.  A better implementation would be to make a moveRight() and moveLeft() methods.

 

Cohesion is when components interact in a way that is logical and easy to determine the flow of data.  Again if you think of your application in terms of objects operating on one another, and name the methods in a way that is easy to understand then designing an application becomes that much easier.  For example if you had a Bank Account object you could expect it to have methods such as getBalance(), deposit(double x), withdrawl(double x), etc.

 

OOD represents a more modular way to design an application.

Adam Lum
Senior Programmer
Prestwood Software
http://www.prestwood.com

 Posted 14 years ago
Comment Quote
About Adam Lum -Collapse +Expand
Visit Profile
Approved member.
Member does not subscribe to this thread.
About Adam Lum

Adam Lum is a part time developer for Prestwood Software and participates in this online community when time allows. His day-to-day work is C# coding but his current intrests (right now) are Ruby on Rails and iOS programming with Objective-C.  He has also coded several projects in Java, C++, ASP Classic, and PHP.  His personal website can be found at adamlum.com.


Post ID #11944 (Level 1.1)  Reply to 6166
Thread Started 6/26/2007 3:51:33 PM
View Counter=2
Location=Citrus Heights, CA 
Joined=15 years ago   MB Posts=31   KB Posts=23   KB Comments=4   BLOG, Topics=1  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1111A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #6166 Counter
6778
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2021 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech