Monday, February 27, 2012

.NET Interview Questions: - Show object pooling in .NET?

This is the most practical oriented .Net Interview Questions which may be asked during the Interview by the Interviewer.
COM+ reduces overhead by not creating object from scratch. So in COM+ when object is activated it’s activated, from pool and when it has deactivated it’s pushed back to the pool. Object pooling is configures by using the “ObjectPoolingAttribute” to the class.
Note:- When a class is marked with object pooling attribute it can not be inherited.
ObjectPooling(MinPoolSize := 2, MaxPoolSize := 5, CreationTimeout :=
20000)> _
Public Class testingclass
Inherits ServicedComponent
Public Sub DoWork()
' Method contents go here.
End Sub
End Class
Above is a sample code, which has the “Object Pooling” attribute defined. Below is a sample code, which uses the class.
Public Class App
Overloads Public Shared Sub Main(args() As String)
Dim xyz As New TestObjectPooling()
xyz.doWork()
ServicedComponent.DisposeObject (xyz)
End Sub
End Class
Above is a sample code, which uses the object pooled object. Note the Dispose Object () This ensures its safe return to the object pool.
View following video on regular expressions & some practical demonstrations in .Net Interview: -

Learn more on Dotnet interview questions and answers

Regards,

From more on author’s blog related to Most asked Dotnet interview question click and visit.

Thursday, February 23, 2012

.NET interview questions: - Can you explain the advantages of using OOPS over functional programming?

In fact this one is the basic but very important .NET interview questions asked in almost every interview. An interviewer expects that every candidate should know and answer it. So if you are not sure about it so read the following answer thoroughly and get clear your fundamental related to OOPS.
  • Abstraction: - Abstraction filters un-necessary information from the user’s perspective. It just gives enough information to the user rather than giving him unnecessary information by which he can get confused. Abstraction can be different from different user perspective. For instance below figure 'Abstraction perspective' shows how a simple user looks at a television and how a TV mechanic looks at the television. From a simple user perspective he only needs to start, stop, change channels and control volume. But when a TV mechanic looks at the box he is concerned with details like CRT, Electrical Components, Wires, connection, cooling fan etc. So abstraction is about two things one is show only what is needed and second the need should be from end users perspective.


Figure: - Abstraction Perspective

Ok, now how does that fit in to the software world? When we design components we should know what type of user will be using the component. Figure ‘Abstraction in action’ shows how the customer components when has different view of abstraction for the internal and external developer.


Figure: - Abstraction in Action
  • Encapsulation: - Encapsulation separates an object interface from its implementation. It hides internal implementation details from the users. You can get a better feel by looking at the figure ‘Encapsulation and Abstraction’. It shows a simple stock class which allows a user to add and remove products from the stock. It also has a restock and alert in case products are out of stock. End user is only exposed to operations like ‘addstock’,’removestock’ and get the current level of the stock. He is completely isolated from auto functionalities like how the restock operation takes place. These operations are encapsulated from the end user perspective.
Note :- Abstraction means to expose the necessary functionalities while encapsulation means to hide the complexity. They both complement each other, but there is a huge difference in terms of thinking approach. In interviews ‘difference between abstraction and encapsulation’ is one of the favorites questions among interviewers. So understand the concept fundamentally as you can get in to long talks of confusion with the interviewer.


Figure: - Encapsulation and Abstraction
In java or C# encapsulation is achieved by using private, public and protected access modifiers.
  • Inheritance: - OOPS is all about mapping with real world. One of the relationships in real world is parent child relationship. Inheritance is a methodology by which you can form new classes using existing classes as base. For instance figure ‘Inheritance in action’ shows we have created a parent class called as ‘ClsDisplay’. We can inherit from ‘clsDisplay’ and create bold and italic display classes.

Figure: - Inheritance in action
  • Polymorphism: - Polymorphism means one object can exist in different forms. It refers to ability of the object to take different forms depending on situations. For instance we can use the ‘clsDisplay’ object to point to italic or a bold display object. So depending on the situation the parent class ‘clsDisplay’ can morph/change to any other form.

Figure: - Polymorphism in action
See more on OOPS in video from describing implementation of Aggregation, Association and Composition as follows: -



Visit to get more stuff on Dotnet interview questions and answers

Regards,

Also visit for more author’s other blogs on Most asked .NET interview questions

Monday, February 20, 2012

SQL Server interview question:- What do you mean by SSIS, SSAS and SSRS?

All these 3 things are related to Business intelligence. Business intelligence is all about making meaning of your data, forecasting using that data, making more business sense from the data.

In order to do the same we first need to collect data, analyze it and then display it to the stake holders.
The collection of data is done by using SSIS.

The data analyzation part is done by SSAS.

The displaying of data is done by using SSRS or reporting services.

Below is a simple video in 2 parts which explains the same in more detail and with full demonstration.

Part 1:


Please click to see the Part 2 of what are SSIS, SSAS and SSRS video.

Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions

Wednesday, February 15, 2012

3 Important Concepts: - Association, Aggregation and Composition.

