Tuesday 31 July 2012

WCF : Binding


1.    What is Binding in WCF?
ü  Simple definition for Binding describes how the client will communicate with service.
ü  Bindings in WCF define the configuration of communication channel between clients and services.
ü  Binding specifies
1. Transport Protocol
2. Message encoding
3. Security Mechanism
4. Reliable Messaging
5. Transactions Support


2.    What are built-in bindings in WCF?
1.      BasicHttpBinding
2.      NetPeerTcpBinding
3.      WSFederationHttpBinding
4.      NetNamedPipeBinding
5.      WSHttpBinding
6.      WSDualHttpBinding
7.      NetTcpBinding
8.      NetMsmqBinding
9.      MsmqIntegrationBinding
I have used BasicHttpBinding, WSHttpBinding and NetTcpBinding mostly.

3.    How can you configure binding in WCF?
You can configure binding either using
a.       Configuration file
b.       Programmatically using code
c.       Both
Specifications given in configuration file are overwritten by code.
I prefer configuring binding in configuration file. It’s easy and efficient.

4.    Explain how bindings are used?
Suppose there is a scenario where a service has to be used by two type of client.
ü  One of the client will access SOAP using http and
ü  Other client will access Binary using TCP.
In such cases we need to configure extra endpoint in configuration file and the job is done.
In the configuration file common behaviors affect all endpoints globally, service behaviors affect only service-related aspects, endpoint behaviors affect only endpoint-related properties, and operation-level behaviors affect particular operations.

In the service behavior below the servieMetadata node is added with attribute httGetEnabled='true'. This attribute will specify the publication of the service metadata. Similarly we can add more behavior to the service.
<system.serviceModel>
    <services>
      <service name="MathService"
        behaviorConfiguration="MathServiceBehavior">
        <endpoint address="" contract="IMathService"
          binding="wsHttpBinding"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MathServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>



5.    Does WCF support custom binding?
Yes, bindings in WCF are completely extensible and we can create a customized one. 

6.    In WCf, which binding is used if you are using WCF-to-WCF communication between processes on the same machine?
NetNamedPipesBinding binding is used.

7.  Which is binding in WCF support message streaming?

ü  Following bindings supports the streaming in WCF: 
1. basicHttpBinding 
2. netTcpBinding 
3. netNamedPipeBinding 
8. Which is binding in WCF support reliable session?
             1.    wsHttpBinding 
             2.     wsDualHttpBinding 
             3.    wsFederationHttpBinding 
             4.    netTcpBinding 

WCF - ABC of WCF

What is Address in WCF? What are the various transport schema available in WCF?
ü  Address is a way of letting client know that where a service is located.
ü   In WCF, every service is associated with a unique address.
ü   This contains the location of the service and transport schemas. 
ü  Address format of WCF transport schema always follow 
Ø  [Transport]://[machine or domain][:optional port]. 
ü  WCF supports following transport schemas 
ü  HTTP 
ü  TCP 
ü  Peer network 
ü  IPC (Inter-Process Communication over named pipes) 
ü  MSMQ 

HTTP Address Format 
http://localhost:8888
the way to read the above URL is "Using HTTP, go to the machine called localhost, where on port 8888 someone is waiting"
When the port number is not specified, the default port is 80. 
TCP Address Format 
net.tcp://localhost:8888/MyService
when a port number is not specified, the default port is 808:
net.tcp://localhost/MyService
NOTE: Two HTTP and TCP addresses from the same host can share a port, even on the same machine. 

IPC Address Format 
net. Pipe://localhost/MyPipe
We can only open a named pipe once per machine, and therefore it is not possible for two named pipe addresses to share a pipe name on the same machine. 


MSMQ Address Format 
net.msmq://localhost/private/MyService
net.msmq://localhost/MyService


