partial classes in Inventory Demo

partial classes in Inventory Demo

Old forum URL: forums.lhotka.net/forums/t/7031.aspx


Jack posted on Monday, June 01, 2009

Rocky,

I noticed that in the InventoryDemo you are using .server and .client files in lieu of #if SILVERLIGHT etc.  Is that your recommended approach or just a preference?  I know there was an unresolved thread a while back that discussed it

Personally I'm finding the #if #endif really annoying and they don't work too well with ReSharper, my new best friend these days.

I'm starting to think that maybe the compile directives have a place in the codegen file to simplify that as a single file although maybe not.

Anybody else have an opinion on which method is easier to work with?  I also find it a pain to have to close the open file from my server project and re-open the linked version in order to check the compilation or fix certain compile time errors - although it is nice to have a single source file.

Jack

RockfordLhotka replied on Monday, June 01, 2009

I have done a lot of both compiler directives and partial classes. On the whole, I find that partial classes result in code that is easier to read and follow.

I fully appreciate the argument that partial classes result in a lot more files, but compiler directives result in very messy code (imo).

In the end, I think it is just a matter of coming up with standards for your project so you are consistent across the code base.

CampbellCM replied on Monday, June 01, 2009

I'm currently working on a CSLA Light project, several assemblies in fact. My situation is that I am the only person working on the SL side of things with several other developers working on the server side of things. Using partial classes has removed a lot of friction from the project in several ways. It is easier for multiple developers to work on the same classes if they are partials and the developers that are focusing on the server functionality don't even know that the SL code exists. To me its all about reducing friction and with a tight deadline on an LOB application the less friction the better.

That's my 2 cents.

RockfordLhotka replied on Tuesday, June 02, 2009

I should say that in the demos for the video series I'm using partial classes. I do discuss the use of compiler directives, but the partials make it so much easier and cleaner to talk about what's going on that I really do favor their use.

Copyright (c) Marimer LLC