1. What are the Performance Considerations in ASP.NET Applications
To achieve the goal of high performance in ASP.NET applications, we have to take care of the Design Considerations, Coding Techniques, Platform Optimizations and .NET Framework Configurations.
The main performance considerations are-
1). Design Considerations
- Consider security and performance
- Partition your application logically.
- Evaluate affinity.
- Reduce round trips.
- Avoid blocking on long-running tasks.
- Use caching.
- Avoid unnecessary exceptions.
- Tune the thread pool by using the formula to reduce contention.
- Consider minIoThreads and minWorkerThreads for burst load.
- Do not create threads on a per-request basis.
- Avoid blocking threads.
- Avoid asynchronous calls unless you have additional parallel work.
3). Resource Management
- Pool the resources.
- Explicitly call Close() or Dispose() on resources you open.
- Do not cache or block on pooled resources.
- Know your application allocation pattern.
- Obtain resources late and release them early.
- Avoid per-request impersonation.
- Trim your page size.
- Enable buffering.
- Use Page.IsPostBack to minimize redundant processing.
- Partition page content to improve caching efficiency and reduce rendering
- Ensure pages are batch compiled.
- Ensure debug is set to false.
- Optimize expensive loops.
- Consider using Server.Transfer instead of Response.Redirect.
- Use client-side validation.
5). Server Controls
- Identify the use of view state in your server controls.
- Use server controls where appropriate.
- Avoid creating deep hierarchies of controls.
- Data Binding
- Avoid using Page.DataBind.
- Minimize calls to DataBinder.Eval.
- State Management
- Store simple state on the client where possible
- Consider serialization costs.
- Separate dynamic data from static data in your pages.
- Configure the memory limit.
- Cache the right data.
- Refresh your cache appropriately.
- Cache the appropriate form of data.
- Use output caching to cache relatively static pages
- Choose the right cache location.
- Use VaryBy attributes for selective caching.
- Use kernel caching on Microsoft® Windows Server™ 2003.
7). Application State
- Use static properties instead of the Application object to store application state.
- Use application state to share static, read-only data.
- Do not store single-threaded apartment (STA) COM objects in application state.
8). Session State
- Prefer basic types to reduce serialization costs.
- Disable session state if you do not use it.
- Avoid storing STA COM objects in session state.
- Use the ReadOnly attribute when you can.
9). View State
- Disable view state if you do not need it.
- Minimize the number of objects you store in view state.
- Determine the size of your view state.
10). HTTP Modules
- Avoid long-running and blocking calls in pipeline code.
- Consider asynchronous events.
11). String Management
- Use Response.Write for formatting output.
- Use StringBuilder for temporary buffers.
- Use HtmlTextWriter when building custom controls.
12). Exception Management
- Implement a Global.asax error handler.
- Monitor application exceptions.
- Use try/finally on disposable resources.
- Write code that avoids exceptions.
- Set timeouts aggressively.
13). COM Interop Services
- Use ASPCOMPAT to call STA COM objects.
- Avoid storing COM objects in session state or application state.
- Avoid storing STA components in session state.
- Do not create STA components in a page constructor.
- Supplement classic ASP Server.CreateObject with early binding.
14). Data Access
- Use paging for large result sets.
- Use a DataReader for fast and efficient data binding.
- Prevent users from requesting too much data.
- Consider caching data.
15). Security Considerations
- Constrain unwanted Web server traffic.
- Turn off authentication for anonymous access.
- Validate user input on the client.
- Avoid per-request impersonation.
- Avoid caching sensitive data.
- Segregate secure and non-secure content.
- Only use Secure Sockets Layer (SSL) for pages that require it.
- Use absolute URLs for navigation.
- Consider using SSL hardware to offload SSL processing.
- Tune SSL timeout to avoid SSL session expiration.
16). Deployment Considerations
- Avoid unnecessary process hops.
- Understand the performance implications of a remote middle tier.
- Short-circuit the HTTP pipeline.
- Configure the memory limit.
- Disable tracing and debugging.
- Ensure content updates do not cause additional assemblies to be loaded.
- Avoid XCOPY under heavy load.
- Consider precompiling pages.
- Consider Web garden configuration.
- Consider using HTTP compression.
- Consider using perimeter caching.
2. What are the different types of Microsoft Application Blocks?
1). Application Blocks. The Application Blocks are C# and VB.NET classes distributed as Visual Studio projects that can be downloaded from Microsoft's Web site and used in any .NET application, including ASP.NET Web applications. They are useful and powerful tools that can make applications more maintainable, scalable and efficient. The second question which of the application blocks has been used depends on really what you have implemented. But there are two famous MAB which is making buzz around the industry:-
2). Data Access Block. The Data Access Block provides static methods located in the SqlHelper class that encapsulates the most common data access tasks performed with Microsoft SQL server. If the term "static method" is new to you, it means that the class methods can be called without instantiating an instance of the class. For example, the method ExecuteReader () within the SqlHelper class can be called by simply using the statement SqlHelper.ExecuteReader () -- no object instantiation of the SqlHelper class is required.
3). Exception Management Block. The Exception Management Block provides a simple yet extensible framework for handling exceptions. With a single line of application code you can easily log exception information to the Event Log or extend it by creating your own components that log exception details to other data sources or notify operators, without affecting your application code. The Exception Management Application Block can easily be used as a building block in your own .NET application.
3. What is Service Oriented Architecture (SOA)?
“Services” are components which expose well defined interfaces and these interfaces communicate through XML messages. Using SOA you can build workflow, which uses interfaces of these components. SOA is typically useful when you are crossing heterogeneous technical boundaries, organizations, domain etc. In .NET SOA technically uses Web services to communicate with each service which is crossing boundaries. You can look SOA which sits on TOP of web services and provides a workflow. SOA uses service components which operate in their own domain boundary. Let’s note some points of service:-
- They are independent components and operate in their own boundary and own technology.
- They have well defined interfaces which use XML and WSDL to describe themselves.
- Services have URL where anyone can find them and clients can bind to these URL to avail for the service.
- Services have very loosely coupled architecture. In order to communicate to service you only have to know the WSDL. Your client can then generate proxy from the WSDL of the service.
4. What are different ways to pass data between application tiers?
There are many ways you can pass data between tiers :-
1) Dataset the most preferred one as they maintain data in XML format
3) Custom classes
5. What is Windows Distributed InterNet Applications Architecture (DNA)?
The Windows Distributed InterNet Applications Architecture (DNA) is a Microsoft blueprint for robust, scalable, distributed business software. Windows DNA has evolved over time and was not preplanned. It gives all combined advantages of Centralized mainframe, application servers, internet technologies and Personal computers.
Windows DNA is a evolution which started from mainframes (Where all logic was centralized), Fox pro pages (Where we talked in terms of two tier systems), VB6 / SQL SERVER (Three tier where we talked in terms of having one more tier which was mainly COM162 where business logic resided), COM+ (looking in terms of transactions and fulfilling ACID rules) and finally the DNA.
6. What do you mean by Replication?
Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different locations and to remote or mobile users over local and wide area networks, dial-up connections, wireless connections, and the Internet. There are three types of replication: snapshot, transactional, and merge.
Each type of replication typically begins with an initial synchronization of the published objects between the Publisher and Subscribers. This initial synchronization can be performed by replication with a snapshot, which is a copy of all of the objects and data specified by a publication. After the snapshot is created, it is delivered to the Subscribers. For some applications, snapshot replication is all that is required. For other types of applications, it is important that subsequent data changes flow to the Subscriber incrementally over time. Some applications also require that changes flow from the Subscriber back to the Publisher. Transactional replication and merge replication provide options for these types of applications.
Data changes are not tracked for snapshot replication; each time a snapshot is applied, it completely overwrites the existing data. Transactional replication tracks changes through the SQL Server transaction log, and merge replication tracks changes through triggers and metadata tables
7. What is Unified Modeling Language (UML)?
The Unified Modeling Language (UML) is a standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems, as well as for business modeling and other non-software systems. The UML represents a collection of best engineering practices that have proven successful in the modeling of large and complex systems.
The UML is very important parts of developing object oriented software and the software development process. The UML uses mostly graphical notations to express the design of software projects. Using the UML helps project teams communicate, explore potential designs, and validate the architectural design of the software.
8. What are the goals of UML?
Goals of UML includes-
- The primary goals in the design of the UML were:
- Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models.
- Provide extensibility and specialization mechanisms to extend the core concepts.
- Be independent of particular programming languages and development processes.
- Provide a formal basis for understanding the modeling language.
- Encourage the growth of the OO tools market.
- Support higher-level development concepts such as collaborations, frameworks, patterns and components.
- Integrate best practices.
9. What are the different types of diagram in UML?
- Use Case Diagram
- Class Diagram
- Interaction Diagrams
- State Diagram
- Activity Diagram
- Physical Diagrams
10. What is a Class Diagram?
Class Diagram models class structure and contents using design elements such as classes, packages and objects. It also displays relationships such as containment, inheritance, associations and others.
11. What is a Sequence Diagram?
Sequence Diagram displays the time sequence of the objects participating in the interaction. This consists of the vertical dimension (time) and horizontal dimension (different objects).
12. What is a Use Case diagram?
A use case is a set of scenarios that describing an interaction between a user and a system. A use case diagram displays the relationship among actors and use cases. The two main components of a use case diagram are use cases and actors.
An actor is represents a user or another system that will interact with the system you are modeling. A use case is an external view of the system that represents some action the user might perform in order to complete a task.
13. What are Design Patterns? And what are the basic classifications of design patterns?
Design patterns are the recurring solutions to the recurring problems in software architecture.
There are three basic classifications of design patterns Creational, Structural and Behavioral patterns.
1). Creational Patterns
- Abstract Factory: Creates an instance of several families of classes
- Builder: - Separates object construction from its representation
- Factory Method: Creates an instance of several derived classes
- Prototype: A fully initialized instance to be copied or cloned
- Singleton: A class of which only a single instance can exist
2). Structural Patterns
- Adapter: Match interfaces of different classes.
- Bridge: Separates an object’s interface from its implementation.
- Composite: A tree structure of simple and composite objects.
- Decorator: Add responsibilities to objects dynamically.
- Facade: A single class that represents an entire subsystem.
- Flyweight: A fine-grained instance used for efficient sharing.
- Proxy: An object representing another object.
3). Behavioral Patterns
- Mediator: Defines simplified communication between classes.
- Memento: Capture and restore an object's internal state.
- Interpreter: A way to include language elements in a program.
- Iterator: Sequentially access the elements of a collection.
- Chain of Resp: A way of passing a request between a chain of objects.
- Command: Encapsulate a command request as an object.
- State: Alter an object's behavior when its state changes.
- Strategy: Encapsulates an algorithm inside a class.
- Observer: A way of notifying change to a number of classes.
- Template Method: Defer the exact steps of an algorithm to a subclass.
- Visitor: Defines a new operation to a class without change.
14. How can we implement singleton pattern in .NET?
Singleton pattern mainly focuses on having one and only one instance of the object running. Example a windows directory service which has multiple entries but you can only have single instance of it throughout the network.
Note:- May of developers would jump to a conclusion saying using the “STATIC” keyword we can have a single instance of object. But that’s not the real case there is something more that has to be done. But please note we cannot define a class as STATIC, so this will not serve our actual purpose of implementing singleton pattern.
Following are the three steps needed to implement singleton pattern in .NET:-
1). First, create your class with static members.
Public class ClsStaticClass
Private shared objCustomer as clsCustomer
This ensures that there is actually only one Customer object throughout the project.
2). Second, define a private constructor to your class.
Note: - defining a private constructor to class does not allow a client to create objects directly.
3). Finally, provide a static method to get access to your singleton object.
15. What is MVC Pattern?
The Model-View-Controller (MVC) pattern encapsulates a design feature where controller objects play a decoupling role by enabling clients to choose a view of information, while minimizing or preventing change to the model, which outputs the information in one format only. In everyday life, examples of a MVC pattern include a translation tool that translates code from Java to C#, or an integration layer that interposes two layers of architecture.
What: The MVC pattern is a design that seeks to minimize the impact that results from fulfilling the requirements of clients to control how they view information from the model.
Where: An MVC is used where there is a requirement to vary perspectives or views (output) without disturbing, or while minimizing the disruption to, the underlying information source (model) that publishes the information used in the views. It may be used not only in an information-view scenario, but also in architecture, for example, to offer platform independence.
A platform controller object (controller) may be used to transpose functionality of an application (model) that runs on an incompatible platform to an application (view) running on another platform. The pattern may natively be extended to include multiple controllers.
16. How can we implement Observer Pattern in .NET?
Observer patterns can be implemented using “Delegates” and “Events”.
17. What are different types of Architecture?
Client-Server Architecture: In the client-server architecture, requests are made by the client and the server addresses client requests
A client-server application consists of three layers: presentation, which handles the GUI interface, business logic, and database. The client-server architecture is classified depending on the distribution and interaction among the three layers. The four tiers in the client-server architecture are:
4). N-tier or multi-tier
Single-Tier Architecture: The single-tier architecture has a cohesive interface between the business logic and database. The modifications made to one module need to be reflected in the other by making corresponding changes. This type of architecture is not flexible. This architecture is also called the desktop architecture because the presentation, business logic, and database are stored on a single computer.
Two-Tier Architecture: Two-tier architecture has a client and a server with database access through ActiveX Data Object (ADO) or Open Database Connectivity (ODBC). In this architecture, the presentation layer or GUI is present on the client computer. The server stores the database and the client or the end user’s computer and the server perform the business logic. The technologies used in the two-tier model are SQL, VB and MS-Access tools, and ODBC.
Three-Tier Architecture: The three-tier architecture adds another layer to the two-tier architecture for handling part of the business logic and the database services. The middle tier can be a Web or print server.
The three-tier architecture introduces the application layer to protect data from being accessed directly by the client. The three-tier model also enables you to create components or reusable objects.
When the number of end users is large, the three-tier client-server architecture is useful because it helps improve throughput and is more flexible compared to the two-tier architecture.
The middle layer in a three-tier architecture can be further divided into two or more layers to form the N-tier architecture
N-Tier Architecture: The N-tier architecture has three or more layers. In an N-tier model, each layer can be present on different servers. The number of tiers in an N-tier model depends on the degree of separation of functionality required for a particular application. There is no prescribed structure or limit on the number of tiers, but there are some commonly used models.
In the model shown in the above figure, the presentation layer does not include any application processing logic, queuing services, or caching. This means that this tier can easily be implemented on a thin client such as mobile phones or Personal Digital Assistants (PDAs). This model includes a tier to cache components such as Java applets or Component Object Model (COM) components to improve bandwidth usage. The Application Service tier manipulates the data and processes it. The Data tier implements an RDBMS or ODBMS and commonly used business logic procedures to process queries.
18. What are the concepts of Smart Client / Thick Client and Thin Client?
A Smart Client is an application that uses local processing, consumes XML Web Services and can be deployed and updated from a centralized server. While the .NET Framework (Windows Forms) and the .NET Compact Framework provide the ability to develop Smart Clients with ease, other technologies can provide smart client applications by utilizing the same architecture. Smart Client is the concept of architecting your application solution into a smart, flexible and convenient platform that utilizes web services for communication.
The Thin Client: The Thin clients or the Web application provided features like –
o Easy to Update – Single location update
o Easy to deploy – Single location Update
o Easy to manage
If it had the above features then it also had the following issues –
o Network dependency – are usually Network based
o Poor user experience – mainly emit HTML
o Complex to develop
The Thick Client: The Thick clients or the Rich client or Desktop Applications or Client/Server application provided features like –
o Rich User experience – by means of better user interface
o Offline capabilities – Need not be connected on a Network
o High Developer Productivity
o Responsive & Flexible
The Thick did provide the above feature but on the other hand they also had the following issues –
o Tough to Update – Each location needs modifications
o Tough to Deploy – Deployment had to be done at multiple location
o “DLL Hell” problem