• No results found

(A)How to use a checkbox in a datagrid?

In document 046_SampleInterviewQuestionBook(1) (Page 182-191)

Twist :- How can I track event in checkbox which is one of the columns of a datagrid ? Note: - This is normally asked when the interviewer want to see that have you really worked practically on a project.

Following are the steps to be done

:-√ In ASPX page you have to add Itemtemplate tag in datagrid.

<ItemTemplate>

<asp:CheckBox id="CheckBox1" runat="server" AutoPostBack="True"

OnCheckedChanged="Check_Clicked"></asp:CheckBox>

</ItemTemplate>

√ If you look at the Itemtemplate we have “OnCheckChanged” event. This

“OnCheckChanged” event has “Check_Clicked” subroutine is actually in behind code. Note this method which is in behind code should either be

“protected” or “public”

√ Following below is the subroutine which defines the method Protected Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs)

‘ do something End Sub

The above steps should be defined in short to the interviewer which will give a quick feeling of your practical experience with ASP.NET

(I)What are the steps to create a windows service in VB.NET

?

Windows Services are long-running executable applications that run in its own Windows session, which then has the ability to start automatically when the computer boots and also can be manually paused, stopped or even restarted.

Following are the steps to create a service

:-√ Create a project of type “Windows Service”.

Figure 7.6 :- Create project for Windows Service

√ If you see the class created it is automatically inheriting from

“System.ServiceProcess.ServiceBase”.

√ You can override the following events provided by service and write your custom code. All the three main events can be used that is Start, stop and continue.

protected override void OnStart(string[] args) {

}

protected override void OnStop() {

}

protected override void OnContinue() {

}

√ Now to install the service you need to do run the install util exe.

InstallUtil <Project Path>\BIN\MyNewService.exe

(A) What is the difference between “Web farms” and “Web garden”?

“Web farms” are used to have some redundancy to minimize failures. It consists of two or more web server of the same configuration and they stream the same kind of contents.

When any request comes there is switching / routing logic which decides which web server from the farm handles the request. For instance we have two servers “Server1”

and “Server2” which have the same configuration and content. So there is a special switch which stands in between these two servers and the users and routes the request accordingly.

Figure 7.7 : - Web Farm in action

Above figure explains in detail how web farm work. You can see there is a router in between which takes a request and sees which one of the server is least loaded and forwards the request to that server. So for request1 it route’s server1, for request2 it routes server2, for request3 it routes to server3 and final request4 is routed to server4. So you can see because we have web farm at place server1 and server2 are loaded with two request each rather than one server loading to full. One more advantage of using this kind of architecture is if one of the servers goes down we can still run with the other server thus having 24x7 uptime.

The routing logic can be a number of different

options:-√ Round-robin: Each node gets a request sent to it “in turn”. So, server1 gets a request, then server2 again, then server1, then server2 again. As shown in the above figure.

√ Least Active: Whichever node show to have the lowest number of current connects gets new connects sent to it. This is good to help keep the load balanced between the server nodes.

√ Fastest Reply: Whichever node replies faster is the one that gets new requests. This is also a good option - especially if there are nodes that might not be “equal” in performance. If one performs better than the other, then send more requests there rather than which is moving slowly?

Before we try to understand what a web garden is let’s try to understand how IIS handles processes. All requests to IIS are routed to “aspnet_wp.exe” for IIS 5.0 and “w3wp.exe”

for IIS 6.0. In normal case i.e. with out web garden we have one worker process instance (“aspnet_wp.exe” / “w3wp.exe”) across all requests. This one instance of worker process uses the CPU processor as directed by the operating system.

Figure 7.8 : - With out Web Garden

But when we enable web garden for a web server it creates different instances of the worker process and each of these worker process runs on different CPU. You can see in the below diagram we have different worker process instances created which run on different CPU’s.

Figure 7.9 : - With Web Garden

In short we can define a model in which multiple processes run on multiple CPUs in a single server machine are known as a Web garden.

(A) How do we configure “WebGarden”?

“Web garden” can be configured by using process model settings in “machine.config” or

“Web.config” file. The configuration section is named <processModel> and is shown in

the following example. The process model is enabled by default (enable=”true”). Below is the snippet from config file.

<processModel enable=”true”

timeout=”infinite”

idleTimeout=”infinite”

shutdownTimeout=”0:00:05"

requestLimit=”infinite”

requestQueueLimit=”5000"

memoryLimit=”80"

webGarden=”false”

cpuMask=”12"

userName=””

password=””

logLevel=”errors”

clientConnectedCheck=”0:00:05"

/>

From the above processmodel section for web garden we are concerned with only two attributes “webgarden” and “cpuMask”.

webGarden :- Controls CPU affinity. True indicates that processes should be affinitized to the corresponding CPU. The default is False.

cpuMask:- Specifies which processors on a multiprocessor server are eligible to run ASP.NET processes. The cpuMask value specifies a bit pattern that indicates the CPUs eligible to run ASP.NET threads. ASP.NET launches one worker process for each eligible CPU. If webGarden is set to false, cpuMask is ignored and only one worker process will run regardless of the number of processors in the machine. If webGarden is set to true, ASP.NET launches one worker process for each CPU that corresponds to a set bit in cpuMask. The default value of cpuMask is 0xffffffff.

Below are detail steps of how to implement web garden

√ click Start and then click Run.

√ type calc.exe and then click OK.

√ Goto View menu, click Scientific.

√ Goto View menu, click Binary.

√ Use 0 and 1 to specify the processors ASP.NET can or cannot use.

Use 1 for the processor that you want to use for ASP.NET. Use 0 for the processor that you do not want to use for ASP.NET. For example, if you want to use the first two processors for ASP.NET of a four-processor computer, type 1100.

√ On the View menu, click Decimal. Note the decimal number.

√ Open the Web.config or machine.config file in a text editor such as Notepad. The Web.config file is located in the folder where the application is saved.

√ In the Web.config file, add the processModel configuration element under the System.web element. Before adding <processModel> to Web.config file, the user has to make sure that the allowDefinition attribute in the <processModel> section o f the Web.config file is set to everywhere.

√ Add and then set the webGarden attribute of the processModel element to True.

√ Add and then set the cpuMask attribute of the processModel element to the result that is determined in your calculation.

Do not preface the number with 0x because the result of the calculation is a decimal number. The following example demonstrates the processModel element that is configured to enable only the first two processors of a four-processor computer.

<processModel enable=”true”

webGarden=”true”

cpuMask=”12" />

Save the Web.config file. The ASP.NET application automatically restarts and uses only the specified processors.

(B)What is the main difference between Gridlayout and FlowLayout ?

GridLayout provides absolute positioning for controls placed on the page. Developers that have their roots in rich-client development environments like Visual Basic will find it easier to develop their pages using absolute positioning, because they can place items exactly where they want them. On the other hand, FlowLayout positions items down the page like traditional HTML. Experienced Web developers favor this approach because it results in pages that are compatible with a wider range of browsers.

If you look in to the HTML code created by absolute positioning you can notice lot of DIV tags. While in Flow layout you can see more of using HTML table to position elements which is compatible with wide range of browsers.

(B) What are design patterns ?

Design patterns are recurring solution to recurring problems in software architecture.

(A) Can you list down all patterns and their classification ?

Note :- This is advanced question because anyone who asks to list down all patterns can only be crazy for what he is asking. But it is always a win-win situation for the interviewer.

There are three basic classification of patterns Creational, Structural and Behavioral patterns.

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 in which only a single instance can exist

Note :- The best way to remember Creational pattern is by ABFPS (Abraham Became First President of States).

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.

√ Façade:-A single class that represents an entire subsystem.

√ Flyweight:-A fine-grained instance used for efficient sharing.

√ Proxy:-An object representing another object.

In document 046_SampleInterviewQuestionBook(1) (Page 182-191)

Related documents