Design Pattern Framework 4.5
Copyright © Data & Object Factory, LLC. All rights reserved. Page 2 of 104
Index
Index.............................................................................................................................................................. 2
Introduction .................................................................................................................................................. 6
Document.................................................................................................................................................. 6
What is Spark 4.5 .......................................................................................................................................... 7
Overview ................................................................................................................................................... 7
Selecting data ........................................................................................................................................ 7
Ad-hoc queries ...................................................................................................................................... 9
Insert, update, and delete..................................................................................................................... 9
MicroORM ........................................................................................................................................... 10
Spark Features ........................................................................................................................................ 11
Full stack.............................................................................................................................................. 11
Prescriptive ......................................................................................................................................... 11
Simple .................................................................................................................................................. 11
Light-weight ........................................................................................................................................ 12
Agile .................................................................................................................................................... 12
Rapid Application Development (RAD) ............................................................................................... 12
Architecture ........................................................................................................................................ 12
Design Patterns ................................................................................................................................... 15
Practices .............................................................................................................................................. 15
Tools .................................................................................................................................................... 16
Conclusion ........................................................................................................................................... 16
What is Art Shop ......................................................................................................................................... 16
Art Shop Walkthrough ............................................................................................................................ 16
Product Details ........................................................................................................................................ 21
Shopping Cart and Checkout................................................................................................................... 22
Authentication and Authorization .......................................................................................................... 23
Administration ........................................................................................................................................ 27
Reports ................................................................................................................................................ 29
Dashboard ........................................................................................................................................... 32
Design Pattern Framework 4.5
Copyright © Data & Object Factory, LLC. All rights reserved. Page 3 of 104
Ad Hoc ................................................................................................................................................. 32
REST ......................................................................................................................................................... 34
Solution and projects .................................................................................................................................. 35
Project: Art.Web ..................................................................................................................................... 36
Project: Art.Domain ................................................................................................................................ 38
Project: Art.Rest.v1 ................................................................................................................................. 40
Project: Art.Rest.v1.Text ......................................................................................................................... 40
Code Review................................................................................................................................................ 41
Database ................................................................................................................................................. 41
Domain Generator .................................................................................................................................. 47
Data Layer ............................................................................................................................................... 49
The Data Layer in detail: Db class ....................................................................................................... 49
Domain Layer .......................................................................................................................................... 51
The Domain Layer in detail: Entity class ............................................................................................. 56
Repository Layer ..................................................................................................................................... 57
Context ................................................................................................................................................ 59
Unit of Work ........................................................................................................................................ 60
Building Domain projects with Spark 4.5 ................................................................................................ 62
Multiple databases.................................................................................................................................. 62
Presentation Layer .................................................................................................................................. 63
App_Data and App_Start .................................................................................................................... 63
Areas ................................................................................................................................................... 64
Code Folder ......................................................................................................................................... 69
Content Folder .................................................................................................................................... 72
Scripts Folder ...................................................................................................................................... 72
Views Folder ........................................................................................................................................ 72
Global.asax.cs ...................................................................................................................................... 72
Web.Config.......................................................................................................................................... 72
REST Layer ............................................................................................................................................... 73
Design Patterns ........................................................................................................................................... 77
Active Record .......................................................................................................................................... 78
Repository ............................................................................................................................................... 78
Design Pattern Framework 4.5
Copyright © Data & Object Factory, LLC. All rights reserved. Page 4 of 104
Unit of Work ............................................................................................................................................ 78
Façade ..................................................................................................................................................... 79
DTO ......................................................................................................................................................... 79
CQRS ........................................................................................................................................................ 79
Miscellaneous Patterns ........................................................................................................................... 80
MV* Patterns ...................................................................................................................................... 80
GOF Patterns ....................................................................................................................................... 80
Enterprise Patterns ............................................................................................................................. 81
Best Practices .............................................................................................................................................. 81
Convention over Configuration ............................................................................................................... 82
Constraints over Lookups........................................................................................................................ 82
Caching .................................................................................................................................................... 83
JSON over XML ........................................................................................................................................ 84
Tools and Components ............................................................................................................................... 84
Tools ........................................................................................................................................................ 84
Automapper ........................................................................................................................................ 85
Json.NET .............................................................................................................................................. 85
Bootstrap ............................................................................................................................................ 85
jQuery .................................................................................................................................................. 86
jQuery UI ............................................................................................................................................. 86
History.js ............................................................................................................................................. 86
Flot ...................................................................................................................................................... 86
Components ............................................................................................................................................ 86
Caching ................................................................................................................................................ 87
Custom Principals ................................................................................................................................ 87
Service layer ........................................................................................................................................ 88
Error logging ........................................................................................................................................ 88
JavaScript and jQuery.......................................................................................................................... 89
Building apps with Spark 4.5 ....................................................................................................................... 90
Solution and Projects .............................................................................................................................. 90
Creating the Database ............................................................................................................................ 93
Building the Web project ........................................................................................................................ 95
Design Pattern Framework 4.5
Copyright © Data & Object Factory, LLC. All rights reserved. Page 5 of 104
Building the Domain project ................................................................................................................... 96
Hand-coding the Domain project ........................................................................................................ 98
Building the REST project ........................................................................................................................ 99
Hand-coding the REST project .......................................................................................................... 101
Building the REST Test project .............................................................................................................. 101
Summary ................................................................................................................................................... 104