Sunday, January 26, 2014

Lambdas and Delegates

Anonymous Methods in Action





Understanding Lambda Expressions














Assigning a Lambda to a Delegate
 

Handling Empty Parameters

Delegates that don't accept any parameters can be handled using lambdas:

Delegates in .NET

The .NET framework provides several different delegates that provide flexible options:
  1. Action - Accepts a single parameter and returns no value
  2. Func - Accepts a single parameter and return a value of type TResult

Using Action

Action can be used to call a method that accepts a single parameter of type T:












Using Func

Func supports a single parameter (T) and returns a value (TResult):











Summary

  • Lambdas provide a way to define inline methods using a concise syntax
  • The .NET Framework provides several built-in delegate types such as:
      • Action
      • Func
Please find below link of source code providing example.

What is meant by “N Tier”?

Some Number of Tiers or Layers

      1.      Logical and sometimes Physical separation
2.      May be deployed separately
3.      May be developed separately

Tiers and Layers
  1.     Terms often used interchangeably
  2.      Layer can be applied specifically to the logical structure of the application
  3.     Tier can be applied specifically to the physical structure of the system infrastructure

Logical vs. Physical Separation
                        Logical separation refers to: Code organization
                        Namespaces, classes, folders, and assemblies
                        A software design pattern
                         
                        Physical separation refers to: Infrastructure organization
                        Separate physical processes, machines, devices
                        A software architecture

N Tier Diagram

Evolution of N-Tier Applications

























Evolution of N-Tier Applications


















Evolution of N-Tier Applications












Evolution of N-Tier Applications


Evolution of N-Tier Applications















Evolution of N-Tier Applications














Evolution of N-Tier Applications













Benefits of N-Tier Design
  • Improved Productivity via Reuse
  • Improved Productivity via Team Segmentation
  • Improved Maintainability
  • Looser Coupling
  •   More Physical Deployment Options

Drawbacks and Risks of N-Tier Design
  •   Reduced Performance, especially when physically separated
  •     More Complex Design
  •     More Complex Deployment

Thursday, January 23, 2014

How does MSMQ work?

ChannelFactory over Proxy class in WCF

When to use a proxy?

If you have a service that you know is going to be used by several applications or is generic enough to be used in several places, you’ll want to use the proxy classes.

When to use ChannelFactory?

ChannelFactory class is used to construct a channel between the client and the service without the need of a proxy. In some cases, you may have a service that is tightly bound to the client application. In such a case, you can reference the Interface DLL directly and use ChannelFactory to call your methods using that.

When to use a ChannelFactory over Proxy class

Use of DLL is helpful if the client code is under you control and
  • You’d like to share more than just the service contract with the client such as some utility methods associated with entities.
  • Make the client & the service code more tightly bounded.
  • If you know that your entities will not change much and the client code is less, then a DLL would work better than a proxy.
Proxies have several restrictions such as:
  • They need to have gets and sets
  • Contractors can’t be exposed
  • Methods other than the service contract cannot be exposed
  • Repetition of code
  • Every time that we add/modify a service contract/data contract/message contract we need to re-generate the proxy for the client.

So if you are designing a connected system and using WCF for that, then you can use a shared dll instead of a proxy.
Remember: sharing more than just the service contract with the client goes against the SOA fundamental – loose coupling between the consumers and services.