I am currently using IKVM to access a large Java library in a C # .Net project. The entry point to the library is singleton, and from there I can create objects and set properties of objects.
Currently, I have created a C # facade template around this singleton and am creating an object and passing parameters through this Facade. The functions in Facade are all static. Is it normal that the facade template contains only static functions, or did I just create an extra layer with a very small value?
The original Java code looks 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) version of C # 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; } }
source share