How use a Foundational Module

Topics: Web Client Software Factory
Feb 13, 2009 at 10:13 PM
Hi,
 
I am new to this and I am not sure about things.

I used CodeSmith to gen a DAL:  (This code was generated by using The Kinetic Framework v3.0)
Results:
RigZone.Business
       Has the Entities that were generated.
RigZone.Business.Framework
       Has the DAL and supporting classses.

In my wcsf project I added a foundational module called Business and copied all the code that was generated:

So I now have a module called Business 
        with the Entities: 
        it also has the fhe Framework Folder (with the DAL classes) 
        and the Service Folder (Which has nothing at this time)

So my first question:  Should I implement a Service and IService for each entity? and register this so that I have access to the entities DAL? If not how would I refrence the entities and DAL from the Shell module. Say I want to use the default.apx page that has a GridView and load it with RigHistory data?

The entities have the fields and methods Insert, Update ...  So if this needs more edification, it might be helpful to see some of the code.
Feb 17, 2009 at 4:33 PM
Ok, Lets go at this from a different angle.

I have the Foundation Module, but the code generated is partly static and instance.

So if I expose a Service and interface, I will then expose a create method and the crud methods.

So how does this free me from having a reference to the entity returned from the Create Method? Or do I use reflections so that I am loosley coupled?

Thanks

Mike
Feb 17, 2009 at 5:38 PM
Let me take a shot at sharing my understanding, even though the other folks may be able to provide better guidance.

First, could you confirm that the following illustrates your concern:

Your DAL and business entities generated code has something like this

//pseudo code
public class Person
{
    private Guisd _id;
    private string _name;
    private int _age;
    public Person(string guid)
    {
        DataTable p = FetchPerson(guid)
        _id = guid;
        _name = p["name"];
        _age = p["age"];
    }

    public void Save()
    {
        _id = PersonDataAdapter.UpdateOrInsert(_name, _age);
}
public class CustomerDataAdapter
{
    public static DataTable FetchPerson(string guid)
    {
        //db acess SELECT * FROM tblPerson WHERE [id] = @guid
    }
    public static Guid UpdateOrInsert(string name, int age)
    {
        //db access code
    }
}

Let's say your Foundational Module exposes a "service" method

public Person GetPerson(string guid)
{
    return new Person(guid);
}

and you're concerned that your Foundational module will have to return a concrete instance of the Person class, thus your UI needs a reference you your Foundational Module?
Feb 23, 2009 at 7:41 AM
I don't konw what's the purpose for Foundational module and what should we put?
Feb 23, 2009 at 2:28 PM

Hi,

I think a possible solution could be creating a Class Library where you define all the Business Entities (adding here the Person class for example), this could be a shared layer for all your modules (like a vertical layer), and doesn’t need to be a module.

Then you can create a Foundation Module hosting all the DAL classes as services, so then, you can inject them in your presenters or consume them through an intermediate business layer.

 

Zhihao: Perhaps, you can find useful the How to: Create a Foundational Module article in the documentation that explains the Foundational Modules’ purpose:

“[…] Foundational modules are units of development and deployment that encapsulate infrastructure services. They do not contain Web pages nor do they have a module composition container. An example of a foundational module could be a module that contains services, such as logging and authorization services. […]”.

 

Please, let me know if this helps.

 

Ezequiel Sculli

http://blogs.southworks.net/esculli/