Saturday, August 1, 2009

.NET FAQs - 1

1. What is Lamda Expression?

A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types. All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:

delegate int del(int i);
del myDelegate = x => x * x;
int j = myDelegate(5); //j = 25

To create an expression tree type:


using System.Linq.Expressions;


Example :




The => operator has the same precedence as assignment (=) and is right-
associative. Lambdas are used in method-based LINQ queries as arguments to standard query operator methods such as Where``1(IEnumerable(UMP), Func(UMP, Boolean)).

The general rules for lambdas are as follows:

The lambda must contain the same number of parameters as the delegate type. Each input parameter in the lambda must be implicitly convertible to its corresponding delegate parameter.

The return value of the lambda (if any) must be implicitly convertible to the delegate's return type.


2. Difference between clustered and non-clustered index


The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.


3. What is Microsoft UIP?


The User Interface Process Application Block provides a simple yet extensible
framework for developing user interface processes. It is designed to abstract
the control flow and state management out of the user interface layer into a user interface process layer. This helps you write generic code for the control flow and state management for different applications types (for example, Web and Windows) and helps manage user's tasks in complex scenarios (for example, suspending and resuming tasks).

The UIP Application Block is based on the model-view-controller (MVC) pattern. Each of the MVC objects is represented in the UIP Application Block in the following ways:

Model — Implemented in the State class. This stores both user information and control information within the user interface process.
View — Implemented in the WebFormView, WindowsFormView, and
WindowsFormControlView classes.

These are used to create views in your application.

Controller — Implemented in classes that derive from the ControllerBase abstract class. These classes are responsible for the starting of, navigation within, and ending of a user interface process.

4. Difference between WCF and Webservice.

WCF is much more flexible:

can be used over HTTP (like legacy ASMX) but also: can be used over NetTCP, MSMQ, wsHttp and so on WCF services can be hosted in IIS (like legacy ASMX)
but WCF services can also be self-hosted in a console app, Windows NT Service,
etc.

WCF offers a lot more security features and security levels than ASMX (message
security etc.). WCF offers things like reliable messaging, transaction support etc. In WCF, almost anything is configurable in a config file - much more so than with ASMX

5. Why do we need 3-Tier architecture?

i. Reusability of the business logic component results in quick development.Let's say we have a module that handles adding, updating, deleting and finding customers in the system. As this component is developed and tested, we can use it in any other project that might involve maintaining customers.

ii.Transformation of the system is easy. Since the business logic is separate from the data access layer, changing the data access layer won t affect the business logic module much. Let's say if we are moving from SQL Server data storage to Oracle there shouldn t be any changes required in the business layer component and in the GUI component.

iii.Change management of the system is easy. Let's say if there is a minor change in the business logic, we don t have to install the entire system in individual user s PCs. E.g. if GST (TAX) is changed from 10% to 15% we only need to update the business logic component without affecting the users and without any downtime.

iv. Having separate functionality servers allows for parallel development of
individual tiers by application specialists. Provides more flexible resource allocation. Can reduce the network traffic by having the functionality servers strip data to the precise structure needed before sending it to the clients.

6. New features of .NET 3.5 Framework

1. .NET Compact Framework

Windows Communication Foundation (WCF) technology
Language-Integrated Query (LINQ)
Improvements made to Windows Forms controls
SoundPlayer to play multiple sounds.
Supports Compression through the System.IO.Compression namespace
Supports the CreateDelegate method
Supports the CLR Profiler
Supports the Configuration Tool (which provides runtime version information and
administrative functions)
Debugging enhancements
Improvements have been made to logging features
Information about the platform type

The runtime tools library with diagnostic tools, such as Remote Performance
Monitor, with the emulator. Strong names that are greater than 1,024 bytes are now supported The global assembly provides improved error handling and integration with
Windows Embedded CE version 6.0.

The class library documentation improved

2. ASP.NET

ListView Class


ListView Class displays the values of a data source by using user-defined templates. The ListView control enables users to select, sort, delete, edit, and insert records. The ListView control is quiet flexible and contains features of the Gridview, Datagrid, Repeater and similar list controls available in ASP.NET 2.0.

DataPager


Provides paging functionality for data-bound controls that implement the IPageableItemContainer interface, such as the ListView control.he best advantage is that you need not have to keep it ‘tied’ with the control on which the paging is being done. You can keep it anywhere on the page.DataPager gives you a consistent way of paging with the controls that support it.

3. Add-Ins and Extensibility
4. Common Language Runtime
5. Cryptography
6. Networking
7. Windows Communication Foundation
8. Windows Presentation Foundation
9. Windows Workflow Foundation
10. Windows Forms
11. LINQ
12. Expression Trees
13. Programming Languages

Please refer http://www.tipsntracks.com/11/new-features-in-the-dotnet-framework-version-35.html for detailed explanation.

7.LINQ to SQL Implementation

LINQ to SQL is an O/RM (object relational mapping) implementation which allows you to model a relational database using .NET classes. You can then query the database using LINQ, as well as update/insert/delete data from it.

LINQ to SQL allows .NET developers to write “queries” in their .NET language of choice to retrieve and manipulate data from a SQL Server database. In a general sense, LINQ to SQL allows us to create SQL queries in our preferred .NET language syntax and work with a strongly types collection of objects as a return result. We can make changes to these objects then save changes back to the database.

EX: (HookedOnLINQ - DB name, Contact- table name)
HookedOnLINQ db =
new HookedOnLINQ("Data Source=(local);Initial Catalog=HookedOnLINQ");

var q = from c in db.Contact
where c.DateOfBirth.AddYears(35) > DateTime.Now
orderby c.DateOfBirth descending
select c;

foreach(var c in q)
Console.WriteLine("{0} {1} b.{2}",
c.FirstName.Trim(),
c.LastName.Trim(),c.DateOfBirth.ToString("dd-MMM-yyyy"));

Output:
Mack Kamph b.17-Sep-1977
Armando Valdes b.09-Dec-1973

8.New features of .NET 2.0 Framework

Various aspects such as Support for 64 bit platform application development, Access control list support (ACL), ADO.NET, ASP.NET, Authenticated streams,COM Interop Service Enhancements, Console Class Additions, Data Protection API, Detecting changes in Network connectivity, Disjunctive Demands, Distributed Computing, EventLog Enhancements, Expanded Certificate Management, FTP Support, Generics and Generic Collection, I/O Enhancements and several other features.

For detailed description:

http://www.programmersheaven.com/2/new-DotNET-Framework-v2

9. Features of SQL Server Integration Services(SSIS):

1. Enterprise-Ready Platform

SQL Server Integration Services (SSIS) provides out-of-the-box enterprise-class scalability options with its advanced data-integration pipeline architecture,
high-performance processing, and native support for 64-bit platforms.

2. Developer Productivity

SQL Server Integration Services, Analysis Services, and Reporting Services all use a common Microsoft Visual Studio–based development environment, the SQL Server Business Intelligence Development Studio, for streamlined productivity.

3. Extensible and Customizable

SSIS goes beyond simple extraction, transformation, and loading (ETL) tools by enabling nontraditional scenarios and leveraging the power of the Microsoft .NET platform and SQL Server

SQL Server Integration Services (SSIS) is a component of Microsoft SQL Server 2005 and 2008. It replaces Data Transformation Services, which has been a feature of SQL Server since Version 7.0. Unlike DTS, which was included in all versions, SSIS is only available in the "Standard" and "Enterprise" editions.

Integration Services provides a platform to build data integration and workflow applications. The primary use for SSIS is data warehousing, as the product features a fast and flexible tool for data extraction, transformation, and loading (ETL). The tool may also be used to automate maintenance of SQL Server databases, update multidimensional cube data, and perform other functions.

Tutorial:

http://sqlserverpedia.com/wiki/SQL_Server_Integration_Services_Section

10. Sql Server Reporting Services

SQL Server Reporting Services (SSRS) is a server-based report generation software system from Microsoft. It can be used to prepare and deliver a variety of interactive and printed reports. It is administered via a web interface.

Reporting services features a web services interface to support the development
of custom reporting applications.

SSRS competes with Crystal Reports and other business intelligence tools, and
is included in Express, Workgroup, Standard, and Enterprise editions of Microsoft SQL Server as an install option. Reporting Services was first released in 2004 as an add-on to SQL Server 2000. The second version was released as a part of SQL Server 2005 in November 2005. The latest version was released as part of SQL Server 2008 in August 2008.

In SSRS, reports are defined in Report Definition Language (RDL), an XML markup
language. Reports can be designed using recent versions of Microsoft Visual Studio[1] with the included Business Intelligence Projects plug-in installed or with the included Report Builder, a simplified tool that does not offer all the functionality of Visual Studio. Reports defined by RDL can be generated in a variety of formats[2] including Excel, PDF, CSV, XML, TIFF (and other image formats[3]), and HTML Web Archive. SQL Server 2008 SSRS can also prepare reports in Microsoft Word (DOC) format.

Tutorial: http://sqlserverpedia.com/wiki/SQL_Server_Reporting_Services_Section

11. Design Patterns

All design patterns have the following characteristics …

A name
A description of the problem being addressed
A description of the solution
An evaluation of the pattern's consequences (i.e. its trade-offs)
As software developers and architects, why should we care about design
patterns?

Design patterns provide a common vocabulary, and therefore facilitate communication.

Design patterns provide templates or guidelines for solving common design problems.

Design patterns help us understand the consequences of our design decisions. If we study design patterns and understand when they should be applied, we can build better products, and in the process bring benefit to our respective companies, our projects, our teams, and ourselves as well. Rather than reinventing the wheel, we can learn from our predecessors, and that's the key to building better software!

Types:

I .GOF (Gang of Four) -The GOF book catalogued 23 design patterns into 3

groups, namely Creational, Structural and Behavioural

Creational


Abstract Factory
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.


Builder
Separate the construction of a complex object from its representation so that the same construction process can create different representations.


Factory Method
Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.


Prototype
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

Singleton
Ensure a class only has one instance, and provide a global point of access to it.

Structural

Adapter
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Bridge
Decouple an abstraction from its implementation so that the two can
vary independently.

Composite
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Decorator
Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Fa├žade
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Flyweight
Use sharing to support large numbers of fine-grained objects efficiently.

Proxy
Provide a surrogate or placeholder for another object to control access to it.


Behavioural


Chain Of Responsibility
Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.


Command
Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

Interpreter
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

Iterator
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Mediator
Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

Memento
Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.

Observer
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.


State
Allow an object to alter its behaviour when it’s internal state changes. The object will appear to change its class.


Strategy
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.


Template Method
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

Visitor
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

II. Environmental Design Pattern

III. Architectural Design Pattern

Architectural or Enterprise design patterns tend to focus at higher abstractions of implementation. In other words, a typical Architecture design pattern would be the 'Three-Layered Architecture'. This simply means that one tries to separate ones implementation in terms of three focused areas or layers (Presentation, Business Logic, and Data Access). At the Enterprise level, one would start looking at Integration Patterns and understanding what patterns are useful in terms of connecting disparate systems in a hybrid environment.

No comments: