Saturday, March 22, 2014

General - 2013

  • 3Tier vs 3 Layer:
    • Tier is physical separation of components and Layer is logical separation.
    • Application UI - First Tier, web services/ business logic - Sec Tier / Database - third tier.Three tiers are linear UI-BUS-DAL while MVC is triangular UI - controller and UI-Model and Controller- Model. Generally MVC is part of UI for larger systems.
  • Repository Pattern:Prepare business entities in DAL (Repository) so business layer is independent of any data related information and has to deal only with strong type entities.
  • Code Smell:In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and don't currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future
  • Anti Pattern:Very common practice which is being used to solve a  common problem but instead of solving it's causing more problems.  Such as: God Objects - Multi purpose object.
  • Anonymous Functions:
    • An anonymous function is an "inline" statement or expression that can be used wherever a delegate type is expected. You can use it to initialize a named delegate or pass it instead of a named delegate type as a method parameter 
  • A lambda expression is an anonymous function that you can use to create delegates or expression tree types. using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls.very helpful in writing LINQ queries.
    • (int x, string s) => s.Length > x () => SomeMethod()
    • if you are creating expression trees that will be consumed in another domain, such as SQL Server, you should not use method calls in lambda expressions. The methods will have no meaning outside the context of the .NET common language runtime.
                delegate void TestDelegate(string s); //1.0 syntax. - Named Method
               TestDelegate   testDelA = new TestDelegate(M);
               TestDelegate    testDelB = delegate(string s) { Console.WriteLine(s); };                              //Anonymous Method
               TestDelegate    testDelC = (x) => { Console.WriteLine(x); }; //Lambda                           expression

  • Expression Trees:
    • Expression trees represent code in a tree-like data structure, where each node is an expression, for example, a method call or a binary operation such as x < y.
    • Used for dynamic modification of executable code, the execution of LINQ queries in various databases, and the creation of dynamic queries
    • Expression trees are also used in the dynamic language runtime (DLR) to provide interoperability between dynamic languages and the .NET Framework and to enable compiler writers to emit expression trees instead of Microsoft intermediate language (MSIL).

Can be created by anonymous lambda expression, or manually by using the System.Linq.Expressions namespace.




No comments: