Sign in to follow this  
sanch3x

[.net] C# partial classes

Recommended Posts

Hey guys, I'm building an parser in c# and I'm trying to follow some sort of work ethic. I'm using C# 2005 EE and I noticed that while building the form I had a "partial class". Seeing how I'm unfamiliar with c# I looked it up (I've only worked in java at school). Now, I never worked on GUI's before and I'm mostly asking for advice seeing how this could work either way. Once my GUI has been defined should I make another partial class for my parser or should I integrate it directly in my NewsletterForm class? Maybe the parser should be in a whole other namespace? Thanks for any advice! PS. Although I've taken OOP classes I've only worked in java and I'm not familiar with terms like namespace or partial class (I did look them up though! :P) edit: I seem to have figured it out. It would be unwise to put them together if I want to make the code reusable. If I was to get rid of the GUI I'd be getting rid of the functionality as well. However I still don't know if I should put it in the same namespace or not.

Share this post


Link to post
Share on other sites
C# namespace = Java package (roughly). They are mostly organizational tools. On small projects, they are all but meaningless. On large projects, they are a means of compartmentalizing your code. Namespaces also give greater context to the meaning of a class or function name (C++ supports namespaces that can hold functions without classes). For example, I could have three different classes called Transformer that do completely seperate things, and the namespace they belong to provides greater insight into what they do (Xml, VectorMath, Toys).

Java has no equivalent to partial classes. A partial class is one class that is defined in multiple, seperate files.

Your parser should be implemented as a completely seperate class from your GUI. A well-designed GUI should only be an interface to some kind of background business logic. That way you can reuse the same worker classes with different types of GUIs (desktop app, web form, console app, etc).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this