Came to know that there is an interesting languege enhancement in .NET 2.0 for both VB and C#:
Partial Class. The definition of it is that your class definition can be split into multiple physical files. But to the compiler, it simply groups all the various partial classes into single entity.
The syntax is something like below:
In VB: (One of the classes need not have the "Partial" keyword)
' Class1.vb
Partial Public Class Class1
...
End Class
' Class1_1.vb
Partial Public Class Class1
...
End ClassIn C#: ("partial" keyword must appear in all class definitions)
// Class1.cs
public partial class Class1 {
...
}According to
MSDN, there're many benefits using Partial Class such as it allows programmers on your team to work on different parts of a class without needing to share the same physical file and separates your application business logic from the designer-generated code.
In Java, we can't see something similar to it, every single class definition must reside in one physical source file. But people do practise business logic separation by using design patterns like Strategy pattern. If we want to separate UI code from business logic, normally what we do is creating two classes for handling them, for example, HelloFrame class and Hello class.
I wonder if we can fully utilize Partial Class without having problem on the issues like code readability, member variables conflicts, code duplication and so forth. I'm not sure about those as I'm still figuring it out, but it's literally a "new" concept to me. As a class implementor, that should be better if we can have the full snapshot of the entire class.