SlideShare a Scribd company logo
1 of 30
Data Access – Best Practice

Lars-Erik Kindblad
Senior Consultant
Blog: kindblad.com
Agenda

   Why is Data Access so important?
   Common issues in many applications
   How to solve these issues
   Summary




                                         | Sector, Alliance, Offering
Why is Data Access so important?

 Retrieving, creating, updating and deleting data are core operations
 Affects the entire application in a bad way if done incorrectly




                                                            | Sector, Alliance, Offering
Common issues in many applications


                            | Sector, Alliance, Offering
Code issues

 The code in the data access layer is often put into a single or a few
  huge classes
  • Hard to maintain
 Database queries are constructed in the frontend or business layer
  • Leads to messy frontend or business code
 ORM framework limitations or lack of «ORM masters»
  • A lot of quickfixes
 Doesn’t support rollback of changes when errors occurs




                                                             | Sector, Alliance, Offering
Performance issues

 The application slow
  •   Too many database queries
  •   Too heavy database queries
  •   Lazy loading
  •   Poorly generated SQL by the ORM framework




                                                  | Sector, Alliance, Offering
Security issues

 Vulnerable to SQL Injection
 Users get access to data they should not have access too




                                                             | Sector, Alliance, Offering
Quality issues

 Many bugs
  • No tests
  • ... or tests that doesn’t test the important stuff




                                                         | Sector, Alliance, Offering
How to solve these issues


                  | Sector, Alliance, Offering
What do we want?
 Well structured data access code that is easy to maintain
   • Small simple classes that does only one thing - Single Responsiblity Principle
 The application should be fast
   • Only retrieve the data that we actually need – Criteria Pattern
   • Do as much as possible in one query – SQL Joins
   • Avoid lazy loading
 The application should be secure
   • Use an ORM framework and/or use parameters instead of concatenated strings
   • Always check for permissions when retrieving, creating, updating or deleting data
 Rollback uncomitted changes if anything goes wrong
   • Transaction support
 As little dependency on the ORM as possible
   • Gateway Pattern
 Frontend, Business and Data Access Code should be separated
   • Logical Layering
 High quality – Bug free code
   • Integration tests
                                                                                      | Sector, Alliance, Offering
Example code


      | Sector, Alliance, Offering
HOW TO:
REDUCE ORM DEPENDENCIES
STRICTER LAYERING
ROLLBACK IF ERROR OCCURS
HAVE SIMPLE DATA ACCESS CODE
                               | Sector, Alliance, Offering
The Common Way
                                Frontend
                                 Layer




                                Business
ORM
                                 Layer
          Query the Database




                               Data Access
                                  Layer



                                       | Sector, Alliance, Offering
A Better Way
                                               Frontend
                                                Layer

                     ORM
                    Gateway

     Initialize ORM                            Business
Transaction management                          Layer

                         ORM


                                              Data Access
                                                 Layer




                                                | Sector, Alliance, Offering
DbContexGateway for FluentData




                                 | Sector, Alliance, Offering
Data Access Layer




                    | Sector, Alliance, Offering
Business Layer




                 | Sector, Alliance, Offering
Frontend Layer




                 | Sector, Alliance, Offering
EFFICIENT DATA RETRIEVAL & FILTERING

                               | Sector, Alliance, Offering
Overview

 Frontend     Criteria Pattern: Decide what data to retrieve and filter on
  Class




 Business     Business logic
  Class




Data Access
   Class      Construct the most optimal and secure query



                                                            | Sector, Alliance, Offering
Frontend Layer




                 | Sector, Alliance, Offering
Business Layer




                 | Sector, Alliance, Offering
Data Access Layer




                    | Sector, Alliance, Offering
Overview

 Frontend     Transaction management
  Layer       Decide what data to retrieve and filter on




 Business     Business logic
  Layer




Data Access
   Layer      Construct the most optimal and secure query



                                                           | Sector, Alliance, Offering
HOW TO:
GET A HIGH QUALITY APPLICATION
THROUGH INTEGRATION TESTS
                                 | Sector, Alliance, Offering
Test - CreateProductDbCommand




                                | Sector, Alliance, Offering
Test - GetProductsDbCommand




                              | Sector, Alliance, Offering
