Cohesion And Coupling In Software Engineering Ppt
![](http://careersplay.com/wp-content/uploads/2016/07/Types-of-Cohesion.jpg)
Applications that are difficult to alter and extend may be the result of software designs that ignore the principles of coupling and cohesion. For example, when a relatively minor feature change requires a significant amount of programming, tight coupling and low cohesion may be contributing factors. Coupling Coupling is measure of the independence of components. Coupling is related to cohesion. It is an indication the strength of inter connections between the components in a design. Jagnesh Chawla(jagneshchawla@gmail.com) 4.
Software development is time-consuming and expensive. Under the best circumstances, one goes from an idea to requirements, design, coding, testing, deployment, and then a maintenance phase. This is, more or less, the classic software development model. Of course, changing requirements can throw off this entire process. EHR vendors are experiencing this first-hand due to changing MU requirements. The threat of obsolescence due to changes in computing technology may also result in new requirements that alter software development cycles.
Consider how much computing has changed since 2000. In 2000, the Internet was just beginning to come into its own, and LAN-based client/server was still the next big thing. Creating a complex web application such as a content management system was expensive, and the tools to do so were not that great. Java was five years old, Rails was four years in the future, and.Net was still two years away.
Look at how much things have changed in just 12 years. Mobile computing is a fact of life; anybody with a web hosting account can launch a content management system-based website; and the cloud and multi-processing are coming to the forefront of software development. In previous posts, I have discussed basic software design principles that help to address the problem of change. Concepts such as essentially acknowledge change as a constant that must be addressed via development practices and software architecture/design choices. Happily, developing a web application while studying object-oriented analysis and design (OOA&D) has allowed me to see the practical value of these design principles.
Cohesion and coupling are my latest discoveries. Coupling is defined as the degree of interdependence between two or more classes, modules, or components. Tight coupling is bad, and loose coupling is good. This will make more sense with an example. Let’s say we have a clinical research application that contains a patient information collection form.
![Coupling Coupling](http://image.slideserve.com/441998/range-of-coupling-l.jpg)
On this form is a field for the SSN. Bajo el estigma del quinto sol pdf filetype pdf. Whenever a patient enrolls in a study, the form checks the SNN to see whether: 1) it is a valid SSN (i.e., fits the pattern 0), and 2) the patient has been a subject in prior studies. In the current version of the application, when the cursor leaves the SSN field, the following procedure runs.
Procedure SSN Check Begin If is_Number(Left_Three_Chars) Then Result=0 Else Result =1 If is_Number(Middle_Two_Chars) Then Result=0 Else Result =1 If is_Number(Right_Three_Chars) Then Result=0 Else Result =1 If Result=0 Then Count = “SELECT SSN FROM patients WHERE SocNum=SSN” Else Print “This is not a valid SSN” End This procedure checks whether each part of the SSN is a number, and if everything is okay, it searches for the SNN in the patients table and returns 1 if the patient has been in a prior study. This type of code is easy (and tempting) to write in form-based development environments.
Why is it bad? The Count query makes a direct call to the database. As a result, the SSN text field is tied directly to the database, exhibiting tight coupling. Arctic cat snowmobile serial number decoder. With one form, this is not a huge problem. However, if the application has multiple forms and more than one requires SSN verification, it might become a headache if the form changes, the database changes, or the query is altered. Any of these situations could prove to be costly and messy because developers would have to find every place in the application where a SSN check occurred, change the programming code, and test the final application.
Cohesion is defined as the degree to which all elements of a module, class, or component work together as a functional unit. High cohesion is good, and low cohesion is bad.
The ideal situation is one where a module, class, or component provides only one function or, at most, a very closely related set of functions. Looking at the above procedure, we see that it performs two functions.
It validates SSNs, and it performs a database query. These are completely unrelated actions and, thus, the procedure exhibits low cohesion. Improving the Design Moving unrelated functions into their own units (i.e., module, class, or component) would be a good first-step in improving the design. One solution would be creating a data access module then placing all database queries for the entire application in one location.