The Power of Partial Classes
- Problem: You
want a shared component but there can be many different versions of it. You
don’t know what version to expect. You could always replace the latest
version of the shared component but then you’re constantly distributing this
ever growing component. Worse, if you a person has old versions of your
software installed, the new version of the shared component may break
something. You could end up with a huge shared component on a website
(eating up memory) when the website only needs a few of the methods.
- Solution:
Using partial classes your shared component is a single class in the
App_Code directory. You only add the methods that the software currently
being installed needs. If you feel you need to, you can have a code file for
each method.
- What this
gives you: You only have to
worry about breaking older software if you replace the particular code file.
The website only needs to load the components it is actually using.
-
You can start
the class, add more files, remove some of the files and the files that were
added are still there
-
This allows
us to make changes to the IWEB Core even though unknown people have been
making their won additions to the class. The only thing they cannot change
is the actual code file. If they have a method that conflicts they will know
immediate because it won’t compile
-
You can allow
for code files in multiple languages because one partial class can inherit
from another partial class in a different language. All methods from both
classes will be visible in the final superclass.
[Back to:
The ADefWebserver DotNetNuke HELP WebSite]