Introduction
Extracting real world relationships from requirement
Requirement 1 (The IS A relationship)
Requirement 2 (The Using relationship: - Association)
Requirement 3 (The Using relationship with Parent: - Aggregation)
Requirement 4 and 5 (The Deathrelationship: - Composition)
Putting things together
The source code
Summarizing
Video on Association, Aggregation and Composition

Introduction
In this article we will try to understand 3 important concepts association, aggregation and composition.
We will also try to understand in what kind of scenarios do we need them. These 3 concepts have really confused lots of developers and in this article my attempt would be to present the concepts in a simplified manner with some real world examples.

Extracting real world relationships from requirement
The whole point of OOP is that your code replicates the real world object, thus making your code readable and maintainable. The time we say real world, real world have relationships. Let’s consider the simple requirement listed below:-
  1. Manager is anemployee of XYZ limited corporation.
  2. Manager uses a swipe card to enter XYZ premises.
  3. Manager has workers who work under him.
  4. Manager has the responsibility of ensuring that the project is successful.
  5. Manager's salary will be judged based on project success.
If you flesh out the above 5 point requirement we can easily visualize 4 relationships:-
  • Inheritance
  • Aggregation
  • Association
  • Composition
Let’s understand them one by one.

Requirement 1 (The IS A relationship)
If you see the first requirement (Manager is an employee of XYZ limited corporation) it’s a parent child relationship or inheritance relationship. The sentence above specifies that Manager is a type of employee, in other words we will have two classes one the parent class “Employee” and the other a child class “Manager” which will inherit from “Employee” class.

Note: -The scope of this article is only limited to aggregation, association and composition. So we will not discuss inheritancein this article as its pretty straight forward and I am sure you can get1000 of articles on the net which will help you in understanding the same.

Requirement 2 (The Using relationship: - Association)
The requirement 2 is an interesting requirement (Manager uses a swipe card to enter XYZ premises). In this requirement the manager object and swipe card object use each other but they have their own object life time. In other words they can exist without each other. The most important point in this relationship is that there is no single owner.



The above diagram shows howthe “SwipeCard” class uses the “Manager” class and the “Manager” class uses the “SwipeCard” class. You can also see how we can create the object of the “Manager” class and “SwipeCard” independently and they can have their own object life time.

This relationship is called as the “Association” relationship.

Requirement 3 (The Using relationship with Parent: - Aggregation)
The third requirement from our list (Manager has workers who work under him) denotes the same type ofrelationship like association but with a difference that one of them is an owner. So as per the requirement the “Manager” object will own “Workers” object.

The child “Worker” objects can not belong to any other objects. For instance the “Worker” object cannot belong to the “SwipeCard” object.

But But….the “Worker” object can have his own life time which is completely disconnected from the “Manager” object. Looking from a different perspective it means that if the “Manager” object is deleted the “Worker” object does not die.

This relationship is termed as the “Aggregation” relationship.



Requirement 4 and 5 (The Deathrelationship: - Composition)
The last two requirements are actually logically one. If you read closely both the requirements which are as follows:-
  1. Manager has the responsibility of ensuring that the project is successful.
  2. Manager's salary will be judged based on project success.
Below is the conclusion from analyzing the above requirements:-
  1. Manager and the project objects are dependent on each other.
  2. The lifetimes of both the objects are same. In other words the project will not be successful if the manager is not good and manager will not get good increments if project has issues.
Below is how the class formation will look like. You can also see when I go to create the project object it needs the manager object.



This relationship is termed as the composition relationship. In this relationship both objects are heavily dependent on each other. In other words if goes for garbage collection the other also has to garbage collected , or putting from a different perspective the life time of the objects are same. That’s why I have put in the heading “Death” relationship.

Putting things together
Below is a visual representation of how the relationships have emerged from the requirements.



The source code
You can also download source code for this article

Summarizing
To avoid confusion hence forth in these 3 terms I have put forward a table below which will help us compare them from 3 angles owner , life time and child object.

AssociationAggregationComposition
OwnerNo OwnerSingle ownerSingle Owner
Life timeHave their own life timeHave their own life time.Owners life time
Child objectNo Child objects all are independentChild objects belong to single parent.Child objects belong to single parent.

Video on Association, Aggregation and Composition
I have also added a video in case you do not want to read this long article.



Just a note I have recorded around 500 videos, do have once a look at my videos on .NET, OOP, SQL Server, WCF, Silver light , LINQ , VSTS, Share Point, Design patterns , UML and lot more.

Visit to get more stuff on Dotnet interview questions and answers

Regards,

Also visit for more author’s other blogs on Most asked Dotnet interview question

Monday, February 13, 2012

SQL Server interview questions: - Elaborate the essential components of SQL Server Service broker?

An SQL Server interview questions asked in the interview. So do read the following answer before going for an interview.

Following are the essential components of SQL Server:-
  • End-Points
The endpoints can be two applications running on different servers or instances, or they can be two applications running on the same server.
  • Message