Summary

   Have small simple classes that does only one thing
   Use the Criteria Pattern to decide what data to retrieve
   Use joins to retrieve as much data as needed in one query
   Avoid lazy loading
   Use parameters instead of concatenated strings
   Always check for permissions when retrieving, creating, updating or
    deleting data
   Use transactions to rollback when errors occurs
   Use the Gateway Pattern to reduce ORM dependency
   Have a strict Frontend layer, Business layer, Data Access layer
   Verify quality through Integration Tests
                                                             | Sector, Alliance, Offering
QUESTIONS?

             | Sector, Alliance, Offering
www.capgemini.com



The information contained in this presentation is proprietary. ©2010 Capgemini. All rights reserved

More Related Content

What's hot

Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1Sonia Mim
 
Adbms 40 heuristics in query optimization
Adbms 40 heuristics in query optimizationAdbms 40 heuristics in query optimization
Adbms 40 heuristics in query optimizationVaibhav Khanna
 
Object Oriented Database Management System
Object Oriented Database Management SystemObject Oriented Database Management System
Object Oriented Database Management SystemAjay Jha
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbmsRituBhargava7
 
Managing and sharing data
Managing and sharing dataManaging and sharing data
Managing and sharing dataSarah Jones
 
Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Jotham Gadot
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management systemPooja Dixit
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture NotesJasour Obeidat
 
Major issues in data mining
Major issues in data miningMajor issues in data mining
Major issues in data miningYashwant Rautela
 
Database administrator
Database administratorDatabase administrator
Database administratorTech_MX
 
Database Administration
Database AdministrationDatabase Administration
Database AdministrationBilal Arshad
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and securityDhani Ahmad
 
Database security
Database securityDatabase security
Database securityBirju Tank
 
Less12 maintenance
Less12 maintenanceLess12 maintenance
Less12 maintenanceAmit Bhalla
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and BasicsSHIKHA GAUTAM
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database SystemMeghaj Mallick
 
Introduction to distributed database
Introduction to distributed databaseIntroduction to distributed database
Introduction to distributed databaseSonia Panesar
 

What's hot (20)

Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1
 
Adbms 40 heuristics in query optimization
Adbms 40 heuristics in query optimizationAdbms 40 heuristics in query optimization
Adbms 40 heuristics in query optimization
 
Basic DBMS ppt
Basic DBMS pptBasic DBMS ppt
Basic DBMS ppt
 
Object Oriented Database Management System
Object Oriented Database Management SystemObject Oriented Database Management System
Object Oriented Database Management System
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
 
Managing and sharing data
Managing and sharing dataManaging and sharing data
Managing and sharing data
 
Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01Fundamentals of Database ppt ch01
Fundamentals of Database ppt ch01
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management system
 
DBA
DBADBA
DBA
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture Notes
 
Major issues in data mining
Major issues in data miningMajor issues in data mining
Major issues in data mining
 
Database administrator
Database administratorDatabase administrator
Database administrator
 
Database Administration
Database AdministrationDatabase Administration
Database Administration
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and security
 
Database security
Database securityDatabase security
Database security
 
Less12 maintenance
Less12 maintenanceLess12 maintenance
Less12 maintenance
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and Basics
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database System
 
Database security
Database securityDatabase security
Database security
 
Introduction to distributed database
Introduction to distributed databaseIntroduction to distributed database
Introduction to distributed database
 

Viewers also liked

Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeLars-Erik Kindblad
 
Data Access
Data AccessData Access
Data Accesseclumson
 
Metadata standards
Metadata standardsMetadata standards
Metadata standardsmakammer
 
Introduction to Metadata Standards
Introduction to Metadata StandardsIntroduction to Metadata Standards
Introduction to Metadata StandardsDavid Massart
 
AAUP 2014--Metadata Standards
AAUP 2014--Metadata StandardsAAUP 2014--Metadata Standards
AAUP 2014--Metadata StandardsBowker
 
Webinar: Responsive Design
Webinar: Responsive DesignWebinar: Responsive Design
Webinar: Responsive Designkuehlhaus AG
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Lars-Erik Kindblad
 
Responsive Design - Quick & Dirty
Responsive Design - Quick & DirtyResponsive Design - Quick & Dirty
Responsive Design - Quick & DirtyArno Selhorst
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiLars-Erik Kindblad
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeLars-Erik Kindblad
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMLars-Erik Kindblad
 
Avoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsAvoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsLars-Erik Kindblad
 
How to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsHow to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsLars-Erik Kindblad
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014Lars-Erik Kindblad
 
Anforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenAnforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenChristian Baranowski
 
Domain Driven Design und Nosql
Domain Driven Design und Nosql Domain Driven Design und Nosql
Domain Driven Design und Nosql ArangoDB Database
 
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMarkus Greve
 

Viewers also liked (20)

The Fluent Interface Pattern
The Fluent Interface PatternThe Fluent Interface Pattern
The Fluent Interface Pattern
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best Practice
 
Data Access
Data AccessData Access
Data Access
 
Metadata standards
Metadata standardsMetadata standards
Metadata standards
 
Introduction to Metadata Standards
Introduction to Metadata StandardsIntroduction to Metadata Standards
Introduction to Metadata Standards
 
AAUP 2014--Metadata Standards
AAUP 2014--Metadata StandardsAAUP 2014--Metadata Standards
AAUP 2014--Metadata Standards
 
Ready or not: No UI vom Verschwinden des Graphical User Interfaces
Ready or not: No UI vom Verschwinden des Graphical User InterfacesReady or not: No UI vom Verschwinden des Graphical User Interfaces
Ready or not: No UI vom Verschwinden des Graphical User Interfaces
 
Webinar: Responsive Design
Webinar: Responsive DesignWebinar: Responsive Design
Webinar: Responsive Design
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)
 
Responsive Design - Quick & Dirty
Responsive Design - Quick & DirtyResponsive Design - Quick & Dirty
Responsive Design - Quick & Dirty
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, Capgemini
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best Practice
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORM
 
Avoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsAvoid code duplication! Principles & Patterns
Avoid code duplication! Principles & Patterns
 
How to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsHow to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systems
 
Systementwurf mit UML
Systementwurf mit UMLSystementwurf mit UML
Systementwurf mit UML
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014
 
Anforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenAnforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML Grundlagen
 
Domain Driven Design und Nosql
Domain Driven Design und Nosql Domain Driven Design und Nosql
Domain Driven Design und Nosql
 
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
 

Similar to Data Access - Best Practice

Aras Vision and Roadmap with Aras Innovator PLM Software
Aras Vision and Roadmap with Aras Innovator PLM SoftwareAras Vision and Roadmap with Aras Innovator PLM Software
Aras Vision and Roadmap with Aras Innovator PLM SoftwareAras
 
Aras PLM Roadmap
Aras PLM RoadmapAras PLM Roadmap
Aras PLM RoadmapAras
 
Next Generation Datacenter Oracle - Alan Hartwell
Next Generation Datacenter Oracle - Alan HartwellNext Generation Datacenter Oracle - Alan Hartwell
Next Generation Datacenter Oracle - Alan HartwellHPDutchWorld
 
Oracle - Next Generation Datacenter - Alan Hartwell
Oracle - Next Generation Datacenter - Alan HartwellOracle - Next Generation Datacenter - Alan Hartwell
Oracle - Next Generation Datacenter - Alan HartwellHPDutchWorld
 
Solix Corporate Overview
Solix Corporate OverviewSolix Corporate Overview
Solix Corporate OverviewKunal Grover
 
Deciding to go cloud 09212010
Deciding to go cloud  09212010Deciding to go cloud  09212010
Deciding to go cloud 09212010ERwin Modeling
 
Performance Monitoring and Testing in the Salesforce Cloud
Performance Monitoring and Testing in the Salesforce CloudPerformance Monitoring and Testing in the Salesforce Cloud
Performance Monitoring and Testing in the Salesforce CloudSalesforce Developers
 
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...InSync2011
 
A perspective on cloud computing and enterprise saa s applications
A perspective on cloud computing and enterprise saa s applicationsA perspective on cloud computing and enterprise saa s applications
A perspective on cloud computing and enterprise saa s applicationsGeorge Milliken
 
Data Mining
Data MiningData Mining
Data Miningswami920
 
Opening Data for Fun and Profit
Opening Data for Fun and Profit Opening Data for Fun and Profit
Opening Data for Fun and Profit 3scale
 
Extending The Value Of Oracle Crm On Demand Through Cloud Based Extensibility
Extending The Value Of Oracle Crm On Demand Through Cloud Based ExtensibilityExtending The Value Of Oracle Crm On Demand Through Cloud Based Extensibility
Extending The Value Of Oracle Crm On Demand Through Cloud Based ExtensibilityJerome Leonard
 
