Howto :: Class implementation on several files...

  • Thread starter Thread starter Malkocoglu
  • Start date Start date
M

Malkocoglu

In the good old days , i had a class that had 30 functions (let's say)
There was a single include(*.H) file and i could have several
implementation(*.CPP) files
The reason for doing this is to have some functions grouped so it is easier
to read/manage them...
Maybe several developers work on the same class but on different parts of it
in parallel...

I have a C_foo class
foo.h // the header file that has the C_foo class...
foo_1.cpp // 1st part of the implementation of C_foo class
foo_2.cpp // 2nd part of the implementation of C_foo class
foo_3.cpp // 3rd part of the implementation of C_foo class

By this way developer_1 checks-out foo_1.cpp , works on it and then
checks-in , etc..
How can we do the very same thing under .net/C# language ???
Thanks in advance...
 
Malkocoglu,

You can not do this currently in C#. You must place the complete
implementation in a single class file.

Hope this helps.
 
Malkocoglu,

Unfortunately this isn't available at the moment, although it is planned for
the next version of .NET (think its going to be called partial types)

HTH

Kieran
 
As Nicholas said you can't currently split a class up over several files but
you can group parts of the class up by using the #region directive. With
regards to multiple developers working off of the same file you will
currently have to rely on mulitiple checkouts on the same file and then
merge the differences when you check in.

Regards
Lee
 
Malkocoglu,
Consider using Method Objects to move the implementation of the methods into
their own class.

http://www.refactoring.com/catalog/replaceMethodWithMethodObject.html

Each method (most methods) of the C_foo class becomes their own class, that
C_foo calls into to get the work done.

The problem with this approach is that these method object classes may need
'intimate' knowledge of the C_foo class.

I find method objects work better for Web Services & Remoting Servers,
making the Web Service or Remoting Server a facade.

Hope this helps
Jay
 
Back
Top