14.01.2015 Views

Application Architecture Guide 2.0 BETA 1 - Willy .Net

Application Architecture Guide 2.0 BETA 1 - Willy .Net

Application Architecture Guide 2.0 BETA 1 - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If you are designing a small Web application or a service, and you want to take advantage of<br />

the disconnected behavior they provide, consider using DataSets. If you are working with<br />

content-based applications that have few or no business rules, consider using XML. If you<br />

have complex business rules related to the business domain, or if you are designing a rich<br />

client where the domain model can be initialized and held in memory, consider using<br />

custom Domain Model objects. If your tables or views in the database represent the<br />

business entities used by your application, consider using custom Table Module objects. If<br />

the data you are consuming is already in XML format, or if you are working with read-only<br />

document-based data, consider using custom XML objects.<br />

Data Access<br />

The following guidelines will help you to understand the fundamental factors when designing<br />

the data layer for your application.<br />

• How to design your data connectivity strategy<br />

If the client and the server are located on the same machine, use shared memory. If you<br />

must support communication over the Internet, over wide area networks, or are dealing<br />

with slow network connections, use TCP/IP. If the underlying database is Microsoft SQL<br />

Server, use Named Pipes. If you must expose data directly from your database without<br />

being required to create an intermediate interface, use HTTP Endpoints. When working with<br />

HTTP Endpoints, use Web services as the communication mechanism. If you need a .NET<br />

Framework managed provider for the database, use ADO.NET.<br />

• How to choose between dynamic SQL and stored procedures<br />

In the past, a primary reason for using stored procedures was the improvement in<br />

performance compared to dynamic SQL statements. However, with modern database<br />

engines, performance is no longer a factor in choosing one over the other. One of the<br />

primary reasons for choosing stored procedures has to do with the fact that a database is<br />

one of the top assets for an organization. A stored procedure provides an abstraction layer<br />

that can be used to restrict access to underlying objects and mitigate system wide changes<br />

when objects in the database need to change. Stored procedures also provide enhanced<br />

security by reducing exposure to SQL Injection attacks, and providing a security model that<br />

is much easier to manage. Avoid mixing dynamic SQL within a stored procedure. Avoid<br />

mixing business logic in your stored procedures and in dynamic SQL. When using dynamic<br />

SQL, use parameters to help protect against SQL injection attacks, and batch statements to<br />

maximize performance. Consider maintainability. For example, decide if it is easier to<br />

update statements in a stored procedure or SQL statements in the compiled code.<br />

• How to improve data access performance<br />

Minimize processing on the server and at the client. Minimize the amount of data passed<br />

over the network. Use database connection pooling to share connections across requests.<br />

Keep transactions as short as possible to minimize lock durations and to improve<br />

20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!