Skip to main content

Posts

Showing posts from 2014

Adapter Pattern

An Adapter as the name says is used to provide a mechanism that adapts an existing interface to the required interface. This helps the types that are not designed to work together, work together. Adapter pattern may become handy when working with legacy system. Here adapter allows the use of interfaces that are incompatible with new interface requirement. For example, an object needs to compress a file. You find that there is another class that provide the compression service, but has a different method signature than the one required by the object. An adapter patter can come to rescue in such situations. We can create an adapter class that allows the existing service to be used through a new interface. There are two kinds of adapters: Class Adapter - This type of adapters adapters through sub-classing  Object Adapter - This type of adapter use delegation to adapt instead of subclassing Class Adapter  Let say you want to use this existing method zipFile() i...

Facade Pattern

A facade is "the front of a building OR any side of a building facing a public way or space and finished accordingly." ( Dictionary.com , 2014). A facade pattern hides all the complexities behind a simple easy to use interface. It provides a simplified access to subsystem. Related pattern: Trusted Facade Pattern Bibliography Bishop, J. (2016, 12 30). Structural Patterns: Adapter and Façade . Retrieved from MSDN: https://msdn.microsoft.com/en-us/library/orm-9780596527730-01-04.aspx MSDN. (2016, 12 30). The Trusted Façade Pattern . Retrieved from MSDN: https://msdn.microsoft.com/en-us/library/ff649496.aspx MSDN. (2016, 12 30). Trusted Facade Service . Retrieved from MSDN: https://msdn.microsoft.com/en-us/library/aa355058(v=vs.110).aspx

ASP.NET Web Apps

ASP.NET web applications ASP.NET is used to create dynamic web sites. Web pages are said to be dynamic when the content displayed on the web page change based on the user profile, user input, time or any other factor. The web pages that does not changes are said to be static. In an ASP.NET web application, web pages served by the web server are generated by an application based on the user request. ASP.NET websites use client server technology like every other web sites. Where the browser is the client. When a user types a URL or clicks a link or a button in the web page, a request is sent to the web server. This request is then sent to application server that runs an appropriate program to create the web page requested by the user. This web page also may include data that is retrieved from a database server. Once the web page is created, this web page is sent to web server which sends it to the user's browser. The whole process is called a round trip. Listed below are 5 di...

Singleton Pattern

Singleton Pattern is used to control the instantiation of a class. A Singleton class can have only one instance and the class provides a global access point to that instance. The singleton class has the following responsibility: ensures that only one instance of the class is created. provides access to that instance of the object. ideally the singleton instance should be created only when it is needed. There are situation when we need a single unique instance of a class. To do this we can make the constructor of the class private so that only the class itself is capable of creating an instance of itself. We can hold the instance of the singleton class in a global variable and provide access to this instance through a global method. However, a global variable would exist for the duration of the program taking up resources. This could become a problem when the instance is resource-intensive. Therefore, you may want to create such an object only when it is needed. Si...

Design Patterns Intro.

What are Design Patterns? A Design Pattern is a recurring solution to a recurring problem in a specific context. Patterns are not a specific to Software engineering. They are applied in many disciplines including but not limited to Construction, Mechanical Engineering and psychology. The first book on patterns was written by Christopher Alexander in 1977 on building architecture. “A pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.” - Christopher Alexander Design Patterns is the first book on software design patterns written by Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) or GoF. This book describes 23 common design patterns (Gamma et al, 1995). All of these 23 design patterns are explained in your text book. Design patterns have 4 essential element...

Laws Laws Laws

Software Development Laws Conway's Law  - This law states that the organizational structure of the development team reflects in the code. Hierarchical organizational structure that are rigid can result in the poor architecture and code that would result in software that is too costly and hard to maintain. Humphrey's Law - This law states that the users do not know the requirement until they see the software. User says "I Know It When I See It" (IKIWISI). But the traditional developer says that "What You See Is What You Get" (WYSIWYG). Here lies the problem and in my opinion may possibly contributes to the Ziv's law. Ziv's Law  - This law states that software development is unpredictable.

Drawing network diagram in Excel

