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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

presentation, business, and data access layers. This helps you to create maintainable,<br />

scalable code and allows you to monitor and optimize the performance of each layer<br />

separately. Use abstraction to implement loose coupling between layers. This can be<br />

accomplished by defining interface components, such as a façade with well-known inputs<br />

and outputs that translates requests into a format understood by components within the<br />

layer. In addition, you can use interface types or abstract base classes to define a shared<br />

abstraction that must be implemented by interface components. When designing a Web<br />

application, consider using techniques such as caching and output buffering to reduce<br />

round trips between the browser and the Web server, and between the Web server and<br />

downstream servers. Avoid blocking during long-running tasks. If you have long-running or<br />

blocking operations, consider using an asynchronous approach to allow the Web server to<br />

process other incoming requests. Design your application to authenticate users whenever<br />

they cross a trust boundary; for example, when accessing a remote business layer from your<br />

presentation layer. Consider using a trusted sub-system for authentication across trust<br />

boundaries. This is particularly useful when accessing a data layer that connects to a<br />

database. When using a trusted sub-system, consider flowing the user’s identity with the<br />

call in order to support auditing and non-repudiation. Whenever you must pass sensitive<br />

data such as a password or authentication cookie across the network, consider encrypting<br />

and signing the data or using a secure transport mechanism such as SSL. Design to run your<br />

Web application using a least-privilege account. If an attacker manages to take control of a<br />

process, the process identity should have restricted access to the file system and other<br />

system resources in order to limit the possible damage.<br />

<strong>Architecture</strong> Frame<br />

The following guidelines will help you to understand the fundamental cross cutting factors<br />

when designing your chosen application type.<br />

• How to design your exception management strategy<br />

Exceptions can be expensive. Do not use exceptions to implement application logic. Use<br />

structured exception handling to build robust code, and use exceptions instead of error<br />

codes where possible. While exceptions do carry a performance penalty, they are more<br />

expressive and less error prone than error codes. Write code that avoids unnecessary<br />

exceptions. In other words, adopt a defensive coding strategy where checks are made prior<br />

to accessing an object or component. Use finally blocks to guarantee that resources are<br />

cleaned up when exceptions occur. For example, close your database connections in a<br />

finally block. You do not need a catch block with a finally block. Finally blocks that are not<br />

related to exceptions are inexpensive. Do not reveal internal system or application details,<br />

such as stack traces, SQL statement fragments, and so on. Ensure that this type of<br />

information is not allowed to propagate to the end user or beyond your current trust<br />

boundary. Fail securely in the event of an exception, and make sure your application denies<br />

access and is not left in an insecure state. Do not log sensitive or private data such as<br />

passwords, which could be compromised. When you log or report exceptions, if user input<br />

16

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

Saved successfully!

Ooh no, something went wrong!