• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Data Access   Tech Ed India
 

Data Access Tech Ed India

on

  • 821 views

 

Statistics

Views

Total Views
821
Views on SlideShare
820
Embed Views
1

Actions

Likes
1
Downloads
16
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • To get data out of a database, you have to issue T-SQL statements to it. Scattering these statements throughout the business logic makes the solution more difficult to manage/troubleshoot.Dependencies go out from the DAL! The arrows are showing flow and dependencies.Quality AttributesSeparation of ConcernsEvolvabilityTestabilityPerformance
  • Most of us know that the practices a team uses when building a solution has a tremendous influence on the code that implements the ultimate solution. Also, the technologies used can either make that process easier or harder. Unit testing is a prime example. So for this project, we’re going to start with building a reference implementation and be very transparent about the process by which we build it. We’ve began with domain modeling and TDD as primary practices and (because we’re only in our second iteration) are considering a switch to a more BDD approach. So let’s talk about the scenario.The goal of the solution is pretty simple – it’s just to broker sales between retailers who are selling products and customers who are buying them. We represent the broker who is building the solution and mostly interested in collecting a percentage of each sale … and we have to manage the solution too of course. Hopefully this diagram will give you sense of the products and technologies we’re going to use and the main things the solution will have to do. We feel pretty good about this scenario because if you’ve used Amazon, it should be familiar to your, and the domain model has an appropriate level of complexity.
  • If you would like to host your demo on the Virtual Server, please use the myVPC demo slide, not this slide.

Data Access   Tech Ed India Data Access Tech Ed India Presentation Transcript

  • Don Smith, Program Manager Microsoft patterns & practices
  • Agenda The data access layer and your options Patterns for keeping entities consistent Patterns for managing entity differences Data access technology assessment Other data access challenges Summary and questions
  • Layers & Relationships Business Business Data Data Logic Data Access Layer Logic Storage Storage Layer Layer Considerations Two Options Domain complexity Keep Developer experience entities Greenfield vs. brownfield consistent Desired approach: data, Manage their code, or model first? differences Object/schema fidelity
  • Keeping Entities Consistent Recommended when Common patterns domain is less complex Row Data Gateway Restricts object-oriented Table Data Gateway design options Table Module Can benefit from code Active Record generation strategies Record Set More difficult to evolve over time, but easier to We have choices manage Shape of the objects How to combine data and logic
  • Pre-Built Types when objects and schema have a simple relationship Record Set (DataSet) TableDataGateway Contains the data as rows Find() : RecordSet and columns Update(a, b, c) Insert(a, b, c) Table Data Gateway Delete(id) RecordSet Encapsulates all SQL Rows Can return record sets Columns Table Module TableModule Accepts a record set Process(RecordSet) Contains business logic Calculate(RecordSet)
  • Custom Types when objects and schema have a simple relationship Row Data Gateway RowDataGateway Represents a table’s row ID : long ActiveRecord Includes all CRUD FirstName : string ID : long capability LastName : string FirstName : string Update(first, last) Transaction Script Insert(first, last) LastName : string Update(first, last) Contains business logic Delete(id) Insert(first, last) Active Record Delete(id) Represents a table’s row Process() Contains business logic TransactionScript Includes all CRUD ProcessCostChange() capability CalculateAdjustment()
  • Managing Entity Differences Appropriate for Common patterns complex domain logic Domain Model Requires more Data Mapper developer experience Repository Can leverage more OO Unit of Work (GoF) design patterns Specification Appropriate for apps that evolve over time
  • Storefront Overview Customer Retailer IE WPF ASP.NET Data MVC Services • Searches for • Manages product products information • Buys products • Maintains • Views order SQL inventory Server status • Processes and • Rates products ships orders and retailers Broker • Collects a percentage from each sale • Views sales & site usage reports Silverlight
  • Storefront Reference Implementation
  • Domain Model & Mapping Domain Model Data Mapper An object model that Represents an association of represents the domain types and properties across the Contains the combination of domain model and data model data and business logic Almost always aware of the Two basic options data access technology May be robust and leverage OO Implementations are often principles included in O/RM solutions May be straightforward in less Mapping support varies complex scenarios May have no knowledge of data access technology
  • Repository Collection-type interface to data access Repository Mediates between GetById(id) domain model GetAll() Add(object) and mapper Update(object) Delete(id) Implementations are specific to a technology
  • Unit of Work Maintains a list of new, changed and deleted UnitOfWork objects and coordinates SubmitChanges() persisting changes CancelChanges() Can be used across multiple repositories
  • Specification/Query Object An object that represents the criteria of a query Allows queries to be Specification easier to manage Field : string Value : object Avoids the need for a Operator : OpEnum method for each query
  • Technology Assessment ADO.NET DataSet DataAdapter DataReader LINQ to SQL O/RM for simple mappings ADO.NET Entity Framework O/RM for more complex mappings
  • Related Challenges Domain Model Responsibilities Serialization (DTOs) Data binding Edit tracking Validation Domain Model Representations Subset of the type View models
  • Summary Steps for making choices 1. Determine consistency possibilities between the domain model and the data model Keep entities consistent Manage their differences 2. Choose shape of the types Pre-built Custom built 3. Determine how to attach the business logic Influenced by the shape of the types
  • Resources Don’s email: dons@microsoft.com Project’s community site: http://dataguidance.codeplex.com Patterns of Enterprise Application Architecture http://www.martinfowler.com/eaaCatalog The Microsoft Patterns & Practices Team http://microsoft.com/practices
  • © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Video Title
  • Announcement Title
  • PowerPoint Template Subtitle color Set the slide title in “title case” and subheads in “sentence case” The subhead color is defined for this template as the fourth font color from the left Font Size Requirements Main bullet points must not be smaller than 24pt Do NOT use any font size lower than 20pt Set subhead to 36pt or smaller so it will fit on a single line Turn off Auto Resizing on all text boxes
  • PowerPoint Guidelines Font, size, and color for text have been formatted for you in the Slide Master Use the color palette shown below See next slide for additional guidelines Hyperlink color: www.microsoft.com Sample Sample Sample Sample Sample Fill Fill Fill Fill Fill Sample Sample Sample Sample Sample Fill Fill Fill Fill Fill
  • Instructions on Color Readability Colors are brighter when projected, so contrast and readability are diminished Use black or dark gray text only on these colors Sample Sample Use white text only on these colors Sample Sample Sample Sample Sample Sample Sample Sample
  • Slide for Showing Software Code Use this layout to show software code The font is Consolas, a monospace font The slide doesn’t use bullets but levels can be indented using the “Increase List Level” icon on the Home menu To use straight quotes quot; instead of smart quotes ”, do this: 1.Click on the Office Button in the upper left corner 2.At the bottom of the menu, choose PowerPoint Options 3.From the left pane, select Proofing 4.Click on the AutoCorrect Options button 5.Select the AutoFormat As You Type tab, and deselect “Straight quotes” with “smart quotes”. Then Click OK.
  • Table Format Table Title Column 1 Column 2 Column 3 Column 4 Column 5
  • Bar Chart Example Chart Title Series 1 Series 2 Series 3 5 4.3 4.4 4.5 3.5 3 2.8 2.4 2.5 2 2 1.8 Category 1 Category 2 Category 3 Category 4
  • Pie Chart Example Chart Title 10% 9% 1st Qtr 23% 58%
  • Related Content Breakout Sessions (session codes and titles) Interactive Theater Sessions (session codes and titles) Hands-on Labs (session codes and titles) Hands-on Labs (session codes and titles)
  • Track Resources Resource 1 Resource 2 Resource 3 Resource 4