Drawing AON diagram in Excel Excel can be used to draw AON when you don't have a specialized software to draw your network diagram. First create a node template that can copied again and again. This can be created using cell formatting features such as borders and merge cells. Highlight any 3 by 3 cell group in the worksheet as shown below and then apply All Borders  cell formatting. Now select the three cells in the middle as shown below and select  Merge & Center.  You can now copy and paste this template, for each node you need in your network diagram as shown below. Then use arrow shape in Insert > Shapes > Lines to draw the arrows. 

WCF REST pt 4 Client

Open WCF service host project that you created OR create one based on instructions  here . Add a new project to the current solution: Right click Solution on Solution Explorer > Add > Add New Project Select Console Application template under Visual C# > Windows templates Change the project name to ConsoleClient and click OK In Solution Explorer, under ConsoleClient project, right click References and select Add Reference...  Add reference to ProductServiceLibrary, System.ServiceModel and System.ServiceModel.Web In the Program.cs file,  add  using System.ServiceModel; ** add  using System.ServiceModel.Web; add  using ProductServiceLibrary; ** Add the following code       namespace ConsoleClient {     class Program     {         static void Main(string[] args)         {                      ...

WCF REST pt 3 site

Open WCF RESTful service host project that you created OR create one based on instructions here . Add a new website to the current solution: Right click Solution on Solution Explorer > Add > Add New Website Select WCF Service under Visual C# templates Change the folder name to ProductWCFService and click OK In Solution Explorer, right click on the ProductWCFService website and select Add  Reference...  Add reference to ProductServiceLibrary in solution In Solution Explorer, under ProductWCFService website, expand App_Code and delete two files IService.cs and Service.cs  Open App.config file, remove the code from  <System.ServiceModel> to </System.ServiceModel> inclusive.  In the service.svc file, add replace the code with the one given below:       <%@ ServiceHost Language="C#" Debug="true" Service="ProductServiceLibrary.ProductService"     Factory="System.ServiceModel.Activation.W...

WCF REST pt 2 Host

Open WCF RESTful service project that you created OR create one based on instructions  here . Add a new project to the current solution: Right click Solution on Solution Explorer > Add > Add New Project Select Console Application template under Visual C# > Windows templates Change the project name to ConsoleHost and click OK In Solution Explorer, under  ConsoleHost  project, right click  References  and select  Add Reference...   In the Reference Manager window, add reference to  System.ServiceModel ,  System.ServiceModel.Web , and  ProductServiceLibrary  solution Add  using  System.ServiceModel; Add  using  System.ServiceModel.Web; Add   using  ProductServiceLibrary; Add the following code in  Program.cs  file class Program     {         static void Main(string[] args)         {         ...

WCF REST pt 1 service

Create a RESTful WCF Service  1. Open Visual Studio, click File  >  New  >  Project   2. S elect  WCF Service Library  template under  Visual C# > WCF  templates 3. Change the name to StudentServiceLibrary  and click  OK 4. Visual studio will add reference to System.ServiceModel, System.Runtime.Serialization and will add some files with sample code.  5. Delete IService1.cs and Service1.cs 6. Add reference to System.ServiceModel.Web 7. Add a new class called StudentService Adding Data Contract  8. Open StudentService.cs file that you created and add the following code using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; 9. Add the following code in the StudentService.cs class namespace StudentServiceLibrary {     [ DataContract ] ...

WCF Service Client

Open WCF service host project that you created OR create one based on instructions here . Add a new project to the current solution: Right click Solution on Solution Explorer > Add > Add New Project Select Console Application template under Visual C# > Windows templates Change the project name to ConsoleClient and click OK In Solution Explorer, under ConsoleClient project, right click References and select Add Service Reference...  In the Add Service Reference dialog, click Discover button. This should bring you the Mex address of the service. If not, you may have to copy the endpoint address from the ConsoleHost's App.config file and click go.  Now you should see the ProductService in Services section. Change the default name in Namespace textbox to ProductReference and click OK.   Doing the above will update the references and also App.config file. In the Program.cs file, add using System.ServiceModel; and  using ConsoleClient.ProductReference;...