Partial classes

Posted by Admin on 05-Aug-2008 05:03

The generated code gets rather cluthered with generated code from the designer.

The use of partial classes would hide the generated code from the code added by yourself.

Also the generated code invites the programmer to modify it, which should of course be left alone.

What do you think of this?

I suggested this a year ago at a presentation with the technology preview. Don't know if this has been noted.

All Replies

Posted by jankeir on 05-Aug-2008 05:22

The generated code gets rather cluthered with

generated code from the designer.

The use of partial classes would hide the generated

code from the code added by yourself.

Also the generated code invites the programmer to

modify it, which should of course be left alone.

You've got a point but:

- Seeing the generated code can be a good thing I think, it explains the developer how things work and you can learn a lot from it and notice problems faster. Sometimes you can notice a wrong setting in the code that would mean a lot of searching in the properties window.

- Hiding it would probably mean a fairly complicated change to the editor with fairly little real gain, there are many improvements possible for OEA that would have a much bigger impact than hiding this code. You're not supposed to edit this code, so just don't and there isn't a problem either.

If it wouldn't take much effort making the generated parts of the code read-only (like I believe Netbeans does) that would be nice, but I wouldn't be surprised if the small gain in user-friendliness would justify the complexity to implement that.

Posted by mbanks on 05-Aug-2008 09:32

John, your suggestion certainly has been considered, mostly as a way to simplify and speed up code generation from the designer. It's still something we're looking at.

mike.

Posted by Admin on 05-Aug-2008 09:44

OK, thanks for the update.

I've been working with VS2008 for some time now and like this feature very much.

Posted by Admin on 05-Aug-2008 13:40

John, I also believe that partial classes is a great feature to go with any generated code. So not only frontend related code.

For the time being, I help myself by doing my own version of partial classes using inheritance. A form of mine is called xyzFormDesigner.cls, the file I write custom methods and event handlers is called xyzForm.cls and inherits form xyzFormDesigner. I need to write event subscribtions manually, but I can live with that. I prefer the separation.

While doing this, I always keep an eye on C#s way of dealing with partial classes, because I hope that the feautre will be added later and I want to be able to migrate then.

Mike

This thread is closed