Tuesday, August 8, 2017

HytechPro

What is project management triangle?
What is 20-80 principle
What is mfar?
Do you know UML?
What is database replication?
What is REST?
Why Web API is better than WCF?
What is default Isolation level?
What is RISK management?
What is project attribute?
What is the role of technical architect?
What is responsible website?
What is benefit of de-normalization?

Agile Priority Decision

Nicely explained here

https://michaellant.com/2010/05/21/how-to-easily-prioritize-your-agile-stories/

https://dzone.com/articles/6-backlog-prioritization

Role of Scrum Master

https://www.mountaingoatsoftware.com/agile/scrum/roles/scrummaster

Friday, August 4, 2017

Managerial Round

What is your greatest strength?
What is your biggest strength?
What strengths would you bring to our company?
What are three strengths that you bring to this position?
What are your greatest professional strengths?
What is your greatest accomplishment or the project you’re most proud of completing? 
What do you do best in your current position? 
What would your co-workers say is your strongest area of expertise?
Positive
Optimistic
Work Under Pressure
Passionate about learning new things
Pay a lot of attention on details
Good Team Player
Goal oriented
Self Motivated
Negative
I Seek perfection while doing work which is not possible sometimes.
I find it difficult to say no who ask for help.
I am workaholic. If I am into work, I never bother about time because I want my work to be finished as soon as possible.
Where do you see yourself five years from now?
I definitely see my self employed within this company for the next 5 years and beyond. I feel my self with more knowledge and better skills at senior position while taking more responsibility and contributing growth of the company.
A valued employee of my company.

What are your short term and long term goals?
I have learned that long-term goals are best achieved when I break them into shorter goals.
My short term goal is to serve for my company by using my knowledge and skills and long term goal is create an identity for myself in my company.
OR
My goal is to always perform at an exceptional level. But a short term goal I have set for myself is to implement a process that increases work efficiency.

My short term goal is I want such a platform where I can grow my career along with the organisation growth and my long term goal is to get a respectable position in your company and become an essential part of it.

What are three positive character traits you don't have?
Ability to socialize with anyone.
Being able to speak to an audience. I absolutely hate speaking to crowds.
Name three positive traits you already have.
User Submitted Interview Answers
1. One is my sense of humor, two is that I am good I am a people's person, three is I m always happy.   
2. Optimistic, positive, and excited.   
3. Confidence in speaking to the public, prioritization of tasks, decision making.   
4. Natural leader, reliable, highly motivated.   
5. Retail and HR management.   
6. Listening, communication, and easy going.   
7. I am very optimistic, I am organized, and driven.   
8. My work ethic, my sense of humor, and my leadership abilities.   
9. I believe there is always room to grow and better your personal traits. I would say problem solving, project managing, and root cause analysis. I have all these traits but there is always more learning.    
10. Strong work ethic team player proactive.
How would you gain your team's trust?
Tell me about a time when you have helped resolve a dispute between others.
How would you describe your work style?

Wednesday, July 26, 2017

Conduent

1. What are the roles in Agile?
2. If you have come an issue in previous version during sprint than who will decide in agile what should be done.
3. What  will print in stored procedure

if(Null=Null)
print("if")
else
print("else")

4. If we have to copy one table data into another with identity column. How will you do that?
Ans :  You can on the insert into identity first than you can insert data in identity column

Set IDENTITY_INSERT ON

by default it is off means you can not insert data in identity column.

5. Why MVC is fast?
6. What is the wild card character used in jquery instead of # while selecting id.

7. If we have two variable with same name in two java script file. What will happen?
Ans : Will overwrite second variable value, we use closure for that.

8.   Jquery is browser independent or not? What is the solution to make it?
9.   Why we use Lambda expression?
10. What is WPF architecture?
11. What is MVVM?
12.  What are different type of  resources in WPF?
And dynamic and static

13 . Why we use WPF?
14.  What is entity framework? How will we use entity framework?
15.  Have you worked on ASP .Net Core?
16.  Write a program for sorting an array?
17 What will be the output?

x=5;
while(x<6 p="">print(x)

18. Why we use JQuery?
19. What we can't do in google analytics?

Monday, July 17, 2017

Instance Mode in WCF

When a client make a request to WCF, WCF service creates an instance of service to service the client request. After the request completion what will happen of that object we will see here.

Instance Context Mode dictates how long the service instance remain on the server.


There are three instancing modes

Per Call :-  

A new instance of service object is created for every request, whether the request is coming from same client or different client. It means service object is destroyed after the completion of request i.e after the response sent to the client. 

In this state is not maintained between request.

Per Session :-  

A new instance of service object is created for every new client session and that service object maintained during that session.

Per Session :-  

A single object serves all request whether they are coming from same client or different client during the lifetime of application.

It can be set using InstancContextMode in service behavior.


[ServiceBehaior(InstanceContextMode = InstanceContextMode.PerCall]
public class LoadService: ISService
{

}


Implications of Per Call

1. Better memory usage as object is freed immediately.
2. No Concurrency
3. No State maintained between call.
4. Performance could be an issue as object is created for every method call
5. Application scalability is better because it service does not hold any resources.

[ServiceBehavior (InstanceContextMode = InstanceContextMode.PerCall)]
public class MathService :IMatchServie
{
 int _iVal;
 public int IncreamentVal()
{
  _iVal =_iVal+1;
   return _iVal;
}
}

Client Code

static void main(string[] args)
{
MatchService.MathServiceClient client = new MatchServiceClient()

int iVal = client.IncreamentVal();
Console.WriteLine("Vale after first call "+ iVal);

int iVal = client.IncreamentVal();
Console.WriteLine("Vale after Second call "+ iVal);
}

Output

Value after First call 1
Value after Second call 1

Implications of Per Session

1. State maintained between calls for same client.
2. More memory consumption as service objects  remain in memory until the client session timeout. On the other this affect application scalability negatively.
3. Concurrency is an issue multi threaded client.
4. The default session time out is 10 minutes.




[ServiceBehavior (InstanceContextMode = InstanceContextMode.PerSession]

public class MathService :IMatchServie
{
 int _iVal;
 public int IncreamentVal()
{
  _iVal =_iVal+1;
   return _iVal;
}
}

Client Code

static void main(string[] args)
{
MatchService.MathServiceClient client = new MatchServiceClient()

int iVal = client.IncreamentVal();
Console.WriteLine("Vale after first call "+ iVal);

int iVal = client.IncreamentVal();
Console.WriteLine("Vale after Second call "+ iVal);
}

Output

Value after First call 1
Value after Second call 2

State is maintained for same client means if you create another client like second console application and call increment method it will give you fresh value.

Which is better Per Call or Per Session


1. Both have different strength and weakness
2.If you prefer object oriented style than persession is better, if you prefer SOA (Service Oriented Architecture Style) than percall is better.
3. Per Session is better for performance and Per is better for scalability.

Does all binding support session?

No, All binding does not support session like basichttp binding does not support session. If a binding does not support session than service behaves like per call. netTcpbinding support session.

How to control the WCF service time out?

You can set the receivetimeout attribute in binding tag. and reset it. by default it is 10 minutes.

What happens when the session timeout reached?

When the session timeout reached the connection to the WCF service closed. And communication channel gets faulted and the client can no longer use the same proxy instance to call method. And on calling an exception throws by WCf service. And the data in service object lost.

How to fix the communication channel  in case of faulted state exception?

Using try catch block  at client side and re- create the proxy object in catch block in case of Communication exception.

Session Id

To send message from a particular client to a particular service instance on the server, WCF uses session id.

At client side to retrieve session id we use

client = new MathServiceClient()

client.InnerChannel.SessionId

At WCF service to retrieve session id we use

OperationContext.Current.SessionId

client side and WCF server side session id are co related using the reliable session setting at WCF service host, it is defined in binding tag

If reliableSession is disable than both session id will be different otherwise same. By default it is disabled.

<bindings>
<netTcpBinding>
<binding name="netTcpBinding" receiveTimeout="00:00:10">
<reliableSession enabled="true"/>
<binding>
<netTcpBinding>
<binding>

If binding s wsHttpBinding than session id will be same irrespective of relaibleSession means session id will be same even relaibaleSession if disable.

Single :-  

In single instance context mode only one object created for all client and for all request.Service object is not destroyed after request completed it remains in memory.

In single context mode session id will be same for a client for all request. session id will be different for two different client.

State is maintained and shared between different request and from different client.

Concurrency can be an issue.

To resolve concurrency we can configure the service to allow a single thread at time.

SessionMode Enumeration 

Session mode enumeration is used in service contract to specify whether session is allowed or not not in service

There are three value of session mode

Allowed :-

By default session is allowed in service contract

Not Allowed :- 

In this case session is not allowed so service does not support binding that initiate session

Required :-

In this case service contract require a binding that support session.


If session mode is allowed and Instance Context is Single than what will happen?

In that case we use basicHttpBinding that does not support session than service will work as Single ton but without session but session id will be null.

If we use netTcpBinding that support session than service still work as Singleton but with session.

If session mode is required and Instance Context is Single than what will happen?


In that case if we use basicHttpBinding than service will throw error because basicHttpBinding does not support session.

And netTctBinding will work fine with session.

part-42 

MTOM in WCF - Message Transmission Optimization Mechanism

Default message encoding in WCF is Text which is base64 encodes data.
It has two disadvantages

1. Base 64 encoding (bloats)increase the message size by 33%
2. It evolves extra processing overhead to encode and decode base64.

The best approach to send large data is MTOM. It does not base64 encode data. It is fast and does not have overhead of encode and decode.

With MTOM binary data is included as a MIME (Multipurpose Mail Extension)

Wednesday, July 12, 2017

Hosting WCF in IIS with WAS enabled

By default IIS  support only http protocol, To support non http protocol we have to install Windows Communication Foundation Non-HTTP Activation and WAS(Windows Process Activation). Windows 7 and above version of Windows along with IIS7 support WAS.

After installing you need to enable net.tcp protocol for WCF application hosted in IIS and now you will be able to use nettcp binding.

Message Exchange Pattern in WCF


1. Request-Reply
2. One Way
3. Duplex


Request-Reply

Request-Reply is the default pattern. In this pattern client send a message to WCF service and then wait for a reply even return type is void. Client wait to complete the WCF operation.

Except MSMQ all binding support this pattern.

In this pattern fault and exception get reported to client immediately.
If IsOneWay=false than it is Request-Reply.

One Way

In one way client does not except any response nor WCF send any reply to client. And exception also don't get reported to client. return type should be void in one way call.not out,ref param allowed.

If service has received a call when it was serving other request than the current request is queue but it it does not block the client.

One way call is different form asynchronous call.  In WCF there is a server queue limit if number of waiting  one way call is exceeded the limit than client wait for that.


Duplex

Duplex can be implemented using Request-Reply or One Way operation.

If we want to send some message from WCF service between processing in a long function than we use duplex. We use CallbackContract delegate for this.

Syntax is 

[ServiceContract (CallbackContract= typeof(IReportServiceCallback)]
public interface IReportService
{

  void DoProcessReport();
}

public interface IReportServiceCallback
{

  void Progress(int percentage);

}

Method can be called using OperationContext.

[ServiceBehavior(ConcurrencyMode = ConcuurencyMode.reentrant)]
public ReportService : IReportService
{

public void ProcessReport()
{

OperationContext.Current.GetCallbackChannel().Progress(iValue);

}
}

If we want to use Dupex  with Request Reply operation than we need to set attribute ConcurrencyMode = ConcurrencyMode.Reentrant in service and at client we have to use CallbackBehaior(UseSynchronizationContext = false)

To implement Duplex wiht One Way operation we haven't need any attribute.

Tuesday, July 4, 2017

WCF 30

Advantage WCF hosting in IIS

1. No code required to host the service, All we need ServiceHost.svc file and ServiceHost directive is responsible for creating an object of Service Host and started it when required.
2. Automatic message based activation i.e No need to run the host every time WCF reuired.
Means whenever message arrives at service it launches itself. In case of self hosting it should be always running.
3 Automatic recycling - IIs provide automatic process recycling if process is taking too much time



Thursday, June 29, 2017

Magic Software

What is interface?
What is shadowing?
What is Dependency Injection?
Difference between is and as?
Difference between Singleton and static class
What is dependency Property
What is dispatcher class?
What is partial class ?
Difference between interface and partial class

Tuesday, June 13, 2017

Analec

1.Difference between char and vachar and nvarchar
2.Difference between char(50), varchar(50) and nvarchar(50)
3.If we have taken an integer property and bind it to a text box and types some
string in text box than what will be the value of property.
4. Define Singleton pattern
5. What is attached dependency property?
6. If we have a glass of filled water how will you measure half glass
7. What is region in prism framework
8. How will you do constructor overloading while using unity container.
9. If we have two methods PrintEven and PrintOdd, How will you print sequenceial number
10. What is the role of dispatcher?
11. What is the difference between Dispatcher.Invoke and Dispatcher.BeginInvoke
12. If we call Dispatcher.Invoke with Proirity Background, is it similar to Dispatcher.BeginInvoke

13. Ques. How will you bind mousedown event in MVVM?
Ans. using EventToCommandBehaviour

14. What is the difference between Primary Key and Unique Key
15. What is the difference between user control and custom control
16. What is the difference between clustor index and non clustor index.
17. If you call usercontrol.Dispatcher and Application.Dispatcher than what is the difference
18. What are routed event?
19. In which tree routed event travel visual or logical
Ans Visual
20. Ques : How much memory a static method take
Ans :Depened upon variable declared
21. Can a static class contain instance constructor?
Ans No
22. Ques What is the use of IDisposable interface?
Ans No
23. If a class does not implemented with IDisposable can we still using it with using keyword?
24. How can we use region in prism?
25. How can we use single UI in multiple module?
26. Ques A function take two integer parameter first value is 5 and second value is 10 lacs, we need to sum all from 5 to 10 lacs.
Ans  This is an Arithmetic Progression so sum will be n/2(2a+(n-1)d)
27. How can you make a rounded button?
Ans Using radius property
28. While binding a property to any UIElement what should be the property access specifier?
Ans It should be public
29. Ques How can you do fire an action on two events like Enable and ReadOnly.
Ans using multi trigger

30. Ques.  While using command do we need to bind enable property or it is directly handled by Canexcute method.
Ans .  No need to bin Enable property. It is directly depend on CanExecute method.

31 Ques. Difference between heap table and clustered table in SQL Server

Thursday, June 8, 2017

Buerau Veritas


1. What is the use of IDisposable interface?
2. How garbage collector work ?
3. Difference between multithreading and multitasking.
4. Project architecture.
5. How do you declare dependency property?
6. Why it is static and readonly?
7. Can we define dependency property in one class and use in another class?
8. Have you used custom dependency property ever?
9. Which routed strategy you have used in your project?
    Ans Direct event
10. What is the difference between int32 and Integer.
11. What is the main difference in interface and abstract class?
12. Can an abstract class inherit another abstract class?
Ans Yes
13. If you are developing an application for different time zone, So how will you code that it should show right time in Australia and India.

Wednesday, May 31, 2017

Difference between char, varchar and nvarchar

Char DataType

Char datatype which is used to store fixed length of characters. Suppose if we declared char(50) it will allocates memory for 50 characters. Once we declare char(50) and insert only 10 characters of word then only 10 characters of memory will be used and other 40 characters of memory will be wasted.

varchar DataType
Varchar means variable characters and it is used to store non-unicode characters. It will allocate the memory based on number characters inserted. Suppose if we declared varchar(50) it will allocates memory of 0 characters at the time of declaration. Once we declare varchar(50) and insert only 10 characters of word it will allocate memory for only 10 characters.


nvarchar DataType

nvarchar datatype same as varchar datatype but only difference nvarchar is used to store Unicode characters and it allows you to store multiple languages in database. nvarchar datatype will take twice as much space to store extended set of characters as required by other languages.


So if we are not using other languages then it’s better to use varchar datatype instead of nvarchar.
varchar is single byte, nvarchar is double byte

Attached Dependency Property

Attached dependency property as being the property equivalent of an extension method.
You basically attach a new property to an existing object. Without actually modifying the object definition.
 Which is especially handy when inheritance is not possible, like in sealed objects.

 The most important application, as far as I am concerned, is that you can make something bindable that is not
bindable out of the box. If some value(s) a GUI component can only be set by a method, you cannot use it from MVVM,
for example. By making an attached dependency property that passes on the new value to said method you work around that.
 See below for how you make such a callback.

So how do you make an attached dependency property?

You make a static class, in which the property is declared and 'hosted'


public static class DependencyPropertyHoster
{
  public static readonly DependencyProperty MyPropertyNameProperty =
    DependencyProperty.RegisterAttached("MyPropertyName", 
    typeof(TargetPropertyType), 
    typeof(DependencyPropertyHoster), 
    new PropertyMetadata(CallBackWhenPropertyIsChanged));

  // Called when Property is retrieved
  public static TargetPropertyType GetMyPropertyName(DependencyObject obj)
  {
    return obj.GetValue(MyPropertyNameProperty) as TargetPropertyType;
  }

  // Called when Property is set
  public static void SetMyPropertyName(
     DependencyObject obj, 
     TargetPropertyType value)
  {
    obj.SetValue(MyPropertyNameProperty, value);
  }

  // Called when property is changed
  private static void CallBackWhenPropertyIsChanged(
   object sender, 
   DependencyPropertyChangedEventArgs args)
  {
    var attachedObject = sender as ObjectTypeToWhichYouWantToAttach;
    if (attachedObject != null )
    {
      // do whatever is necessary, for example
      // attachedObject.CallSomeMethod( 
      // args.NewValue as TargetPropertyType);
    }
   }
}
This is roughly the equivalent of
public partial class ObjectTypeToWhichYouWantToAttach
{
  TargetPropertyType _myPropertyName;
  TargetPropertyType MyPropertyName
 {
   get
   {
     return _myPropertyName;
   }
   set
   {
     if( _myPropertyName != value )
     {
        //CallBackWhenPropertyIsChanged...
     }
   }
  }
}

The whole thing works by naming convention. So if you call your property "MyPropertyName", then:


  • Your DependecyProperty needs to be called MyPropertyNameProperty
  • Your Set method needs to be called SetMyPropertyName
  • Your Get method needs to be called GetMyPropertyName

When you register your property the way I do, the members in the RegisterAttached method call are, from left to right:

  • The name of your property (as a string, yes)
  • Property value type (here “TargetPropertyType”, but of course that can be anything)
  • Type of the hosting class (i.e. DependencyPropertyHoster in this case)
  • Callbackmethod to be called when the property is changed.

Monday, May 29, 2017

Value Type and Garbage Collector Role

Garbage Collector play no role in de allocation of value type variable.

The stack is a block of pre-allocated memory one million bytes in size. Sometimes we use portions of that block of memory to store local variables of value type.The stack never changes in size; it's a one-million-byte block of pre-allocated memory.

The stack is divided into two contiguous regions, which we'll call the "valid" and "invalid" sections of the stack. On x86 architectures the ESP register points to the boundary between those regions.

The stack is an implementation detail of a specific version of the runtime.

In a multi-threaded situation each thread will have its own completely independent stack but they will share the heap. Stack is thread specific and Heap is application specific. The stack is important to consider in exception handling and thread executions.

Difference between stack and Heap

The stack is the memory set aside as scratch space for a thread of execution. When a function is called, a block is reserved on the top of the stack for local variables and some bookkeeping data. When that function returns, the block becomes unused and can be used the next time a function is called. The stack is always reserved in a LIFO (last in first out) order; the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack; freeing a block from the stack is nothing more than adjusting one pointer.

The heap is memory set aside for dynamic allocation. Unlike the stack, there's no enforced pattern to the allocation and deallocation of blocks from the heap; you can allocate a block at any time and free it at any time. This makes it much more complex to keep track of which parts of the heap are allocated or free at any given time; there are many custom heap allocators available to tune heap performance for different usage patterns.

Each thread gets a stack, while there's typically only one heap for the application (although it isn't uncommon to have multiple heaps for different types of allocation).


  • Both are stored in computer RAM.
  • Stack is faster than heap.
  • Variables created on the stack will go out of scope and automatically deallocated.
  • Data items on stack are allocated and deallocated by CPU; therefore memory will be managed efficiently, there will be no memory leaks and memory will not become fragmented.
  • Variables once allocated on to the stack cannot be resized.
  • Variables allocated from heap region can be resized using realloc()
  • Memory allocated from stack is called static memory allocation.
  • While, memory allocated from heap is called dynamic memory allocation.



  • Memory allocated from stack is called static memory allocation.



Can you implement IDisposable for value type ?
Structs being a value type can inherit IDisposable interface

Friday, May 26, 2017

Hosting a WCF service

A WCF service can be hosted in following ways

1. Self Hosting: 
       A WCF service can be self hosted using console application or windows forms.

        Benifit

  1.         Support all bindings.
  2.         Easy to debug no need to attach separate process
  3.         Flexi to support the life time of binding using Open() and Close method of service.


2. Hosting can be done using Window Service. --

Advantage
          Support all types of bindings
          In this type you can debug WCF  by attaching the WCF to Client

Disadvantage
  Difficult to Debug ( need to attach window service to client for debugging)
  Need to host on production server


3. Third way is hosting a WCF using IIS but in this support only HTTP binding it does not support Non HTTP Binding.
4. Using Window Activation Services, it supports all types of binding.

Thursday, May 25, 2017

Binding in WCF-21

What is Binding in WCF service?

Binding defines how the client will communicate with WCF service. Binding tell about three things in communication. There are different binding available in WCF like basiHttpBinding, wsHttpBinding, TCP,....

1. Transport Protocol (ex - HTTP, TCP, NamedPipe, MSMQ)
2. Message Encoding ( ex. text/Xml, Binary)
3. Protocol (ex. reliable messaging, transport support)

In WCF you can create your custom binding also.

For speed you can choose netTCP binding, if you have same platform on both end.

For communication client and WCF service should same configuration entry.

Configure WCF service endpoint dynamically in code

Endpoint and behavior setting can be write in code instead of config file.

As depicted below. It is written in host.

 using (ServiceHost host = new ServiceHost(typeof(CalculatorService.CalculatorService)))
            {
                ServiceMetadataBehavior serviceMetadataBehavior = new ServiceMetadataBehavior()
                {
                    HttpGetEnabled=true
                };


                host.Description.Behaviors.Add(serviceMetadataBehavior);
                host.AddServiceEndpoint(typeof(CalculatorService.ICalculatorService), new BasicHttpBinding(), "CalculatorService");

                host.Open();
                WriteLine("Host Started @ " + DateTime.Now.ToString());
                ReadKey();
                host.Close();
            }

And app.config file would defined as below

  <system.serviceModel>
    <services>
      <service name="CalculatorService.CalculatorService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:9001"/>
          </baseAddresses>
        </host>
      
      </service>
    </services>
  

  </system.serviceModel>

Interview MPS

1. What is the benefit of MVCC?
2. Project architecture.
3. MVC is stateful or stateless
4. How ASP .Net is stateful?
5. Write the regular expression for a word which contains 'age' but age word should not captured.
6. What is the use of pdflib and pdftron?
7. Have you worked on procedure?
8. Have you worked on database?
9. Is WPF MVC or not?

Shared by Arvind


Wednesday, May 24, 2017

Unhandled Exception in WCF

If any exception occurred in WCF that is not handled than it break the communication, we can not use the proxy again, to use it we have to new its object again.

Same thing will happen in case of WCF service throwing a .Net exception that's why it is another why a WCF service should not throw a .Net exception.

It is not true for basicHttpBinding because basicHttpBinding does not have session. wsHttpBinding have secure session so in case of wsHttpBinding communication will break.

How to Handle it?

Need to handle exception at service level and should throw FaultException.

WCF interview questions

1. Explain the WCF architechture.

WCF architecture consists
2. Advantages of WCF

  1. Service Oriented
  2. Location Independent
  3. Language Independent
  4. Platform Independent
  5. Support Multiple operation
  6. WCF can maintain transaction like COM+ Does
  7. It can maintain state
  8. It can control concurrency
  9. It can be hosted on IIS, WAS, Self hosting, Windows services.
It has AJAX Integration and JSON (JavaScript object notation) support.
  • WCF can be configured to work independently of SOAP and use RSS instead.
  • To improve communication, transmission speed needs to be optimized. This is done by transmitting binary-coded XML data instead of plain text to decrease latency.
  • Object life-cycle management and distributed transaction management are applicable to any application developed using WCF.

What is the difference between WCF and Web services?

Explain transactions in WCF?

A transaction is a logical unit of work consisting of multiple activities that must either succeed or fail together.
The following are the types of the Transactions:
  1. Atomic
  2. Long Running

Phases of WCF Transaction:

  • Prepare Phase - In this phase, the transaction manager checks whether all the entities are ready to commit for the transaction or not.
  • Commit Phase - In this phase, the commitment of entities get started in reality.

What is one-way operation?

When an operation has no return value, and the client does not care about the success or failure of the invocation. WCF offers one-way operations to support this sort of fire-and-forget invocation,: once the client issues the call, WCF generates a request message, but no correlated reply message will ever return to the client. 
  1. [OperationContract(IsOneWay = true)]  
  2.     void Add(double n1, double n2);  

Explain what is DataContractSerializer?

WCF provides a message-oriented programming framework. Internally WCF represents all the messages by a Message class. When WCF transmits a message it takes a logical message object and encodes it into a sequence of bytes. After that WCF reads those bytes and decodes them in a logical object. The process forms a sequence of bytes into a logical object; this is called an encoding process. At runtime when WCF receives the logical message, it transforms them back into corresponding .Net objects. This process is called serialization. 

DataContractSerializer
WCF supports three basic serializers:
  • XMLSerializer
  • NetDataContractSerializer
  • DataContractSerializer
WCF deserializes WCF messages into .Net objects and serializes .Net objects into WCF messages. WCF provides DataContractSerializer by default with a servicecontract. We can change this default serializer to a custom serializer like XMLSerializer.
NetDataContractSerializer

NetDataContractSerializer is analogous to .Net Remoting Formatters. It implements IFormatter and it is compatible with [Serializable] types. It is not recommended for service oriented design.

What is Transaction Propagation? And how WCF support it?

Transaction propagation is the ability to propagate a transaction across the boundaries of a single service. Or in other words, we can say that a service can participate in a transaction that is initiated by a client. 

To enable transaction propagation, we need to set the value of the TransactionFlow property of the binding being used. This can be done programmatically as follows: 
  1. WSHttpBinding bindingBeingUsed = new WSHttpBinding();  
  2. bindingBeingUsed.TransactionFlow = "true";  
Or it can be done decoratively by updating the configuration file as follows:
  1.   
  2.       
  3.         "binding1" transactionFlow="true" />   


  •     






  •   The default value for the TransactionFlow property is "False".

    Do all WCF bindings support Transaction Propagation?

    No. Not all WCF bindings support transaction propagation. Only the following list of bindings support it:
    • wsHttpBinding
    • netTcpBinding
    • netNamedPipeBinding
    • wsDualHttpBinding
    • wsFederationHttpBinding

    What is WCF throttling?

    WCF throttling provides some properties that you can use to limit how many instances or sessions are created at the application level. Performance of the WCF service can be improved by creating proper instance.

    WCF throttling provides the prosperities maxConcurrentCalls, maxConcurrentInstances, and maxConcurrentSessions, that can help us to limit the number of instances or sessions are created at the application level.


    maxConcurrentCallsThis specifies the maximum number of messages processed across the service host. The default value for this property is 16 (WCF 4.0 is improved to default is 16 * Processor Count).
    maxConcurrentInstancesThis specifies the maximum number of instances of a context object that executes at one time with the service. The default is Int32.MaxValue.
    maxConcurrentSessionsThis specifies the maximum number of sessions at one time within the service host object. The default value is 10 (WCF 4.0 increases that to 100 * Processor Count).


    What is WCF Concurrency and How many modes are of Concurrency in WCF?

    WCF Concurrency means “Several computations are executing simultaneously.

    WCF concurrency helps us configure how WCF service instances can serve multiple requests at the same time.
    We can use the concurrency feature in the following three ways:
    • Single
    • Multiple
    • Reentrant
    Single: A single request will be processed by a single thread on a server at any point of time. The client proxy sends the request to the server, it process the request and takes another request.

    Concurrency

    Multiple: Multiple requests will be processed by multiple threads on the server at any point of time. The client proxy sends multiple requests to the server. Requests are processed by the server by spawning multiple threads on the server object. 

    Reentrant: The reentrant concurrency mode is nearly like the single concurrency mode. It is a single-threaded service instance that receives requests from the client proxy and it unlocks the thread only after the reentrant service object calls the other service or can also call a WCF client through call back.

    What is Instance Context Mode in WCF?
    Answer: An Instance Context mode defines how long a service instance remains on the server.


    Whenever the client sends a request to a WCF service, what exactly happens behind the scenes? Basically after making a client request the WCF service will create a service class instance at the service that will do the operations involved and then it will return the response back to the client. In this request and response process the service instance object has been created in the process.

    The WCF framework has defined the following three Instance Context modes:

    PerCall: A new instance of the service will be created for the request from the same client or a different client, meaning every request is a new request. In this mode no state is maintained.In per-call service, every client request achieves a new dedicated service instance and its memory consumption is less as compared to other types of instance activation.


    1. [ServiceContract]  
    2. interfaceIMyContract  
    3. {...}  
    4. [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]  
    5. classMyService:IMyContract  
    6. {...}  
    Per-Session Service: A new Instance will be created for every new client session and the scope of that object will be the scope of that session.
    1. [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]  
    2. classMyService:IMyContract  
    3. {...}  
    Singleton Service: A single instance will be created for the service object that will take care of all the requests coming from the same client or a different one.

    By decorating the service with a service behavior, an Instance Context mode can be set.

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)] 


    What is Security Implementation in WCF? How many are there?
    WCF supports following securities:
    • Message
    • Transport
    • TransportWithMessageCredential

    Message Security
    Message security uses the WS-Security specification to secure messages. The message is encrypted using the certificate and can now safely travel over any port using plain http. It provides end-to-end security.

    Transport Security
    Transport security is a protocol implemented security so it works only point to point. As security is dependent on protocol, it has limited security support and is bounded to the protocol security limitations.

    TransportWithMessageCredential:
    This we can call a mixture of both Message and Transport security implementation.

    Tuesday, May 23, 2017

    WPF interview Questions

    1. Can you explain the complete WPF object hierarchy?



    Object: - As WPF is created using .NET so the first class from which WPF UI classes inherits is the .NET object class.
    Dispatcher: - This class ensures that all WPF UI objects can be accessed directly only by the thread who own him. Other threads who do not own him have to go via the dispatcher object.
    Dependency: - WPF UI elements are represented by using XAML which is XML format. At any given moment of time a WPF element is surrounded by other WPF elements and the surrounded elements can influence this element and this is possible because of this dependency class. For example if a textbox surrounded by a panel, its very much possible that the panel background color can be inherited by the textbox.
    Visual: - This is the class which helps WPF UI to have their visual representation.
    UI Element: - This class helps to implement features like events, input, layouting etc.
    Framework element: - This class supports for templating , styles , binding , resources etc.
    And finally all WPF controls textbox , button , grids and whatever you can think about from the WPF tool box inherits from the framework element class.

    Does that mean WPF has replaced DirectX?

    No, WPF does not replace DirectX. DirectX will still be still needed to make cutting edge games. The video performance of directX is still many times higher than WPF API. So when it comes to game development the preference will be always DirectX and not WPF. WPF is not an optimum solution to make games, oh yes you can make a TIC TAC TOE game but not high action animation games.
    One point to remember WPF is a replacement for windows form and not directX.

    So is XAML meant only for WPF ?

    No,XAML is not meant only for WPF.XAML is a XML-based language and it had various variants.
    WPF XAML is used to describe WPF content, such as WPF objects, controls and documents. In WPF XAML we also have XPS XAML which defines an XML representation of electronic documents.
    Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us to create rich web content with 2-dimensional graphics, animation, and audio and video.
    WWF XAML helps us to describe Windows Workflow Foundation content. WWF engine then uses this XAML and invokes workflow accordingly.

    Can you explain the overall architecture of WPF?



    What is the need of WPF when we had windows forms?

    CodeRemember: - ABCDEFG
    A - Anywhere execution ( Windows or  browser application)
    B - Bindings ( less coding)
    C - Common look and feel ( resource and styles) -- one style can be bind to all text box
    D - Declarative programming (XAML)
    E - Expression blend animation ( Animation ease)
    F - Fast execution ( Hardware acceleration)
    G - Graphic hardware independent ( resolution independent)

    Explain the difference between static and dynamicresource?

    static resource declared in xaml while dynamic resource can be set from code behind.

    When should we use static resource over dynamic resource ?

    Dynamic resources reduce application performance because they are evaluated every time the resource is needed. So the best practice is use Static resource until there is a specific reason to use dynamic resource. If you want resource to be evaluated again and again then only use dynamic resource.

    What are the benefits of MVVM?

    Separation of concern: -
    Increased UI Reusability: 
    Automated UI Unit testing: 


    Followers

    Link