I am currently using IKVM to gain access to a large Java library within a C# .Net project. The libraries entry point is a singleton and from there I am able to create objects and set an objects properties.
I have currently created a C# Facade Pattern around this singleton and do my object creation and parameter passing via this Facade. The functions within the Facade are all static. Is it normal that a Facade Pattern only contain static functions or have I just created an extra layer with very little value?
The original Java code would look something like this:
Code code = Singleton.Instance.CreateCode();
code.SetExtension("12345");
code.SetId("1");
SubCode subCode = Singleton.Instance.CreateSubCode();
subCode.SetRoot("6789");
subCode.SetId("2");
code.SetSubCode(subCode);
A simplified (without error checking) C# version looks something like this:
public static FacadePattern
{
public static Code CreateCodeWithSubCode(string extension, string codeId, string root, string subCodeId)
{
Code code = Singleton.Instance.CreateCode();
code.SetExtension(extension);
code.SetId(codeId);
SubCode subCode = Singleton.Instance.CreateSubCode();
subCode.SetRoot(root);
subCode.SetId(subCodeId);
code.SetSubCode(subCode);
return code;
}
public static CreateCodeForHP(string extension, string codeId)
{
Code code = Singleton.Instance.CreateCode();
code.SetExtension(extension);
code.SetId(codeId);
code.SetUse(com.org.vocabulary.HP);
return code;
}
}