Metadata Use Cases
Metadata Use CasesMetadata Use Cases
Metadata Use Casesdmurph4
 
Crm On Demand For 2009
Crm On Demand For 2009Crm On Demand For 2009
Crm On Demand For 2009prospectordie
 
Metadata Use Cases You Can Use
Metadata Use Cases You Can UseMetadata Use Cases You Can Use
Metadata Use Cases You Can Usedmurph4
 
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy Modeler
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy ModelerRole Discovery and RBAC Design: A Case Study with IBM Role and Policy Modeler
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy ModelerProlifics
 
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...ORACLE USER GROUP ESTONIA
 

Similar to Data Access - Best Practice (20)

Aras Vision and Roadmap with Aras Innovator PLM Software
Aras Vision and Roadmap with Aras Innovator PLM SoftwareAras Vision and Roadmap with Aras Innovator PLM Software
Aras Vision and Roadmap with Aras Innovator PLM Software
 
Aras PLM Roadmap
Aras PLM RoadmapAras PLM Roadmap
Aras PLM Roadmap
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
 
Next Generation Datacenter Oracle - Alan Hartwell
Next Generation Datacenter Oracle - Alan HartwellNext Generation Datacenter Oracle - Alan Hartwell
Next Generation Datacenter Oracle - Alan Hartwell
 
Oracle - Next Generation Datacenter - Alan Hartwell
Oracle - Next Generation Datacenter - Alan HartwellOracle - Next Generation Datacenter - Alan Hartwell
Oracle - Next Generation Datacenter - Alan Hartwell
 
Solix Corporate Overview
Solix Corporate OverviewSolix Corporate Overview
Solix Corporate Overview
 
Deciding to go cloud 09212010
Deciding to go cloud  09212010Deciding to go cloud  09212010
Deciding to go cloud 09212010
 
Performance Monitoring and Testing in the Salesforce Cloud
Performance Monitoring and Testing in the Salesforce CloudPerformance Monitoring and Testing in the Salesforce Cloud
Performance Monitoring and Testing in the Salesforce Cloud
 
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...
E-Business Suite 2 _ Ben Davis _ Achieving outstanding optim data management ...
 
A perspective on cloud computing and enterprise saa s applications
A perspective on cloud computing and enterprise saa s applicationsA perspective on cloud computing and enterprise saa s applications
A perspective on cloud computing and enterprise saa s applications
 
Data Mining
Data MiningData Mining
Data Mining
 
Opening Data for Fun and Profit
Opening Data for Fun and Profit Opening Data for Fun and Profit
Opening Data for Fun and Profit
 
Extending The Value Of Oracle Crm On Demand Through Cloud Based Extensibility
Extending The Value Of Oracle Crm On Demand Through Cloud Based ExtensibilityExtending The Value Of Oracle Crm On Demand Through Cloud Based Extensibility
Extending The Value Of Oracle Crm On Demand Through Cloud Based Extensibility
 
Metadata Use Cases
Metadata Use CasesMetadata Use Cases
Metadata Use Cases
 
IBM IT Operations Analytics for z Systems
IBM IT Operations Analytics for z SystemsIBM IT Operations Analytics for z Systems
IBM IT Operations Analytics for z Systems
 
IBM IT Operations Analytics for z systems
IBM IT Operations Analytics for z systemsIBM IT Operations Analytics for z systems
IBM IT Operations Analytics for z systems
 
Crm On Demand For 2009
Crm On Demand For 2009Crm On Demand For 2009
Crm On Demand For 2009
 
Metadata Use Cases You Can Use
Metadata Use Cases You Can UseMetadata Use Cases You Can Use
Metadata Use Cases You Can Use
 
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy Modeler
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy ModelerRole Discovery and RBAC Design: A Case Study with IBM Role and Policy Modeler
Role Discovery and RBAC Design: A Case Study with IBM Role and Policy Modeler
 
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...
Oracle Software.Hardware.Complete positioning versus competition - Shahin Tar...
 

