Application frameworks are not a recently emerged idea. Some of the old application frameworks that are still used today are the SmallTalk user interface framework, MacApp (for Macintosh), and Struts (for Web-based Java applications).
We can start with the interface to define a signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step1: Add namespace & References library | |
using System; | |
// Step2: Decalre a namespace | |
namespace FrameworkNamespace | |
{ | |
// Step3: Declare the Interface. | |
public interface Iframework | |
{ | |
// Step4: Declare functions needs to be in framework | |
// Usage: declare method <returntype> <methodname>(); | |
void method1 (); | |
int method2 (); | |
void method3 (); | |
} | |
} |
The Abstract calss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FrameworkNamespace | |
{ | |
// Step5: Declare Abstract class to Implement Interface | |
public abstract class Aframework :Iframework | |
{ | |
// Step6: Declare implemented functions as Abstract or define virtual method with body. | |
// Step7: Implement interface classes as Abstract class | |
public abstract void method1 (); | |
public abstract int method2 (); | |
// Step8: Virtual method Body Defined | |
public virtual void method3 () | |
{ | |
//TODO: Type virtual method body here.. | |
throw new NotImplementedException(); | |
} | |
} | |
} |
The sealed class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FrameworkNamespace | |
{ | |
// Step9: Declare Sealed class to prevent inheritance of class & virtual methods any further | |
// Step10: Inherit the Abstract class | |
public sealed class MyFramework :Aframework | |
{ | |
// Step11: Override the Abstract class | |
public override void method1 () | |
{ | |
//TODO: write your code here | |
throw new NotImplementedException(); | |
} | |
public override int method2 () | |
{ | |
//TODO: write your code here | |
throw new NotImplementedException(); | |
} | |
// Step12: Override the Virtual method if needed | |
public override void method3 () | |
{ | |
// Step13: Call the base class virtual method(if needed) | |
base.method3(); | |
//TODO: write your code here | |
throw new NotImplementedException(); | |
} | |
} | |
} |