Click here to Skip to main content
14,265,558 members

Why Microsoft has partial classes and Java does not?

Rate this:
3.50 (27 votes)
Please Sign up or sign in to vote.
3.50 (27 votes)
18 Sep 2014CPOL
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 80s 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 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 to 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 a 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 into two separate physical files but when they compile, they compile into 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 into one DLL.

When we look at Java, they do not have such kind of RAD approach. So there are 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 ago, 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 team. It talks about the importance of partial classes and partial methods.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Marla Sukesh
Instructor / Trainer Train IT
India India
Learning is fun but teaching is awesome.

Code re-usability is my passion ,Teaching and learning is my hobby, Becoming an successful entrepreneur is my goal.

By profession I am a Corporate Trainer.
I do trainings on WCF, MVC, Business Intelligence, Design Patterns, HTML 5, jQuery, JSON and many more Microsoft and non-Micrsoft technologiees.

Find my profile here

My sites


Comments and Discussions

GeneralMy vote of 5 Pin
xszhu20-Sep-17 14:47
memberxszhu20-Sep-17 14:47 
GeneralMy vote of 5 Pin
User97022-Jan-15 0:20
memberUser97022-Jan-15 0:20 
GeneralMy vote of 1 Pin
TSchind29-Sep-14 22:04
memberTSchind29-Sep-14 22:04 
GeneralMy vote of 1 Pin
Howard Richards22-Sep-14 2:52
memberHoward Richards22-Sep-14 2:52 
GeneralMy vote of 1 Pin
Richard MacCutchan22-Sep-14 0:16
protectorRichard MacCutchan22-Sep-14 0:16 
News[My vote of 1] Too much M$ PR campaigning Pin
Chad3F20-Sep-14 20:15
memberChad3F20-Sep-14 20:15 
GeneralMy vote of 2 Pin
vytheese19-Sep-14 5:42
professionalvytheese19-Sep-14 5:42 
QuestionDelphi Pin
Black68cougar19-Sep-14 4:40
memberBlack68cougar19-Sep-14 4:40 
GeneralMy vote of 2 Pin
Nikhil Shekhar19-Sep-14 4:25
memberNikhil Shekhar19-Sep-14 4:25 
GeneralMy vote of 1 Pin
Emile van Gerwen18-Sep-14 22:20
memberEmile van Gerwen18-Sep-14 22:20 
QuestionShallow Pin
Member 1082963818-Sep-14 8:29
memberMember 1082963818-Sep-14 8:29 
GeneralMy vote of 2 Pin
tornbladswe18-Sep-14 2:35
membertornbladswe18-Sep-14 2:35 
QuestionSorry, not quite true Pin
Member 188040318-Sep-14 2:18
memberMember 188040318-Sep-14 2:18 
AnswerRe: Sorry, not quite true Pin
tornbladswe18-Sep-14 2:34
membertornbladswe18-Sep-14 2:34 
AnswerRe: Sorry, not quite true Pin
Shivprasad koirala18-Sep-14 14:11
memberShivprasad koirala18-Sep-14 14:11 
GeneralMy vote of 1 Pin
Member 188040318-Sep-14 2:16
memberMember 188040318-Sep-14 2:16 
GeneralRe: My vote of 1 Pin
Shivprasad koirala18-Sep-14 14:14
memberShivprasad koirala18-Sep-14 14:14 
GeneralMy vote of 3 Pin
Stanley Gillmer18-Sep-14 0:37
memberStanley Gillmer18-Sep-14 0:37 
QuestionIMO Pin
Dewey17-Sep-14 6:07
memberDewey17-Sep-14 6:07 
GeneralInteresting. Pin
ugo.marchesini17-Sep-14 4:47
professionalugo.marchesini17-Sep-14 4:47 
QuestionWhy Java does not have partial classes? Pin
Paulo Zemek17-Sep-14 3:51
professionalPaulo Zemek17-Sep-14 3:51 
AnswerRe: Why Java does not have partial classes? Pin
Dewey17-Sep-14 6:08
memberDewey17-Sep-14 6:08 
GeneralRe: Why Java does not have partial classes? Pin
Paulo Zemek17-Sep-14 6:12
professionalPaulo Zemek17-Sep-14 6:12 
GeneralRe: Why Java does not have partial classes? Pin
Dewey20-Sep-14 1:19
memberDewey20-Sep-14 1:19 
QuestionNot just UI Pin
Duncan Edwards Jones17-Sep-14 3:16
professionalDuncan Edwards Jones17-Sep-14 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Technical Blog
Posted 16 Sep 2014


13 bookmarked