SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Cloud Security
Cloud SecurityCloud Security
Cloud Security
 
When Cyber Security Meets Machine Learning
When Cyber Security Meets Machine LearningWhen Cyber Security Meets Machine Learning
When Cyber Security Meets Machine Learning
 
Data breach presentation
Data breach presentationData breach presentation
Data breach presentation
 
Cyber attack
Cyber attackCyber attack
Cyber attack
 
Computer Security
Computer SecurityComputer Security
Computer Security
 
cyber security and threats.pptx
cyber security and threats.pptxcyber security and threats.pptx
cyber security and threats.pptx
 
Cyber security and demonstration of security tools
Cyber security and demonstration of security toolsCyber security and demonstration of security tools
Cyber security and demonstration of security tools
 
Introduction to Information Security
Introduction to Information Security Introduction to Information Security
Introduction to Information Security
 
Cyber security
Cyber securityCyber security
Cyber security
 
Introduction to ethical hacking
Introduction to ethical hackingIntroduction to ethical hacking
Introduction to ethical hacking
 
IoT - Attacks and Solutions
IoT - Attacks and SolutionsIoT - Attacks and Solutions
IoT - Attacks and Solutions
 
what is data security full ppt
what is data security full pptwhat is data security full ppt
what is data security full ppt
 
Security Awareness Training by Fortinet
Security Awareness Training by FortinetSecurity Awareness Training by Fortinet
Security Awareness Training by Fortinet
 
Cyber Security Vulnerabilities
Cyber Security VulnerabilitiesCyber Security Vulnerabilities
Cyber Security Vulnerabilities
 
Endpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEyeEndpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEye
 
Brute force attack
Brute force attackBrute force attack
Brute force attack
 
Cloud Security
Cloud SecurityCloud Security
Cloud Security
 
Network security
Network securityNetwork security
Network security
 
Data security
Data securityData security
Data security
 
Security vulnerability
Security vulnerabilitySecurity vulnerability
Security vulnerability
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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...
 

Kürzlich hochgeladen

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Kürzlich hochgeladen (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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

Hinweis der Redaktion

  1. MaintainPerformanceSecurityTransactionsLazy LoadingORMDbCommandTestingSQL / Mangelpå joins