What is Binding in WCF? What are characteristics of Binding in WCF?
ü  Binding describes how client will communicate with service.
ü  There are different protocols available for the WCF to communicate to the Client.
ü  You can mention the protocol type based on your requirements.
ü  A binding has several characteristics, including the following:
·         Transport -Defines the base protocol to be used like HTTP, Named Pipes, TCP, and MSMQ are some type of protocols.
·         Encoding (Optional) - Three types of encoding are available-Text, Binary, or Message Transmission Optimization Mechanism (MTOM). MTOM is an interoperable message format that allows the effective transmission of attachments or large messages (greater than 64K).
·         Protocol(Optional) - Defines information to be used in the binding such as Security, transaction or reliable messaging capability
ü  The following table gives some list of protocols supported by WCF binding.

Binding
Description
BasicHttpBinding
Basic Web service communication. No security by default
WSHttpBinding
Web services with WS-* support. Supports transactions
WSDualHttpBinding
Web services with duplex contract and transaction support
WSFederationHttpBinding
Web services with federated security. Supports transactions
MsmqIntegrationBinding
Communication directly with MSMQ applications. Supports transactions
NetMsmqBinding
Communication between WCF applications by using queuing. Supports transactions
NetNamedPipeBinding
Communication between WCF applications on same computer. Supports duplex contracts and transactions
NetPeerTcpBinding
Communication between computers across peer-to-peer services. Supports duplex contracts
NetTcpBinding
Communication between WCF applications across computers. Supports duplex contracts and transactions

What are contracts in WCF? 
ü  Collection of operation that specifies what the endpoint will communicate with outside world.
ü  Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client.
ü  Each operation is a simple exchange pattern such as one-way, duplex and request/reply.

    What are various types contracts in WCF?
In WCF, all services expose contracts. The contract is a platform-neutral and standard way of describing what the service does.

WCF defines four types of contracts.
  • Service contracts: Describe which operations the client can perform on the service.
  • Data contracts: Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.
  •  Fault contracts: Define which errors are raised by the service, and how the service handles and propagates errors to its clients.
  • Message contracts: Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.





Monday 30 July 2012

PRISM : Explained

Using Prism you can create a WPF application , the client-side of a silverlight application and a Windows Phone applications.

The client side application of PRISM generally has a Shell, a few modules and the infrastructure to connect these:
  • Shell
  • Modules
  • Infrastructure 

Namespace

Namespace used in prism are
  • Microsoft.Practices.Composite.dll
  • Microsoft.Practices.Composite.Presentation.dll
  • Microsoft.Practices.Composite.UnityExtensions.dll
  • Microsoft.Practices.Unity.dll
  • Microsoft.Practices.ServiceLocation.dll

Shell

The foundation of the application is “The Shell”.  The Shell is the top-level window of an application based on the Prism Composite Application Library. This window is a place to host different user interface (UI) components that exposes a way for itself to be dynamically populated by others, and it may also contain common UI elements, such as menus and toolbars. The Shell window sets the overall appearance of the application.

The shell that is responsible to load the Modules.

Module 

A module represents a set of related concerns. It can include components such as views, business logic, and pieces of infrastructure, such as services for logging or authenticating users. Modules are independent of one another but can communicate with each other in a loosely coupled fashion.

Infrastructure 

The Infrastructure Assembly is a shared library referenced by both the shell project and the module projects, and holds shared types such as constants, event types, entity definitions and interfaces.

Looking inside Shell

Shell contains BootStrapper.cs

The Bootstrapper component is used by the application to initialize the various Prism components and services. It is used to initialize the dependency injection container to register any application-level components and services with it. It is also used to configure and initialize the module catalog and the shell's view and view model or presenter.

The Bootstrapper inherits from 
  • Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper 
To be able to run the bootstrapper at least one module should be registered in our application. 


Shell contains Shell.xaml on to which modules are loaded.

Modules can be loaded in the regions defined in Shell.xaml.

Regions


Regions are the placeholders for the controls defined in Modules.  Modules can be added into the shell one by one , generally we add one module at begining and then continue adding more and more.
Modules can be added to regions in shell.xaml and can be added/removed at runtime.Because our application is build with modularity in mind it’s the Module and not the Shell that should define which views need to be added to the regions.

Region Manager Service

