CodeSmith Community
Your Code. Your Way. Faster!

More interface implementation

Latest post 05-22-2008 7:55 PM by blake05. 4 replies.
  • 04-04-2008 8:23 AM

    • KVH
    • Not Ranked
    • Joined on 01-04-2008
    • Posts 5
    • Points 145

    More interface implementation

    Hi, we are building our SCSF/CAB Framework and will use .NetTiers as our datalayer!

    For testing the ‘presenter’ we need more interface implementation. With interfaces we can mock the behavior of the datalayer so that we can dedicate our tests to the ‘presenter’ only.

     

    We would like to change the service layer:

    public partial class OrdersService : Northwind.DataLayer.Services.OrdersServiceBase

    TO

    public partial class OrdersService : Northwind.DataLayer.Services.OrdersServiceBase, IOrderService

    AND

    public override Orders Save(Orders entity)

    TO

    public override Orders Save(IOrders entity)

    ... Update, Delete, Insert , ... 

     

    If we do that, we are sure that the IOrders interface needs more methodes than the current version.  Did anybody already worked on this?Some comments? We would like to integrate this changes (if possible) in the templates so that we still can take advantage of new .NetTiers versions, patches.

     

    Filed under:
    • Post Points: 35
  • 04-14-2008 5:29 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: More interface implementation

     Hi KVH,

    I think this would be a useful enhancement and I don't know of any existing work having been done on this.  

    Have you done any work on his yet? I'll be happy to add it to the repository as it is something I would like too.

    Regards

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 04-18-2008 4:57 AM In reply to

    • DST
    • Not Ranked
    • Joined on 04-15-2008
    • Posts 1
    • Points 65

    Re: More interface implementation

     

    Hi @swin,

     

    I am a colleague of @KHV and I have developed something in the direction described in his post above.

     

    Please, find attached inside Attachment.zip a modified template file “ComponentDataAccess.cst” and a modified generated source file “OrdersServiceBase.generated.cst”.

     

    In order to detect easily my modifications, search in the attached files the comment

    // PROTOTYPE CODE.

     

    Explanation (let’s take the example of Orders from Nothwind database):

    I have easily modified the existing template in order to send as parameter to the CRUD operations (Insert/Delete/Save/Update) the I<Entity> instead of <Entity> (IOrders instead of Orders).

    The problems started inside the generated code where I have obtained compilation errors

    in places where <Entity> (Orders) was explicitely required.

    For example, database operations require <Entity> argument, not I<Entity>: 

     

    public IOrders Save(IOrders entity) { .........       

           /* Persist Entity */        

          dataProvider.OrdersProvider.Save(transactionManager, entity); 

     

    There the “entity” variable (of type I<Entity> = IOrders) needed to be casted to <Entity> (Orders):      

          /* Persist Entity */

          dataProvider.OrdersProvider.Save(transactionManager, (Orders)entity); 

     

    Of course, casting to Orders solves only the compilation problems, but at runtime an exception may be thrown. 

    It means that, in order to produce consistent code, it is necessary to modify also the templates of the DataLayer and we go in a cascade of modifications.

     

    I have stopped myself at this point, because I realize that my modifications are bigger than expected.

     

    Please give me any advice if my direction of working is good or not.

     

     

    Filed under:
    • Post Points: 65
  • 04-18-2008 8:19 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: More interface implementation

     Hi,

    Thanks for this, however I'm a bit snowed under at the moment and won't be able to have a real look until sometime next week (hopefully). 

    Bear in mind that if breaking changes are likely to occur (which from you notes above looks like they will) it will be necessary for us to have a new generation option so that we can allow people the option of having the interfaces or not.

    Thanks

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 5
  • 05-22-2008 7:55 PM In reply to

    • blake05
    • Top 25 Contributor
    • Joined on 04-03-2008
    • Wisconsin
    • Posts 351
    • Points 6,205

    Re: More interface implementation

     Hello,

    Thank you for your contribution, we have added this to our to-do list. You can check the status of this here

    Thanks

    -Blake

    Blake Niemyjski

    CodeSmith Tools, LLC Support Specialist

    Blog: http://windowscoding.com/blogs/blake/

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems