one-click, partial classes;

Posts   
 
    
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 25-Feb-2005 06:37:46   

I was wondering if the one-click regeneration ever got there simple_smile as I have been too busy to check in as often as I'd like.

Also, did you see the article in the last Code Magazine issue by Dino Esposito, mentioning the value of partial classes for data access layers for extending the generated code versus using inheritance. What do you think of the idea?

Thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39801
Joined: 17-Aug-2003
# Posted on: 25-Feb-2005 09:53:06   

tvoss wrote:

I was wondering if the one-click regeneration ever got there simple_smile as I have been too busy to check in as often as I'd like.

simple_smile Well, the unattended refresh is in, (will come in the upgrade going beta next week), re-generating code is still F7 -> enter, or use the command line generator.

Also, did you see the article in the last Code Magazine issue by Dino Esposito, mentioning the value of partial classes for data access layers for extending the generated code versus using inheritance. What do you think of the idea?

I haven't read the article, as I don't have the magazine, but knowing Esposito I think I know what he said wink .

Partial classes are great for code generators, and when they arrive I'll definitely use them. It indeed solves the problem of needing to create a derived class for adding behavior, when deriving the class also gives problems in the related entity department: Order has a reference of type 'Customer'. If I derive a class MyCustomer from Customer, I also have to change Order, as it initially holds a reference to Customer, not MyCustomer.

Partial classes aren't the solution for everything though: you don't have partial methods. This means that if I generate an initialization routine for an entity, and you want to set a ConcurrencyPredicateFactory instance in there, you still have to alter the generated code in some way, as the initialization routine is not adjustable using a method in another part of the class.

Coming with the upgrade I've created a feature called User Code Regions. In the template, there are regions marked which are emitted with markers into the generated code. The user can then add code between these markers in the generated code and this code is preserved between code generation cycles. I'll continue using that in .NET 2.0 to also give users the oppertunity to alter initialization routines for example, or adding extra interfaces to the class header, to name a few places where this can be helpful simple_smile

Frans Bouma | Lead developer LLBLGen Pro
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 25-Feb-2005 19:54:19   

Interesting, thanks.

In the future, do you think Partial Methods are a feasible addition?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39801
Joined: 17-Aug-2003
# Posted on: 25-Feb-2005 20:25:27   

tvoss wrote:

Interesting, thanks.

In the future, do you think Partial Methods are a feasible addition?

In .NET? I don't think they'll ever do that simple_smile . The main issue is maintenance: say you have a class which is spread over 4 files. Looking at method Foo in file 1, you see the method, but do you really know that's all the code? If there is something like partial methods, it will be a mess, because you can add file 5 with another snippet of Foo and everything crashes simple_smile

Frans Bouma | Lead developer LLBLGen Pro
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 25-Feb-2005 20:46:47   

Makes sense, but if they put Partial on all pieces and made it so you could see how many pieces exist with one click or hover it wouldn't be too bad.

I want to give you a bad time here regarding auto-regeneration wink

On page 31 of Code Generation in Microsoft .NET, by Kathleen Dollard, regarding: Understanding the Five Principles for Code Generation:

Principle#3: You, or someone unfamiliar with project, can regenerate your code precisely as a one-click process--now or at any point in the future.

You meet all the other principles perfectly simple_smile

I know this is probably not your priority with all that is going on, but it would really be major improvement for us smaller project users.

Thanks for your time.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39801
Joined: 17-Aug-2003
# Posted on: 26-Feb-2005 12:31:34   

tvoss wrote:

Makes sense, but if they put Partial on all pieces and made it so you could see how many pieces exist with one click or hover it wouldn't be too bad. I want to give you a bad time here regarding auto-regeneration wink

hehe simple_smile

On page 31 of Code Generation in Microsoft .NET, by Kathleen Dollard, regarding: Understanding the Five Principles for Code Generation:

Principle#3: You, or someone unfamiliar with project, can regenerate your code precisely as a one-click process--now or at any point in the future.

You meet all the other principles perfectly simple_smile

I do? simple_smile I thought I missed on preservation of own code added to the generated code (with the regions I think I solve that)

The one-click process is indeed hardly doable I think, although I get very far: if you define the generator config in the preferences, you can just press F7 and hit enter.

I avoided a 'regenerate' button because with generator configs which required a different config the second time you generate code (to preserve added code), you don't want to have the original config being chosen the second time simple_smile

Frans Bouma | Lead developer LLBLGen Pro