Views are created inside modules.To add views to our regions we use the prism region manager service. The region manager service is responsible for maintaining a collection of regions and creating new regions for controls.  Typically, we interact directly with region manager service to locate regions in a decoupled way through their name and add views to those regions. By default, the UnityBootstrapper base class registers an instance of this service in the application container. This means that we can obtain a reference to the region manager service in our application by using dependency injection.

So, this is how my Shell and Module talk to each other.





and following shows the basic terms in PRISM



Bootstrapper – let’s get this party started!


  • Kicks off the application
  • Starts the main UI container (the Shell)
  • Registers Modules and loads, if needed
  • Registers any global singletons (optional)

Shell – the main view (might be a master page)


  • The main UI container
  • Houses all of the Views that will be loaded
  • Can be split into Regions
  • Knows nothing of what will be loaded into it

Regions – content areas


  • Area(s) in the Shell where Views can be placed
  • Are given a name
  • Can contain context, if needed
  • RegionManager exists to help maintain Regions

Modularity – self contained modules


  • To the user this is seamless
  • Can be developed separately
  • Does not reference other modules
  • Solution is split into Modules
  • Modules share infrastructure and Models

Inversion of Control (IoC)


  • Unity or other Dependency Injection (DI) Tools 
  • Helps for test ability and mocking
  • Abstraction
  • Container object allows classes to be registered against their interfaces
  • When an interface is requested, the container creates the class registered with the interface
  • Supports singletons

Infrastructure – common tools


  • A Silverlight class library project
  • Contains shareable items for the modules
  • Classes
  • Assets
  • Resources
  • Makes no references
  • A pure library

Commanding – Action & Reactions


  • Allows events between a View and a ViewModel through Data Binding
  • ViewModel declares the Command receiver
  • Command is declarative in XAML
  • Button – Click,ListBox (Selector) – Selected
  • Command is data bound to the ViewModel’s command receiver
  • Can be disabled/enabled based on rules

Event Aggregation: Publish – Subscribe pattern


  • Allows events of any kind to be published and subscribed to
  • Can be cross module
  • Can be filtered by subscribers
  • For example:
  • Click on a menu item in the Shell
  • Event is invoked by the publisher
  • Event is received by the subscriber
  • The subscriber then loads a View in a Region in the Shell


Conclusion

Thinking of a Prism as a set of options is probably the best way.One pick only the features one really needs, and simply skip the rest. Architecture of Prism provides flexibility, and that is the first advantage of adapting it to project.

You can also read this article at dotnetspider.

Dependency Property : Silverlight/WPF

WPF/Silverlight introduce a new property called dependency property. In this article we will see

  • What is a dependency object
  • What is a dependency property
  • Compare dependency property with CLR property
  • Advantages of dependency properties
  • Attached Properties


Sunday 29 July 2012

MEF and DI/IOC


MEF and IOC are two different design patterns created for two completely different scenarios.

  1. IOC is most useful with Static dependencies , MEF is useful for dynamic dependencies.
  2. IOC is for registration of known parts whereas MEF is for discovery of unknown parts.
  3. When working with/for 3rd party dlls , MEF is more the best choice.
  4. Id you have two dlls, taking a decision at runtime to swap the two is possible using MEF and not IOC.
  5. The principle purpose of MEF is extensibility; to serve as a 'plug-in' framework for when the author of the application and the author of the plug-in (extension) are different and have no particular knowledge of each other beyond a published interface (contract) library.
  6. Plug-in versioning problem is not there in MEF , but may present in IOC.
  7. Again, MEF 'intent' is tightly focused on anonymous plug-in extensibility, something that very much differentiates it from other IoC containers. So while MEF can be used for composition, that's merely a small intersection of its capabilities relative to other IoCs, with which I suspect we'll be seeing a lot of incestuous interplay going forward.
  8.  MEF is basically using some IoC-like principles to enable application composition and dependency management.  So in some way it's kind of like IoC for your application.  It's focused on discovering components and letting your application compose itself on the fly.  It's designed for larger applications like Visual Studio.  Now that I understand it, and, yeah, it's pretty darn cool.
  9. In my opinion, IoC is more about a consistent loose-coupling pattern across your app, and in many ways the factories act like smart service providers, with the containers adding a variety of ways to configure how query resolutions are done at a particular point in time (e.g. they allow you to register bindings in config or in code, statically or dynamically, etc.)


Hosting MEF

When hosting a MEF application . following things should be considered:

  1. Are you hosting a Web application / Desktop application?
  2. Are you hosting this as an application/library?
Check the following links for more information

Once, I have successfully deployed MEF I will update the blog.

MEF : Sample application and explanation

In this post we will create a sample application and we will try to understand the terms:

  • Parts
  • Import
  • Export
  • Composition
  • Catalog
  • Contract

Parts, catalogs, and the composition container

Parts and the composition container are the basic building blocks of a MEF application. A part is any object that imports or exports a value, up to and including itself. A catalog provides a collection of parts from a particular source. The composition container uses the parts provided by a catalog to perform composition, the binding of imports to exports.

Imports and exports

Imports and exports are the way by which components communicate. With an import, the component specifies a need for a particular value or object, and with an export it specifies the availability of a value. Each import is matched with a list of exports by way of its contract.
MEF is a part of the Microsoft .NET Framework, with types primarily under the
System.ComponentModel.Composition.* namespace.

The two namespace we normally add are:
  • using System.ComponentModel.Composition;
  • using System.ComponentModel.Composition.Hosting;
The other options possible are :


The core of the MEF composition model is the composition container, which contains all the parts available and performs composition. 

The most common type of composition container is CompositionContainer.

In order to discover the parts available to it, the composition containers makes use of a catalog. A catalog is an object that makes available parts discovered from some source. 

 MEF provides catalogs to discover parts from a provided type, an assembly, or a directory. Application developers can easily create new catalogs to discover parts from other sources, such as a Web service.

The call to ComposeParts tells the composition container to compose a specific set of parts, in this case the current instance of Program. At this point, however, nothing will happen, since Program has no imports to fill.

 Now, let us import an interface ICalculator inside the program class.
The definition is similar except for the , Import attribute. This attribute declares something to be an import; that is, it will be filled by the composition engine when the object is composed.
Every import has a contract, which determines what exports it will be matched with. The contract can be an explicitly specified string, or it can be automatically generated by MEF from a given type, in this case the interface ICalculator. 

Any export declared with a matching contract will fulfill this import.

The contract is independent from the type of the importing object. (In this case, you could leave out the typeof(ICalculator). MEF will automatically assume the contract to be based on the type of the import unless you specify it explicitly.)

Bow, let us add the interface that we are importing and let us also add a class which implements this interface.

Let us decorate this class with the Export attribute, export that will match the import in Program. In order for the export to match the import, the export must have the same contract.
Now that we have added imports and exports , we need to fill the container with this, so we add followinng to the program.cs

All the logic to calculate is written in FirstCalculator class, the interface ICalculate is implemented.
So, now all the tasks for the business logic is just in 1 place FirstCalculator.
Program contains the composition container which is filled with the required import.
So, now my work is to instantiate the composition container from my main method and use it.
This is a simple example which shows a single method import and export.

But when we are going to do a real calculator we will be importing methods for add, subtract , divide , multiply etc.
A single import method won't work in this case.

 An ordinary ImportAttribute attribute is filled by one and only one ExportAttribute. If more than one is available, the composition engine produces an error. To create an import that can be filled by any number of exports, you can use the ImportManyAttribute attribute.

A good tutorial for importmany is at importmany example.

A normal question which is raised many times is

My import isn't being set, what could be wrong?

Check :
  • Is the member (property or constructor) being imported public?
  • Field imports aren't supported, use properties instead
  • Is the imported member the exact same contract type as the export?


Happy importing-exporting

Friday 27 July 2012

