Your SlideShare is downloading. ×
0
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
DataClass Case Study #1: Solving the Duplication Problem
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

DataClass Case Study #1: Solving the Duplication Problem

299

Published on

There has always been a problem of duplication with regards to database and client code. These are the slides I use to demonstrate how that problem can be solved using DataClass. …

There has always been a problem of duplication with regards to database and client code. These are the slides I use to demonstrate how that problem can be solved using DataClass.

DataClass's official website: http://dataclass.hexsw.com/

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
299
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DataClass™ Case Studies Problem 1: Duplication
  • 2. Duplication <ul><li>A single change in multiple places
  • 3. Not all duplications are created equal
  • 4. Compiled symbols only duplicate logical name
  • 5. Magic strings duplicate data
  • 6. Copy-and-paste duplicates behavior </li></ul>
  • 7. Example of Duplication public class MyQueryRunner { public int RunMyQuery(IDbConnection conn) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = @&amp;quot;SELECT MAX([Tons]) FROM [Grapes] INNER JOIN [Fungi] ON [Grapes].[InfectionID] = [Fungi].[ID] WHERE [Fungi].[Name] = &apos;botrytis cinerea&apos;&amp;quot;; return (int)cmd.ExecuteScalar(); } } } CREATE TABLE Fungi([ID] UniqueIdentifier, [Name] NVARCHAR(200)) -- populate table INSERT INTO Fungi([ID], [Name]) VALUES(newid(), &apos;botrytis cinerea&apos;) CREATE TABLE Grapes([Variety] NVARCHAR(50), [Tons] INT, [InfectionID] UniqueIdentifier)
  • 8. Single Logical Document <ul><li>Application service providers generally same platform as consumers
  • 9. Database service providers typically not
  • 10. Two logical documents: </li><ul><li>Create/upgrade database (SQL)
  • 11. Converse with database (C#, Java, XML, etc.) </li></ul></ul>
  • 12. DataClass™ Changes This <ul><li>One logical document defines </li><ul><li>Interface
  • 13. Construction
  • 14. Behavior </li></ul><li>Distinguishes logical design from physical
  • 15. ...just like a real class </li></ul>
  • 16. Example Database Class (Part I) namespace HexagonSoftware.DataClass.Examples { database WineProductionDataStore { stereotypes table, column, values, value; version 1.0 : initialized { design { public table Grapes { public column Identity (&amp;quot;ID&amp;quot;); public column Tons; public column InfectionIdentity (&amp;quot;InfectionID&amp;quot;); } public table Fungi { public column Identity (&amp;quot;ID&amp;quot;); public column Name; public values KnownFungi { public value NobleRot with Name = &apos;botrytis cinerea&apos;; } } } } } }
  • 17. Example Database Class (Part II) // in version 1.0 construction { in context Fungi { step sql { CREATE TABLE [$[Fungi]]([$[Identity]] UNIQUEIDENTIFIER, [$[Name]] NVARCHAR(50)) } step sql { INSERT INTO [$[Fungi]]([$[Identity]], [$[Name]]) VALUES(newid(), &apos;$[KnownFungi.NobleRot.Name]&apos;) } } in context Grapes { step sql { CREATE TABLE [$[Grapes]]( [$[Identity]] UniqueIdentifier, [$[Tons]] INT, [$[InfectionIdentity]] UniqueIdentifier) } } }
  • 18. Example Database Class Usage using DBDesign = WineProductionDataStore.Design._1_0; public class MyQueryRunner { public int RunMyQuery(IDbConnection conn) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = string.Format( @&amp;quot;SELECT MAX([{0}]) FROM [{1}] INNER JOIN [{2}] ON [{3}].[{4}] = [{2}].[{5}] WHERE [{2}].[{6}] = &apos;{7}&apos;&amp;quot;, DBDesign.Grapes.Tons.GetPhysicalName(), DBDesign.Grapes.GetPhysicalName(), DBDesign.Fungi.GetPhysicalName(), DBDesign.Grapes.InfectionIdentity.GetPhysicalName(), DBDesign.Fungi.Identity.GetPhysicalName(), DBDesign.Fungi.Name.GetPhysicalName(), DBDesign.Fungi.KnownFungi.NobleRot.Name ); return (int)cmd.ExecuteScalar(); } } }
  • 19. Other Topics <ul><li>Version management
  • 20. Coupling clients to the right version
  • 21. Minimizing cost of interface </li></ul>

×