In the local .NET UserGroup the founder of AgileMovement.it asked what’s the general opinion about .NET2.0 partial types, so I’ve posted mine, but since the post is in italian I’m going to translate it in english for my blog:
IMHO partial classes have to be taken with the dropper (and with the magnifying glass too…). I’m not agree when they are defined a “revolution” because in my opinion are a “workaround” to the problems of code generators (or useful in those contexts). Let’s the scenarios:
- cvs: nowadays there are problems to handle cvs with a team who work on the same class, problems that IMHO wouldn’t be solved with partial types because if (as the good Murphy teachs us) something could go wrong, it will with partial types too, I explain myself: suppose that John and I are working on the same class (I keep on asking myself why someone else and I should work on the same class but ignore it and go on…); if something goes working the integrity of a single file is underminded, that thing doubles (or worse) with partial types. After all it’s not a big problem…
- inheritance and OOP: maybe I’m a traditionalist but I don’t see how partial types could fit (here in the italian version there’s a pun but it’s impossible to translate it) in the OOP architecture… inheritance? No because I don’t inherit, code reuse? No because there’s no need to play Lego with a software… admit that I’ve mis-intepreted the big plan behind partial types and that they are a revolution… revolution of what? To avoid using Façade? Mmm IMHO the problem has to be resolved at the root (that’s what I meant with “workaround” at the beginning of the post)
- code generators: likely the only purpose of this “revolution”, maybe tools like LLBGen, datalayers generators or something else could benefit
- VS.NET, WindowsForms and other stuff: in my opinion with this point of view are more than an error because they step over things like MVC and so on; I didn’t see how VS generates the code with partial types but I have the idea that we could end with “meltin pot” partial types to throw in all the source code that a developer should not see. Much better approaches like XUL, Glade, XAML (if my mind don’t play tricks on me they use partial types under the hood, but they don’t expose them to classes users) and so on.
So… partial types? Yes but the lesser the better. I’m in favour for XAML and for code generators, a little less for Windows Forms and to the direct exposure to programmers.
Bye

