Library tutorials & articles
Building Application Framework with C#
- Introduction
- Application Framework using C#
- Implementing the Framework
Application Framework using C#
In the following article, you'll see how to implement a basic infrastructure for Application Framework Model. The fundamental concept in building application framework is the template method, which is hidden inside the application and controls the flow of the application. This method is characteristically implemented in the base class and cannot be changed.
The first step is to construct the base class for the framework. The base class is the most important class when building application framework. It consists of override able method, which the end user should override to provide customized application. Apart from these, there is also a template method that as mentioned controls the framework processing.
The framework that we are going to built consist of three abstract methods for the end user to implement. These are init, run and destroy which must be implemented in sequence.So the base class for that kind of framework can be implemented as following.
// The class is defined abstract because the customized methods
have no definitions
abstract class AppFramework
{
// the constructor which calls the template methods
public AppFramework()
{
templateMethod();
}
// the method required to be implemented by the end user
public abstract void init();
public abstract void run();
public abstract void destroy();
// the template method which is the heart of the framework
private void templateMethod()
{
Console.WriteLine("Initializing Template Engine");
// template method calling the necessary function in sequence
init();
run();
destroy();
Console.WriteLine("Ending Template Engine");
}
}
One thing that you should avoid is to make the template method virtual. Because it then gives the end user ability to override the template method hence changing the whole framework process flow.
Related articles
Related discussion
-
accessing media player's library?
by buvanasubi (1 replies)
-
String was not recognized as a valid DateTime.
by buvanasubi (22 replies)
-
copying access DB to SQL DB
by Lufuno (0 replies)
-
save .csv with newline character
by James Crowley (1 replies)
-
Loop help needed
by mandy130 (3 replies)
Related podcasts
-
Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner
One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
None serious actual framework uses inheritance or templating. Inversion of Control (aka Dependency Injection Pattern) is a much better design and seems to be the way most popular frameworks had taken.
Developing Java for a few years and understanding most of the concepts and theory of the language this tutorial gave me a better idea as to what to expect when making the jump to C#. Although not in-dept, intricate enough to get the 'just' of the language and framework building. EXCELLENT JOB!!!!!!!
The title gives an impression that we are going to delve deep into application frameworks...but the article is just basic, although its OK. Better change the title to avoid such comments.
Horrible!!
I thought this was an article about Frameworks??? Instead I get a brief on the basics of Inheritence. A Framework is a much larger issue, and cannot be covered in three HTML pages.
A very good article and written in a very good understandable form.
Frameworks are rightly easing the amount of effort required to put in to code development by developers.
Frameworks provide set of services , but dot NET goes beyond that by managing the code that uses those services. So, dotNET can be viewed as playing dual role (Provision of services and managment of code).
This thread is for discussions of Building Application Framework with C#.