Recently uploaded

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Data Access - Best Practice

  • 1. Data Access – Best Practice Lars-Erik Kindblad Senior Consultant Blog: kindblad.com
  • 2. Agenda  Why is Data Access so important?  Common issues in many applications  How to solve these issues  Summary | Sector, Alliance, Offering
  • 3. Why is Data Access so important?  Retrieving, creating, updating and deleting data are core operations  Affects the entire application in a bad way if done incorrectly | Sector, Alliance, Offering
  • 4. Common issues in many applications | Sector, Alliance, Offering
  • 5. Code issues  The code in the data access layer is often put into a single or a few huge classes • Hard to maintain  Database queries are constructed in the frontend or business layer • Leads to messy frontend or business code  ORM framework limitations or lack of «ORM masters» • A lot of quickfixes  Doesn’t support rollback of changes when errors occurs | Sector, Alliance, Offering
  • 6. Performance issues  The application slow • Too many database queries • Too heavy database queries • Lazy loading • Poorly generated SQL by the ORM framework | Sector, Alliance, Offering
  • 7. Security issues  Vulnerable to SQL Injection  Users get access to data they should not have access too | Sector, Alliance, Offering
  • 8. Quality issues  Many bugs • No tests • ... or tests that doesn’t test the important stuff | Sector, Alliance, Offering
  • 9. How to solve these issues | Sector, Alliance, Offering
  • 10. What do we want?  Well structured data access code that is easy to maintain • Small simple classes that does only one thing - Single Responsiblity Principle  The application should be fast • Only retrieve the data that we actually need – Criteria Pattern • Do as much as possible in one query – SQL Joins • Avoid lazy loading  The application should be secure • Use an ORM framework and/or use parameters instead of concatenated strings • Always check for permissions when retrieving, creating, updating or deleting data  Rollback uncomitted changes if anything goes wrong • Transaction support  As little dependency on the ORM as possible • Gateway Pattern  Frontend, Business and Data Access Code should be separated • Logical Layering  High quality – Bug free code • Integration tests | Sector, Alliance, Offering
  • 11. Example code | Sector, Alliance, Offering
  • 12. HOW TO: REDUCE ORM DEPENDENCIES STRICTER LAYERING ROLLBACK IF ERROR OCCURS HAVE SIMPLE DATA ACCESS CODE | Sector, Alliance, Offering
  • 13. The Common Way Frontend Layer Business ORM Layer Query the Database Data Access Layer | Sector, Alliance, Offering
  • 14. A Better Way Frontend Layer ORM Gateway Initialize ORM Business Transaction management Layer ORM Data Access Layer | Sector, Alliance, Offering
  • 15. DbContexGateway for FluentData | Sector, Alliance, Offering
  • 16. Data Access Layer | Sector, Alliance, Offering
  • 17. Business Layer | Sector, Alliance, Offering
  • 18. Frontend Layer | Sector, Alliance, Offering
  • 19. EFFICIENT DATA RETRIEVAL & FILTERING | Sector, Alliance, Offering
  • 20. Overview Frontend Criteria Pattern: Decide what data to retrieve and filter on Class Business Business logic Class Data Access Class Construct the most optimal and secure query | Sector, Alliance, Offering
  • 21. Frontend Layer | Sector, Alliance, Offering
  • 22. Business Layer | Sector, Alliance, Offering
  • 23. Data Access Layer | Sector, Alliance, Offering
  • 24. Overview Frontend Transaction management Layer Decide what data to retrieve and filter on Business Business logic Layer Data Access Layer Construct the most optimal and secure query | Sector, Alliance, Offering
  • 25. HOW TO: GET A HIGH QUALITY APPLICATION THROUGH INTEGRATION TESTS | Sector, Alliance, Offering
  • 26. Test - CreateProductDbCommand | Sector, Alliance, Offering
  • 27. Test - GetProductsDbCommand | Sector, Alliance, Offering
  • 28. Summary  Have small simple classes that does only one thing  Use the Criteria Pattern to decide what data to retrieve  Use joins to retrieve as much data as needed in one query  Avoid lazy loading  Use parameters instead of concatenated strings  Always check for permissions when retrieving, creating, updating or deleting data  Use transactions to rollback when errors occurs  Use the Gateway Pattern to reduce ORM dependency  Have a strict Frontend layer, Business layer, Data Access layer  Verify quality through Integration Tests | Sector, Alliance, Offering
  • 29. QUESTIONS? | Sector, Alliance, Offering
  • 30. www.capgemini.com The information contained in this presentation is proprietary. ©2010 Capgemini. All rights reserved

Editor's Notes

  1. MaintainPerformanceSecurityTransactionsLazy LoadingORMDbCommandTestingSQL / Mangelpå joins