The Other 2.0
The Other 2.0
0
Architectural
Patterns and Styles
Relevant Technologies
l Authentication
l Authorization
l Caching
l Coupling and Cohesion
l Exception Management
l Logging, Auditing, and Instrumentation
l Validation
Relevant Design Patterns
Data Layer Guidelines
Specific Design Issues
l Batching
l Binary Large Objects (BLOBs)
l Connections
l Data Format
l Exception Management
l Object Relational Mapping
l Queries
l Stored Procedures
l Stored Procedures vs. Dynamic SQL
l Transactions
l Validation
l XML
Stored Procedures
In the past, stored procedures represented a performance improvement over dynamic
SQL statements. However, with modern database engines, the performance of stored
procedures and dynamic SQL statements (using parameterized queries) are generally
similar. When considering the use of stored procedures, the primary factors are
abstraction, maintainability, and your environment.
l Use typed parameters as input values to the procedure and output parameters to
return single values. Consider using XML parameters or table-value parameters for
passing lists or tabular data. Do not format data for display in stored procedures;
instead, return the appropriate types and perform formatting in the presentation
layer.
l Use parameter or database variables if it is necessary to generate dynamic SQL
within a stored procedure. However, bear in mind that using dynamic SQL in
stored procedures can affect performance, security, and maintainability.
l Avoid the creation of temporary tables while processing data. However, if
temporary tables must be used, consider creating them in memory instead
of on disk.
l Implement appropriate error handling designs, and return errors that the
application code can handle.
Relevant Design Patterns
Service Layer Guidelines
l Service interfaces. Services expose a service
interface to which all inbound
messages are sent. You can think of a service
interface as a façade that exposes
the business logic implemented in the
application (typically, logic in the business
layer) to potential consumers.
1. Define the data and message contracts that represent the schema used for
messages.
2. Define the service contracts that represent operations supported by your
service.
3. Define the fault contracts that return error information to consumers of the
service.
4. Design transformation objects that translate between business entities and
data
contracts.
5. Design the abstraction approach used to interact with the business layer.
Component Guidelines
General Guidelines for Component Design
l Apply the SOLID design principles to the classes within your component
l Single responsibility principle. A class should have only responsibility.
l Open/closed principle. Classes should be extensible without requiring
modification.
l Liskov substitution principle. Subtypes must be substitutable for their
base types.
l Interface segregation principle. Class interfaces should be client specific
and fine grained. Classes should expose separate interfaces for different
clients where the interface requirements differ.
l Dependency inversion principle. Dependencies between classes should
be replaced by abstractions to allow top down design without requiring
design of low level modules first. Abstractions should not depend upon
details—details should depend upon abstractions.