Why Microsoft has partial classes and Java does not?

In this article we have explained Why Microsoft has partial classes and Java does not have it and how new
era of RAD (Rapid application development) and visual programming started.

The secret success(it’s not a secret anymore)of Microsoft was GUI (Graphical User interfaces).

In case you are an old guy like me you would remember until 80’s the operating system were DOS based, with those black windows and cruel commands like dir, edit, mkdir etc.

Suddenly when Microsoft launched windows 3.X the whole world went crazy. Simple User Interfaces, no need to remember those DOS commands and windows became THE NUMBER ONE OPERATING SYSTEM in every end user desktop.

So Microsoft tasted its first success by the magic word GUI(Graphical User Interface).

They wanted to take the same success story to PROGRAMMING and Visual studio was born. A new era of RAD ( Rapid application development ) and visual programming started.

In order to enforce the GUI magic Microsoft introduced Visual Studio where developers get User Interfaces like grids, buttons, combo boxes etc. They can drag and drop these UI elements and create user interfaces quickly. Developers also had the luxury to write code easily when these User Interfaces where clicked.

“Behind every successful RAD there is code behind”.

Now there are two kinds of code in RAD tools:-

  • One is which is auto-generated by the tool where developers drag and drop UI elements like button, text boxes. These kinds of codes are marked with standard Microsoft comments like something below. They expect developers to not touch it as it would lead undesirable effects.
//---------------------------------------------------------------------------
// <auto-generated>
//   This code was generated from a template.
//
//   Manual changes to this file may cause unexpected behavior in your application.
//   Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;
  • Second is the custom code which developers need to write to fulfill business functionality. This code is not auto-generated and very custom code which developers write for specific needs.

Now the biggest challenge for Microsoft was how to keep custom and auto-generated code separate. Because if they are kept in single file there are high chances that the code which is auto-generated can overwrite the custom code written by developer leading to havoc.

The answer was “Partial classes”. The concept of partial class is your class can stay in to two separate physical files but when they compile they compile in to one DLL unit.

So now you have one physical file where you have the VS generated code and in the other physical file the developer can contain custom coding and after compiling both these files merge in to one DLL.

While when we look at java they do not have such kind of RAD approach. So there is no partial classes, no code behind etc. With full respect I personally love the idea of partial classes when it comes to RAD and Visual programming.

Some months back I just wrote a consolidated article where partial classes are useful ,4 real time use of C# partial classes.

Also below is a simple C# partial classes video created by www.questpond.com team. It talks about the importance of partial classes and partial methods.

Comments

comments

Leave a Reply