Data Binding and Cohesion Metric
Data Binding and Cohesion Metric
COHESION METRIC
GROUP 3
GROUP MEMBERS
ALIZA SAJID 15
SALEHA AFTAB 37
MISBAH IFTIKHAR 38
SIDRA TUL MUNTAHA 18
ALEENA HAMEED 17
AYESHA JALIL 16
RABIA AMIN 46
WHAT IS DATA BINDING?
• DATA BINDING
• Data binding is a way to connect and update data between different
parts of an application, like a website or a mobile app, so that they
always show the same information.
• Ensures that data is consistent and up-to-date across all connected
sources.
WHAT IS THE IMPORTANCE OF DATA
BINDING?
• IMPORTANCE
• Saves Time: Data binding automates the process of updating data, saving
developers time and effort.
• Reduces Errors: By automatically updating data, data binding reduces the
chance of human error.
• Improves User Experience: Data binding ensures that users see the most
up-to-date information, improving their overall experience.1.
• Increases Efficiency: Data binding enables developers to focus on other
tasks, increasing their productivity and efficiency.
• Enhances Data Consistency: Data binding ensures that data is consistent
across all connected sources, reducing inconsistencies and errors.
RELATION OF COHESION AND COUPLING
WITH DATA BINDING?
• COHESION :In data binding, cohesion is important because it
helps to ensure that the data and the UI components that
display the data are closely related and work together
seamlessly
• COUPLING : In data binding, coupling is important because it
helps to define the relationships between the data and the UI
components that display the data. Tight coupling can make it
difficult to change or replace one component without affecting
others, while loose coupling can make it easier to modify or
replace components independently.
BEST PRACTICIES FOR DATA BINDING
Use Case: Common in forms where user input updates the underlying model directly.
Example: Angular's ng Model directive or React with controlled components using state.
1. Event Binding
2. Definition: The Ul listens to events and triggers logic in the data layer, without directly
binding data to the Ul.
3. Use Case: Handling user interactions such as button clicks.
4. Example: Binding a button click to a method in JavaScript.
• Data Binding Examples and tools
• Reporting. Binding is a common way to compile reports that display data from a data source to a screen or
printer.
• Data entry. Data binding is also a common way to enter large amounts of data and keep it updated and
synchronized to a data source.
• Lookup tables. Lookup tables are information tables that are typically a part of larger data displays. Data
binding and controls are used to display and change data.Master-detail formats. This is a model for
communication protocols where one device or process controls another. These formats may have two
tables of data bound together.
• Data binding tools
• Visual Studio is a Microsoft product that provides design tools for working with custom objects as a data
source in applications. Visual Studio is also used to bind UI controls.
• Binding Library is a support library for Android developers that binds UI components to data sources.
• Google Web Toolkit is an open source tool from Google that enables web developers to create and
maintain browser-based Java applications deployed as JavaScript. Google Web Toolkit has a feature called
UiBinder that allows the creation of UIs.AngularJS is an open source JavaScript web framework that
facilitates the development of single-page applications. The framework uses HTML and two-way data
binding to synchronize data providers or data consumers automatically. As of January 1, 2022, Google is
• Code for illustrate late binding
• #include<iostream>
• using namespace std;
• class Base
• { public:
• virtual void show()
• { cout<<" In Base \n"; }
• };
• class Derived: public Base
• { public:
• void show() { cout<<"In Derived \n"; }
• };
• int main(void)
• { Base *bp = new Derived;
• bp->show(); // RUN-TIME POLYMORPHISM
• return 0;
• Code for illustrating early binding
• / Any normal function call (without virtual) // is binded early. Here we have taken base // and derived class example
so that readers // can easily compare and see difference in // outputs.
• #include<iostream>
• using namespace std;
• class Base
• { public:
• void show() { cout<<" In Base \n"; }
• };
• class Derived: public Base
• { public:
• void show() { cout<<"In Derived \n";
• }
• };
• int main(void)
• { Base *bp = new Derived; // The function call decided at // compile time (compiler sees type // of
pointer and calls base class // function.
• bp->show();
• Types of cohesion
• 1. Functional Cohesion: Binding elements that perform a single task.
• Example: Login function.
• 2. Sequential Cohesion: Binding elements that perform tasks in a specific order.
• Example: Payment processing.
• 3. Communicational Cohesion: Binding elements that operate on the same data.
• Example: Chat app.
• 4. Procedural Cohesion: Binding elements that perform a series of steps.
• Example: Recipe app.5. Temporal Cohesion: Binding elements that are related in time.
• 6. Logical Cohesion: Binding elements that are logically related.
• Example: Sorting algorithm.
• 7. Coincidental Cohesion: Binding elements that are unrelated but bundled together.
• Example: Utility app with calculator and unit converter.
• Importance of cohesion
• 1. Improved Code Organization: Cohesion helps to organize code into logical modules, making it easier to
understand and maintain.
• 2. Reduced Complexity: Cohesive code reduces complexity by breaking down large systems into smaller,
more manageable pieces.
• 3. Easier Maintenance: Cohesive code is easier to modify and maintain, as changes are localized to specific
modules
• .4. Reusability: Cohesive code promotes reusability, as individual modules can be reused in other contexts
• .5. Improved Readability: Cohesive code is more readable, as each module has a clear and specific purpose.
• 6. Reduced Coupling: Cohesion helps to reduce coupling, as each module is self-contained and independent.
• 7. Improved Scalability: Cohesive code is more scalable, as new modules can be added without affecting
existing code.
• 8. Better Error Handling: Cohesive code makes it easier to identify and handle errors, as each module has a
specific responsibility.
• 9. Improved Collaboration: Cohesive code promotes collaboration, as developers can work on separate
modules without affecting each other's work.
• 10. Reduced Bugs: Cohesive code reduces the likelihood of bugs, as each module is tested and validated
independently.
• Metric
• A metric is a way to measure something. It's a standard unit of measurement that helps us
understand how well something is doing or how well it's working.
• Cohesion Metric
• A cohesion metric is a way to measure how well the different parts of a program or system
work together. It shows how strongly related the different elements are within a module or
system.