ASP.NET Interview Questions

  1. From constructor to destructor (taking into consideration Dispose() and the concept of non-deterministic finalization), what the are events fired as part of the ASP.NET System.Web.UI.Page lifecycle. Why are they important? What interesting things can you do at each?
  2. What are ASHX files?  What are HttpHandlers?  Where can they be configured?
  3. What is needed to configure a new extension for use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?
  4. What events fire when binding data to a data grid? What are they good for?
  5. Explain how PostBacks work, on both the client-side and server-side. How do I chain my own JavaScript into the client side without losing PostBack functionality?
  6. How does ViewState work and why is it either useful or evil?
  7. What is the OO relationship between an ASPX page and its CS/VB code behind file in ASP.NET 1.1? in 2.0?
  8. What happens from the point an HTTP request is received on a TCP/IP port up until the Page fires the On_Load event?
  9. How does IIS communicate at runtime with ASP.NET?  Where is ASP.NET at runtime in IIS5? IIS6?
  10. What is an assembly binding redirect? Where are the places an administrator or developer can affect how assembly binding policy is applied?
  11. Compare and contrast LoadLibrary(), CoCreateInstance(), CreateObject() and Assembly.Load().
  12. Describe the difference between a Thread and a Process?
  13. What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
  14. What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
  15. What is the difference between an EXE and a DLL?
  16. What is strong-typing versus weak-typing? Which is preferred? Why?
  17. Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
  18. What is a PID? How is it useful when troubleshooting a system?
  19. How many processes can listen on a single TCP/IP port?
  20. What is the GAC? What problem does it solve?
  21. Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
  22. Describe what an Interface is and how it’s different from a Class.
  23. What is Reflection?
  24. What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
  25. Are the type system represented by XmlSchema and the CLS isomorphic?
  26. Conceptually, what is the difference between early-binding and late-binding?
  27. Is using Assembly.Load a static reference or dynamic reference?
  28. When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
  29. What is an Asssembly Qualified Name? Is it a filename? How is it different?
  30. Is this valid? Assembly.Load("foo.dll");
  31. How is a strongly-named assembly different from one that isn’t strongly-named?
  32. Can DateTimes be null?
  33. What is the JIT? What is NGEN? What are limitations and benefits of each?
  34. How does the generational garbage collector in the .NET CLR manage object lifetime? 
  35. What is non-deterministic finalization?
  36. What is the difference between Finalize() and Dispose()?
  37. How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
  38. What does this useful command line do? tasklist /m "mscor*"
  39. What is the difference between in-proc and out-of-proc?
  40. What technology enables out-of-proc communication in .NET?
  41. When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003? Windows 7? Windows 2008?
  42. What’s wrong with a line like this? DateTime.Parse(myString);
  43. What are PDBs? Where must they be located for debugging to work?
  44. What is cyclomatic complexity and why is it important?
  45. Write a standard lock() plus “double check” to create a critical section around a variable access.
  46. What is FullTrust? Do GAC’ed assemblies have FullTrust?
  47. What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
  48. What does this do? gacutil /l | find /i "Corillian"
  49. What does this do? sn -t foo.dll
  50. What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
  51. Contrast OOP and SOA. What are tenets of each?
  52. How does the XmlSerializer work? What ACL permissions does a process using it require?
  53. Why is catch(Exception) almost always a bad idea?
  54. What is the difference between Debug.Write and Trace.Write? When should each be used?
  55. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
  56. Does JITting occur per-assembly or per-method? How does this affect the working set?
  57. Contrast the use of an abstract base class against an interface?
  58. What is the difference between a.Equals(b) and a == b?
  59. In the context of a comparison, what is object identity versus object equivalence?
  60. How would one do a deep copy in .NET?
  61. Explain current thinking around IClonable.
  62. What is boxing?
  63. Is string a value type or a reference type?
  64. What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
  65. Why are out parameters a bad idea in .NET? Are they?
  66. Can attributes be placed on specific parameters to a method? Why is this useful?
  67. Juxtapose the use of override with new. What is shadowing?
  68. Explain the use of virtual, sealed, override, and abstract.
  69. Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
  70. Explain the differences between public, protected, private and internal.
  71. What benefit do you get from using a Primary Interop Assembly (PIA)?
  72. By what mechanism does NUnit know what methods to test?
  73. What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
  74. What is the difference between typeof(foo) and myFoo.GetType()?
  75. Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
  76. What is this? Can this be used within a static method?
  77. Describe how a browser-based Form POST becomes a Server-Side event like Button1_OnClick.
  78. What is a PostBack?
  79. What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
  80. What is the <machinekey> element and what two ASP.NET technologies is it used for?
  81. What three Session State providers are available in ASP.NET 1.1? What are the pros and cons of each?
  82. What is Web Gardening? How would using it affect a design?
  83. Given one ASP.NET application, how many application objects does it have on a single proc box? A dual? A dual with Web Gardening enabled? How would this affect a design?
  84. Are threads reused in ASP.NET between reqeusts? Does every HttpRequest get its own thread? Should you use Thread Local storage with ASP.NET?
  85. Is the [ThreadStatic] attribute useful in ASP.NET? Are there side effects? Good or bad?
  86. Give an example of how using an HttpHandler could simplify an existing design that serves Check Images from an .aspx page.
  87. What kinds of events can an HttpModule subscribe to? What influence can they have on an implementation? What can be done without recompiling the ASP.NET Application?
  88. Describe ways to present an arbitrary endpoint (URL) and route requests to that endpoint to ASP.NET.
  89. Explain how cookies work. Give an example of Cookie abuse.
  90. Explain the importance of HttpRequest.ValidateInput()?
  91. What kind of data is passed via HTTP Headers?
  92. Juxtapose the HTTP verbs GET and POST. What is HEAD?
  93. Name and describe at least a half dozen HTTP Status Codes and what they express to the requesting client.
  94. How does if-not-modified-since work? How can it be programmatically implemented with ASP.NET?
  95. Explain <@OutputCache%> and the usage of VaryByParam, VaryByHeader.
  96. How does VaryByCustom work?
  97. How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.aspx?q=5)?
  98. What is the purpose of XML Namespaces?
  99. When is the DOM appropriate for use? When is it not? Are there size limitations?
  100. What is the WS-I Basic Profile and why is it important?
  101. Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. Include elements from both namespace.
  102. What is the one fundamental difference between Elements and Attributes?
  103. What is the difference between Well-Formed XML and Valid XML?
  104. How would you validate XML using .NET?
  105. Why is this almost always a bad idea? When is it a good idea? myXmlDocument.SelectNodes("//mynode");
  106. Describe the difference between pull-style parsers (XmlReader) and eventing-readers (Sax)
  107. What is the difference between XPathDocument and XmlDocument? Describe situations where one should be used over the other.
  108. What is the difference between an XML "Fragment" and an XML "Document."
  109. What does it meant to say “the canonical” form of XML?
  110. Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve?
  111. Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?
  112. Does System.Xml support DTDs? How?
  113. Can any XML Schema be represented as an object graph? Vice versa?
  114. What is SOLID?
  115. Why is the Single Responsibility Principle important?
  116. What is Inversion of Control? How does that relate to dependency injection?
  117. How does a 3 tier application differ from a 2 tier one?
  118. Why are interfaces important?
  119. What is the Repository pattern? The Factory Pattern? Why are patterns important?
  120. What are some examples of anti-patterns?
  121. Who are the Gang of Four? Why should you care?
  122. How do the MVP, MVC, and MVVM patterns relate? When are they appropriate?
  123. Explain the concept of Separation of Concerns and it's pros and cons.
  124. Name three primary attributes of object-oriented design. Describe what they mean and why they're important.
  125. Describe a pattern that is NOT the Factory Pattern? How is it used and when?
  126. You have just been put in charge of a legacy code project with maintainability problems. What kind of things would you look to improve to get the project on a stable footing?
  127. Show me a portfolio of all the applications you worked on, and tell me how you contributed to design them.
  128. What are some alternate ways to store data other than a relational database? Why would you do that, and what are the trade-offs?
  129. Explain the concept of convention over configuration, and talk about an example of convention over configuration you have seen in the wild.
  130. Explain the differences between stateless and stateful systems, and impacts of state on parallelism.
  131. Discuss the differences between Mocks and Stubs/Fakes and where you might use them (answers aren't that important here, just the discussion that would ensue).
  132. Discuss the concept of YAGNI and explain something you did recently that adhered to this practice.
  133. Explain what is meant by a sandbox, why you would use one, and identify examples of sandboxes in the wild.
  134. Concurrency
  135. What's the difference between Locking and Lockless concurrency models?
  136. What kinds of problems can you hit with locking model? And a lockless model?
  137. What trade offs do you have for resource contention?
  138. How might a task-based model differ from a threaded model?
  139. What's the difference between asynchrony and concurrency?
  140. Are you still writing code? Do you love it?
  141. You've just been assigned to a project in a new technology how would you get started?
  142. How does the addition of Service Orientation change systems? When is it appropriate to use?

PRISM : An Introduction

What is PRISM?


Prism (or Composite WPF) is a framework provided by Microsoft to help build composite WPF ,Silverlight and Window Phone 7 applications.
It has mechanisms for

  • UI composition,
  •  Module management and 
  • Dependency injection.
Prism uses the design concepts of 
  • Separation of concern
  • Loose Coupling

 Prism helps you to design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application. These types of applications are known as composite applications.

Advantages of PRISM

  • Create an application from modules that can be built, assembled, and, optionally, deployed by independent teams using WPF or Silverlight.
  • Minimize cross-team dependencies and allow teams to specialize in different areas, such as user interface (UI) design, business logic implementation, and infrastructure code development.
  • Use an architecture that promotes reusability across independent teams.
  • Increase the quality of applications by abstracting common services that are available to all the teams.
  • Incrementally integrate new capabilities.

Important terms in PRISM

Shell:The main window of a WPF application or the top-level UserControl of a Silverlight application where the primary UI content is contained.

Region :A named location that you can use to define where a view will appear. Modules can locate and add content to a region in the layout without exact knowledge of how and where the region is visually displayed. This allows the appearance and layout to change without affecting the modules that add the content to the layout.

Region Manager:The class responsible for maintaining a collection of regions and creating new regions for controls. The RegionManager finds an adapter mapped to a WPF or Silverlight control and associates a new region to that control.

Regions allow you to define named placeholders in your main view (the “Shell”). When you initialize your module, you can inject views (e.g. user controls) into these placeholders by specifying their name. This helps separate the application layout from specific views, and allows injecting other views at run time (such as add-ins).

Region Context is a technique that can be used to share context between a parent view and child views that are hosted in a region. The RegionContext can be set through code or by using data binding XAML.


Bootstrapper:The class responsible for the initialization of an application built using the Prism Library.

Composite application: A composite application is composed of a number of discrete and independent modules. These components are integrated together in a host environment to form a single, seamless application.

Event Aggregator:A service that is primarily a container for events that allows publishers and subscribers to be decoupled so they can evolve independently. This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or other modules.

Module:A logical unit of separation in the application

Module Catalog:Defines the modules that the end user needs to run the application. The module catalog knows where the modules are located and the module's dependencies.

Module Manager:The main class that manages the process of validating the module catalog, retrieving modules if they are remote, loading the modules into the application domain, and invoking the module's Initialize method

View Discovery:A way to add, show, or remove views automatically in a region by associating the type of a view with a region name. Whenever a region with that name displays, the registered views will be automatically created and added to the region.

View Injection: A way to add, show, or remove views programmatically  in a region by adding or removing instances of a view to a region. The code interacting with the region does not have direct knowledge of how the region will handle displaying the view.


PRISM Architecture



When to Use View Discovery vs. View Injection

View discovery is a automatic and simple approach to composing views and getting them displayed in a region. In general, View discovery is used , but you can use view injection if you need one of the following:

  • Explicit or programmatic control over when a view is created and displayed, or when you need to remove a view from a region, for example, as a result of application logic.
  • To display multiple instances of the same views into a region, where each view instance is bound to different data.
  • To control which instance of a region a view is added (for example, if you want to add customer detail view to a specific customer detail region). Note that this scenario requires scoped regions described later in this topic.

What PRISM cannot do

  • Occasional connectivity and data synchronization
  • Service and messaging infrastructure design
  • Authentication and authorization
  • Application performance
  • Application versioning
  • Error handling and fault tolerance