Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Increased cohesion and decreased coupling do lead to good software design. </p> <p>Cohesion partitions your functionality so that it is concise and closest to the data relevant to it, whilst decoupling ensures that the functional implementation is isolated from the rest of the system. </p> <p><em>Decoupling</em> allows you to change the implementation without affecting other parts of your software.</p> <p><em>Cohesion</em> ensures that the implementation more specific to functionality and at the same time easier to maintain.</p> <p>The most effective method of decreasing coupling and increasing cohesion is <strong>design by interface</strong>. </p> <p>That is major functional objects should only 'know' each other through the interface(s) that they implement. The implementation of an interface introduces cohesion as a natural consequence.</p> <p>Whilst not realistic in some senarios it should be a design goal to work by.</p> <p>Example (very sketchy):</p> <pre><code>public interface IStackoverFlowQuestion void SetAnswered(IUserProfile user); void VoteUp(IUserProfile user); void VoteDown(IUserProfile user); } public class NormalQuestion implements IStackoverflowQuestion { protected Integer vote_ = new Integer(0); protected IUserProfile user_ = null; protected IUserProfile answered_ = null; public void VoteUp(IUserProfile user) { vote_++; // code to ... add to user profile } public void VoteDown(IUserProfile user) { decrement and update profile } public SetAnswered(IUserProfile answer) { answered_ = answer // update u } } public class CommunityWikiQuestion implements IStackoverflowQuestion { public void VoteUp(IUserProfile user) { // do not update profile } public void VoteDown(IUserProfile user) { // do not update profile } public void SetAnswered(IUserProfile user) { // do not update profile } } </code></pre> <p>Some where else in your codebase you could have a module that processes questions regardless of what they are:</p> <pre><code>public class OtherModuleProcessor { public void Process(List&lt;IStackoverflowQuestion&gt; questions) { ... process each question. } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload