Posts

Showing posts from December, 2013

Singleton Pattern:[Creational]

Image
The Singleton Pattern ensures the class has only one instance and provides a global point of access it. Only one instance of the object to be created and shared between the clients. In singleton constructor is private, so other classes cannot instantiate it. Here instances & methods are static, so we can access it in global point. Ex: public sealed class ClassicSingleton {     //single instance     private static ClassicSingleton instance;     private static object syncRoot = new Object();       //private constructor     private ClassicSingleton() { }       public static ClassicSingleton Instance     {         get         {             if (instance == null)            ...

Abstract Factory:[Creational]

Image
  Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Creates an instance of several families of classes. Abstract Factory will be useful while create a family of objects that having same type of implementations. Note: Abstract Factory can be used while create an instance from family of objects [having lot of similarities] without changing the rules like Carnivore eats Herbivore.

Adapter pattern:[Structural]

Image
A class that would be useful to your application does not implement the interface that requires. Does not support multiple inheritances. Match interfaces of different classes. It is also known as “ Wrapper ”. Adapter is a wrapper that helps one object integrates with any other object's interface. Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. Types: Class Adapter pattern Object Adapter pattern N OTE: Normally adapter pattern used in DataAccess layer to adapt the ADO.Net adapter classes like SQLAdapter.

Design Pattern

1. Design patterns are commonly defined as time-tested solutions to recurring design problems. It is a description or template for how to solve a problem that can be used in many different situations. It typically shows relationships and interactions between classes or objects without specifying the final application classes or objects that are involved. 2. Design patterns are not just about the design of objects but about the interaction between objects. Patterns are not concerned with algorithms or specific implementations. Originated by civil architect “Christopher Alexander” in 1977. Kent Beck and Ward Cunningham implemented in 1987. Gang of Four in 1994: Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. Advantages: Gives our profession in a shared language. Helps avoid re-inventing constantly. Provides a starting point for solution. Can speed production in a team. Generally improves system and application design. Gang of Four categorized in thr...

Development Principles (Software development methodology)

YAGNI (You aren't gonna need it)   do the simplest thing that could possibly work   KISS (Keep it simple, stupid) Simplicity is the ultimate sophistication   DRY (Don't repeat yourself) SOLID Principles:   Introduced by Robert C. Martin in the early 2000s. Helps to create a system that is easy to maintain and extend over time. It is typically used with test-driven development, and is part of an overall strategy of  agile  and  adaptive programming. S ingle responsibility principle: the notion that an object should have only a single responsibility. O pen/closed principle: the notion that “software entities … should be open for extension, but closed for modification”. L iskov substitution principle: the notion that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. I nterface segregation principle: the not...

.Net Collections

The  System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries. Array list: Implements the IList interface using an array whose size is dynamically increased as required. Dictionary Base: Provides the abstract (MustInherit in Visual Basic) base class for a strongly typed collection of key-and-value pairs. Dictionary is a Generic type. So we can get type safety with Dictionary. Hash table: Represents a collection of key-and-value pairs that are organized based on the hash code of the key. A key cannot be a null reference (Nothing in Visual Basic), but a value can be. Hashtable is not a Generic type. So we can’t get type safety with Hashtable. Hashtable is thread safe. Queue: Represents a first-in, first-out collection of objects. Queues are useful for storing messages in the order they were received for sequential processing. Stack: ...

Angular JS – Part 4

Services: Syntax: module.service( 'serviceName', function ); Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words new FunctionYouPassedToService(). Factories: Syntax: module.factory( 'factoryName', function ); Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory. Providers: Syntax: module.provider( 'providerName', function ); Result: When declaring providerName as an injectable argument you will be provided with new ProviderFunction().$get(). The constructor function is instantiated before the $get method is called - ProviderFunction is the function reference passed to module.provider.

Angular JS – Part 3 - Unit tests

Unit tests in Angular using Jasmin How to pass the mock dependencies to Angular Tests Karma Server is used to run Node Test files End to End tests. Browser() function is the special function used in end to end tests To troubleshoot e2e test, use pause() function. It will pause the action on browser.

Angular JS – Part 2

Angular Routing Services and Directives: Routing Services: $route - $routeProvider is used to map the URL with template + assigned controller. (specially for SPAs). Methods: when(), otherwise(redirectTo:), current, params, pathParams, reload(). Also we can use resolve() to decide before load template. $routeParams – Used to pass the parameters via URL $location –Use to enable html5 routing. Can get the URL informations Eg. absUrl, protocol, port, host, path, search, hash, url. Replace() method will not keep URL history. Directives: Uses of Directives: Create custom element, custom event, observe and react to changes Use eventApp.dirctive("directiveName",function(){ return {restrict: 'E', template: "<input>"}}); Can restrict the directive to how should use. E(element), C(class), A(attribute), M(comment). Instead of template HTML text, the URL can be used. Use" replace: true" to replace the element name to html i...