Daqing Chu At WordPress

August 29, 2011

Open/Closed Principle: Delegate Example

Filed under: Programming Notes — David Chu @ 4:16 am
Tags: ,

In object-oriented programming, the open/closed principle is a very important principle. Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. Recently I tried to summary some commonly used components in a serials of documents. I found that I have used delegate in my LogHelper class. This reminds me about my OCP.

[Read more…]

Advertisements

February 13, 2011

.Net Project to Copy Excel Data

Filed under: Programming Notes — David Chu @ 2:56 am
Tags: ,

In the past weeks, I have been working on a project to copy Excel data between worksheets. The source worksheet contains some formulas with links to other worksheets and add-ins. The problem is that the API functions defined in add-ins take long time to get data from a remote service. When there are hundreds and even thousands of rows in Excel, it will take to long time to refresh data. That’s the reason to have a scheduled job to copy the daily data from source excel file to another one with only values. Since the output put excel file contains only values, the show time is much responsive.

[Read more…]

October 17, 2010

.Net Debug Class (2)

Filed under: Programming Notes — David Chu @ 10:01 pm
Tags: ,

My debug class contains one base class. Let’s see the structure of the base class.

[Read more…]

October 11, 2010

.Net Debug Class (1)

Filed under: Programming Notes — David Chu @ 3:53 pm
Tags: ,

I wrote a blog on debug or logger class in Objective-C about couple months ago. Actually, that class was based on my prevous .net debug class. It has a feature to print debug information in a nice indention layout, which was extended to my Objective-C class. I think my .Net is very useful, at least for me, and it is more generic, with an additional feature to calculate a value between paired messages(indent and un-indent).

[Read more…]

April 10, 2010

MEF and IoC/DI (5)

Filed under: Programming Notes — David Chu @ 5:10 pm
Tags: ,

Let’s look my second API class – DICatalogBase.

DICatalogBase Class

The second class I use in my practice of DI library is the DICatalog class. The main purpose of this class is to provide APIs load DIs as parts to MEF and to pass information to customize Export instances. DICatalog is a customized API class for public usage. Therefore, it is an optional class if the customization is required.

Read the full blog ».

March 30, 2010

MEF and IoC/DI (4)

Filed under: Programming Notes — David Chu @ 3:33 am
Tags: ,

Let’s look my first API class – DIResolverBase.

DIResolverBase Class

First, I need to create a class or a library project to define DI mapping relationships which will be used in my application. For example, DIResolver class is a class where I define MEF Import and Export properties. When the class is loaded as an assembly catalog or directory catalog to MEF, the parts or Import and Export mapping relationships are then loaded to MEF framework.

Read the full blog ».

March 20, 2010

MEF and IoC/DI (3)

Filed under: Programming Notes — David Chu @ 8:18 pm
Tags: ,

Here is the way how MEF interacts with the class. When there is a request to get an instance of IProcessController from MEF, MEF will create an instance of DIResolver since MEF knows the Export is defined in this DIResolver class. At the time when the instance is created, the two Import properties are injected with instances of IDataReader and ILog. Finally, the property getter marked as the Export type of IProcessController type is called with the result instance from MEF and then to the request.

Read the full bog ».

March 14, 2010

MEF and IoC/DI (2)

Filed under: Programming Notes — David Chu @ 6:42 pm
Tags: ,

Let’s explore how to use MEF as a DI framework.

Read the full blog ».

March 7, 2010

MEF and IoC/DI (1)

Filed under: Programming Notes — David Chu @ 12:40 am
Tags: ,

Inverse of Control (IoC) and Dependency Injection (DI) are widely used patterns in software development. Here I call DI in short for IoC/DI afterwards. I have used StructureMap in .Net as a framework to inject instances to my application, a nice way to decouple interfaces and implementations(see my previous blog posts). MEF(Managed Extensibility Framework) is another very hot topic in .Net recently. Now it is a part of new libraries in .Net Framework 4.0, and it is also available for .Net Framework 3.5. Actually, MEF started as an Open Source project at CodePlex by a group of Microsoft developers. It is claimed with more features than DI.

Read the full blog ».

February 7, 2010

Retry Component

Filed under: Programming Notes — David Chu @ 5:12 am
Tags: ,

Last Friday, I finished a project of reading data from a service and saving the data to a network drive. The project is a console application based on a framework of DI. that is, dependency injection. The whole process is divided into several small tasks, and each task is corresponding to a component, or a library in .Net. Each one does one job and does it well. Together, the components are plugged in to a main controller, where a work flow of components is laid out in a logic as expected. In addition to this clear and well defined structure, there are many other advantages as well, for example, easy maintenance and reusability.

Read the full blog ».

Next Page »

Create a free website or blog at WordPress.com.