Вы находитесь на странице: 1из 10

What is Difference between NameSpace and Assembly ? The concept of a namespace is not related to that of an assembly.

A single assembly may contain many types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convention, whereas an assembly establishes the name scope for types at run time. Namespace: Namespace is logical grouping unit. It is a Collection of names wherein each name is Unique. They form the logical boundary for a Group of classes. Namespace must be specified in Project-Properties. Assembly: Assembly is physical grouping unit. It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code. Assemblies are Self-Describing. [e.g. metadata,manifest] An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or by code outside that unit.

What is association, aggregation and composition in oops


Association Association is a relationship where all object have their own lifecycle and there is no owner. Lets take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently. Points: Is a Relationship between objects. Objects have independent lifecycles. There is no owner. Objects can create and delete independently. Aggregation Aggregation is a specialize form of Association where all object have their own lifecycle but there is ownership and child object can not belongs to another parent object. Lets take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy. We can think about has-a relationship. Points: Specialize form of Association. has-a relationship between objects Object have independent life-cycles Parent-Child relationship Composition Composition is again specialize form of Aggregation. It is a strong type of Aggregation. Child object dose not have their lifecycle and if parent object deletes all child object will also be deleted. Lets take again an example of relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete. Lets take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically delete. Points: Specialize form of Aggregation Strong Type of Aggregation. Parent-Child relationship Only parent object has independent life-cycle.

Difference between Session object and Application object in asp.Net


Session variables are used to store user specific information where as in application variables we can't store user specific information. Default lifetime of the session variable is 20 mins and based on the requirement we can change it. Application variables are accessible till the application ends. sessions allows information to be stored in one page and accessed in another,and it supports any type of object,including your own custom data types. Application state allows you to store global objects that can be accessed by any client. The common thing b/w session and application is both support the same type of objects,retain information on the server, and uses the same dictionary -based syntax.

---------------------- If you do not specify the INSTEAD OF or AFTER keyword in the trigger header and just use the FOR keyword, then by default an AFTER trigger will be created. You can have only one trigger for each of insert, update or delete option on a single table or view. If you have created an INSTEAD OF trigger on a table then you can not use the cascade option as an UPDATE and DELETE rule. Cascade for delete rule will be prohibited if INSTEAD OF trigger is defined for delete operation and same is the case for update operations. If you have already used cascade for delete or update options for a table then you can not create an INSTEAD OF trigger for that specific DML operation on that table. INSTEAD OF triggers do not work in a recursive manner. Even if you update the same table inside the INSTEAD OF trigger, the trigger will not be invoked a second time. So INSTEAD OF triggers can be used to avoid recursion. You can define both AFTER and INSTEAD OF triggers for the same DML operation on the same table. If defined on an object, an AFTER trigger can be invoked as a result of DML operations from inside the INSTEAD OF trigger. The deleted table for an INSTEAD OF INSERT trigger is always empty and the inserted table for INSTEAD OF DELETE trigger is always empty.

===============================

Creating an index on a table variable can be done implicitly within the declaration of the table variable by defining a primary key and creating unique constraints. The primary key will represent a clustered index, while the unique constraint a non clustered index.
DECLARE @Users TABLE ( UserID INT PRIMARY KEY, UserName varchar(50), UNIQUE (UserName) )

The drawback is that the indexes (or constraints) need to be unique. One potential way to circumvent this however, is to create a composite unique constraint:
DECLARE @Users TABLE (

UserID INT PRIMARY KEY, UserName varchar(50), FirstName varchar(50), UNIQUE (UserName,UserID) )

You can also create the equivalent of a clustered index. To do so, just add the clustered reserved word.
DECLARE @Users TABLE ( UserID INT PRIMARY KEY, UserName varchar(50), FirstName varchar(50), UNIQUE CLUSTERED (UserName,UserID) )

Generally, temp tables perform better in situations where an index is needed. The downfall to temp tables is that they will frequently cause recompilation. This was more of an issue with SQL 2000 when compilation was performed at the procedure level instead of the statement level. SQL 2005 and above perform compilation at the statement level so if only one statement utilizes a temp table then that statement is the only one that gets recompiled. Contrary to popular belief, table variables can and do write to disk.
Difference between Abstraction andEncapsulation :-

Abstraction 1. Abstraction solves the problem in the design level. 2. Abstraction is used for hiding the unwanted data and giving relevant data.

Encapsulation 1. Encapsulation solves the problem in the implementation level. 2. Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

3. Abstraction lets you focus on what the object does instead of how it does it

3. Encapsulation means hiding the internal details or mechanics of how an object does something.

4. Abstraction- Outer layout, used in terms of design. For Example:- Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.

4. Encapsulation- Inner layout, used in terms of implementation. For Example:- Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits.

The easier way to understand Abstraction and encapsulation is as follows:Real World Example:Take an example of Mobile Phone:You have a Mobile Phone, you can dial a number using keypad buttons. Even you don't know how these are working internally. This is called Abstraction. You have the only information that is needed to dial a number. But not its internal working of mobile.

But how the Mobile Phone internally working?, how keypad buttons are connected with internal circuit? is called Encapsulation. Summary: "Encapsulation is accomplished by using Class. - Keeping data and methods that accesses that data into a single unit" "Abstraction is accomplished by using Interface. - Just giving the abstract information about what it can do without specifying the back ground details" "Information/Data hiding is accomplished by using Modifiers - By keeping the instance variables private or protected." Abstraction: Abstraction is "To represent the essential feature without representing the back ground details." Abstraction lets you focus on what the object does instead of how it does it. Abstraction provides you a generalized view of your classes or object by providing relevant information. Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner. Real world Example of Abstraction: Suppose you have an object Mobile Phone. Suppose you have 3 mobile phones as following:Nokia 1400 (Features:- Calling, SMS) Nokia 2700 (Features:- Calling, SMS, FM Radio, MP3, Camera) Black Berry (Features:-Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)

Abstract information (Necessary and Common Information) for the object "Mobile Phone" is make a call to any number and can send SMS." so that, for mobile phone object you will have abstract class like following: abstract class MobilePhone { public void Calling(); public void SendSMS(); } public class Nokia1400 : MobilePhone { } public class Nokia2700 : MobilePhone { public void FMRadio(); public void MP3(); public void Camera(); } public class BlackBerry : MobilePhone { public void FMRadio(); public void MP3(); public void Camera(); public void Recording(); public void ReadAndSendEmails(); } Abstraction means putting all the variables and methods in a class which are necessary. For example: - Abstract class and abstract method. Abstraction is the common thing. example: If somebody in your collage tell you to fill application form, you will fill your details like name, address, data of birth, which semester, percentage you have got etc. If some doctor gives you an application to fill the details, you will fill the details like name, address, date of birth, blood group, height and weight. See in the above example what is the common thing? Age, name, address so you can create the class which consist of common thing that is called abstract class. That class is not complete and it can inherit by other class.

Encapsulation:

Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation. Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object. Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions. class Bag { book; pen; ReadBook(); }

Encapsulation means hiding the internal details of an object, i.e. how an object does something. Encapsulation prevents clients from seeing its inside view, where the behaviour of the abstraction is implemented. Encapsulation is a technique used to protect the information in an object from the other object. Hide the data for security such as making the variables as private, and expose the property to access the private data which would be public. So, when you access the property you can validate the data and set it. Example: class Demo { private int _mark; public int Mark { get { return _mark; } set { if (_mark > 0) _mark = value; else _mark = 0; } } } Real world Example of Encapsulation:Let's take example of Mobile Phone and Mobile Phone Manufacturer Suppose you are a Mobile Phone Manufacturer and you designed and developed a Mobile Phone design(class), now by using machinery you are manufacturing a Mobile Phone(object) for selling, when you sell your Mobile Phone the user only learn how to use the Mobile Phone but not that how this Mobile Phone works. This means that you are creating the class with function and by making object (capsule) of it you are making availability of the functionality of you class by that object and without the interference in the original class. Example-2:

TV operation It is encapsulated with cover and we can operate with remote and no need to open TV and change the channel. Here everything is in private except remote so that anyone can access not to operate and change the things in TV.

The concept of generalization in OOP means that an object encapsulates common state an behaviour for a category of objects. The general object in this sample is the geometric shape. Most geometric shapes have area, perimeter, and color. The concept of specialization in OOP means that an object can inherit the common state and behaviour of a generic object; however, each object needs to define its own special and particular state an behavior. In Figure 1, each shape has its own color. Each shape has also particular formulas to calculate its area and perimeter.

What is Web Service? Web Service is an application that is designed to interact directly with other applications over the internet. In simple sense, Web Services are means for interacting with objects over the Internet. Web Service is o o o o Language Independent Protocol Independent Platform Independent It assumes a stateless service architecture.

We will discuss more on web service as the article proceed. Before that lets understand bit on how web service comes into picture. Example of Web Service

Weather Reporting: You can use Weather Reporting web service to display weather information in your personal website. Stock Quote: You can display latest update of Share market with Stock Quote on your web site. News Headline: You can display latest news update by using News Headline Web Service in your website. In summary you can any use any web service which is available to use. You can make your own web service and let others use it. Example you can make Free SMS Sending Service with footer with your companies advertisement, so whosoever use this service indirectly advertise your company... You can apply your ideas in N no. of ways to take advantage of it. Web Service Communication Web Services communicate by using standard web protocols and data formats, such as

HTTP XML SOAP Advantages of Web Service Communication Web Service messages are formatted as XML, a standard way for communication between two incompatible system. And this message is sent via HTTP, so that they can reach to any machine on the internet without being blocked by firewall. What is SOAP? o SOAP are remote function calls that invokes method and execute them on Remote machine and translate the object communication into XML format. In short, SOAP are way by which method calls are translate into XML format and sent via HTTP. What is WSDL? o o WSDL stands for Web Service Description Language, a standard by which a web service can tell clients what messages it accepts and which results it will return. WSDL contains every details regarding using web service Method and Properties provided by web service URLs from which those method can be accessed. Data Types used. Communication Protocol used.

o o o o

What is UDDI? UDDI allows you to find web services by connecting to a directory. What is Discovery or .Disco Files? Discovery files are used to group common services together on a web server. Discovery files .Disco and .VsDisco are XML based files that contains link in the form of URLs to resources that provides discovery information for a web service. .Disco File (static) o .Disco File contains URL for the WSDL URL for the documentation URL to which SOAP messages should be sent.

A static discovery file is an XML document that contains links to other resources that describe web services. .VsDisco File (dynamic) A dynamic discovery files are dynamic discovery document that are automatically generated by VS.Net during the development phase of a web service.

What is difference between Disco and UDDI? Disco is Microsoft's Standard format for discovery documents which contains information about Web Services, while UDDI is a multi-vendor standard for discovery documents which contains information about Web Services.

What is Web Service Discovery Tool (disco.exe) ? The Web Services Discovery Tool (disco.exe) can retrieve discovery information from a server that exposes a web service. What is Proxy Class? o A proxy class is code that looks exactly like the class it meant to represent; however the proxy class doesn't contain any of the application logic. Instead, the proxy class contains marshalling and transport logic. A proxy class object allows a client to access a web service as if it were a local COM object. The Proxy must be on the computer that has the web application. What is Web Service Description Language Tool (wsdl.exe)? o o This tool can take a WSDL file and generate a corresponding proxy class that you can use to invoke the web service. Alternate of generating Proxy class through WSDL.exe is you can use web reference. Web Reference automatically generate a proxy classes for a web service by setting a web reference to point to the web service. Advantage of using Web Reference as compare to using WSDL.exe Tool is you can update changes done in web service class easily by updating web reference, which is more tedious task with WSDL.exe tool. Testing a Web Service? o You can test web service without building an entire client application. With Asp.net you can simply run the application and test the method by entering valid input paramters. You can also use .Net Web Service Studio Tool comes from Microsoft.

o o

An anonymous function is an "inline" statement or expression that can be used wherever a delegate type is expected. You can use it to initialize a named delegate or pass it instead of a named delegate type as a method parameter. 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: C# delegate int del(int i); static void Main(string[] args) { del myDelegate = x => x * x; int j = myDelegate(5); //j = 25 }

Anonymous methods enable you to omit the parameter list. This means that an anonymous method can be converted to delegates with a variety of signatures. // Create a delegate. delegate void Del(int x); // Instantiate the delegate using an anonymous method. Del d = delegate(int k) { /* ... */ };

By using anonymous methods, you reduce the coding overhead in instantiating delegates because you do not have to create a separate method.

Вам также может понравиться