A message is an entity that is exchanged between Server Brokers. A message must have a name and data type. Optionally, a message can have a validation on that type of data. A message is part of a conversation and it has a unique identifier as well as a unique sequence number to enforce message ordering.
  • Dialog
Dialog ensure messages to be read in the same order as they where put in to queue between endpoints. In short, it ensures proper ordered sequence of events at both ends for a message.
  • Conversation Group
Conversation Group is a logical grouping of Dialog. To complete a task you can need one or more dialog. For instance an online payment gateway can have two Dialog’s first is the “Address Check” and second is the “Credit Card Number” validation, these both dialog form your complete “Payment process”. So you can group both the dialogs in one Conversation Group.
  • Message Transport
Message transport defines how the messages will be send across networks. Message transport is based on TCP/IP and FTP. There are two basic protocols “Binary Adjacent Broker Protocol” which is like TCP/IP and “Dialog Protocol” which like FTP.

See the following video on calling a stored procedure using LINQ: -



Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions

Thursday, February 9, 2012

.NET interview questions: - What are object diagrams in UML?

One of the most expected .NET interview questions on Unified Modeling Language (UML) asked to software engineer during .NET interview.

Class represents shows the static nature of the system. Class diagrams shows the types and how they are linked. Classes come to live only when objects are created from them. Object diagram gives a pictorial representation of class diagram at any point of time. Below figure ‘Object diagram’ shows how a class looks in when actual objects are created. We have shown a simple student and course relationship in the object diagram. So a student can take multiple courses. The class diagram shows the same with the multiplicity relationship. We have also shown how the class diagram then looks when the objects are created using the object diagram. We represent object with Object Name: Class Name. For instance in the below figure we have shown ‘Shiv : ClsStudent’ i.e ‘Shiv’ is the object and ‘ClsStudent’ the class. As the objects are created we also need to show data of the properties, the same is represented by ‘PropertyName=Value’ i.e. ‘StudentName=Shiv’.

Figure: - Object diagrams

The diagram also states that ‘ClsStudent’ can apply for many courses. The same is represented in object diagram by showing two objects one of the ‘Computer’ and the other of ‘English’.

Also see the following video on Object diagram in UML as follows: -



Learn more on important .NET interview questions

Regards,

From more on author’s blog related to Most asked .NET interview questions click and visit

Sunday, February 5, 2012

SQL Server interview questions: - Explain architecture of Notification Services?

This is the SQL Server interview questions which more of Database administrator (DBA) oriented. Have a look before going for interview. So one can start answering this question as follows.

Detail sections in SQL notification services:-

Notification Service application: - It’s a simple user application which will be used to add subscription to the subscription database.

Event providers: - All events reside in Event providers. There are two event providers which are provided by default “File System watcher” and “SQL Server event provider”. “File System watcher” detects changes in operating system files. “SQL Server event provider” watches for SQL Server or analysis service database for change. You can also plug in custom event providers. When event providers find any change in database, they send the event in “Event” table.

Generator: - Generator checks the event database, when it finds any event it tries to match with the subscription and sends it to the notification database. So generator in short is the decision maker between the subscribers and the events.

Distributor: - Distributor continuously pools the “Notification” database for any “Notification’s” to be processed. If the distributor finds any entry, it retrieves it and formats it so that it can be delivered to the end recipient. Formatting is normally done using “XML” and “XSLT” for rendering purpose.

After the formatting is done, it is then pushed to the “distribution providers”. They are nothing but medium of delivery. There are three built-in providers:-
  • SMTP provider
  • File provider
  • HTTP provider
Figure: - Detail architecture of SQL notification services.

See the following video on calling a stored procedure using LINQ: -



Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions

Wednesday, February 1, 2012

SQL Server interview questions: - What is the stateless and stateful load balancing?

Following way you can answer this SQL Server interview questions.

Stateless load balancer
Stateless load balancer uses the hashing algorithm. It takes packet from the client and selects fields from the packet to be hashed. For instance from each client it can take IP address and port number and hash them in to an integer between 1 to number of servers. You can see from the figure we have four servers. So the load balancer takes the IP address and port and hashes them with a number between 1 to 4. Depending on the number the client is directed to the server. For instance client A is directed to server 2, client b to server 1 and so on. Once the client is connected to a server it is always redirected to the same server.


Figure: - Stateless load balancing

Advantage of stateless load balancing is that it’s simple. The biggest disadvantage is that it treats all clients equally and connects one client to one server always. That is if client A is connects to server 2 it will always connect to server 2. This is irrespective of how many times client A sends request. So if client A sends 100 request and client B sends 10 requests even then client will be sent to server 2 for all the 100 request and client B to server 1 for all requests.

Stateful load balancer
In stateful balancing the load balancer looks at each session and assigns it to the appropriate server based on load. In order that the load balancer can track each session it needs to know when the session starts and when it ends.


Figure: - Stateful load balancing

You can see from the figure for every session the load balancer redirects the request to different servers.

See the following video on Data Access layer used in Enterprise Application Block as follows: -



Click for more SQL Server interview questions

Regards,

Visit for more author’s blog on SQL Server interview questions