CodeSmith Community
Your Code. Your Way. Faster!

When to create dependent objects?

Latest post 02-03-2008 6:52 PM by SuperJeffe. 1 replies.
  • 02-02-2008 6:07 AM

    • shovavnik
    • Not Ranked
    • Joined on 08-19-2007
    • Posts 8
    • Points 190

    When to create dependent objects?

    I'm very new to netTiers. I've used some similar frameworks before, but none have been quite as comprehensive. Looks like I'll be sticking around.

    I'm having trouble figuring out when to create dependent objects.

    First of all, should I do it in the service or in the object itself?

    If in the object, then how do I "catch" the various CRUD operations? The object does not have overridable Insert, Update, etc. methods.

    If in the service, then how do I develop unit tests for it? The unit tests generated by the templates all work on the DataRepository directly, and therefore bypass the service methods.

    Here's a simple example of what I'm trying to accomplish. I have two tables: Role and Alias. The Role table has an AliasId column with a foreign key contraint. The alias is transparent to the end-user and is modified only behind-the-scenes, as it were. The Name field of the Alias always matches the Name field of the Role. So when a Role object is created, the RoleService (or whatever) should create the matching Alias object and record. Similarly, when a role is renamed, the associated Alias has to be renamed as well.

    So what's the "right way" to do it?

    Thanks for any help!

    Filed under: ,
    • Post Points: 35
  • 02-03-2008 6:52 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 342
    • Points 8,610

    Re: When to create dependent objects?

    Well, in the ServiceLayer, you can override the Inser, Update, Delete, Save, etc.  There should be a CustomerService class that inherits from the generated file (for a table named Customer).  Here you should be able to do what you want as far as adding dependant object programatically.  This would be my suggestion if your using the ServiceLayer as your business layer.

    As far as unit tests go, you would probably have to write your own that runs the particular methods in the ServiceLayer.

    Jeff

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

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