473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to separete a class in more than one source file

Is it possible to divide a class in many .cs files ? For example one source file for each method ?

Thanks.

Nov 22 '05 #1
9 1471
[Please fix your newsreader to wrap lines properly.]

=?Utf-8?B?SnVhcmV6?= <an*******@discussions.microsoft.com> wrote:
Is it possible to divide a class in many .cs files ?
For example one source file for each method ?


Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
[Please fix your newsreader to wrap lines properly.]

=?Utf-8?B?SnVhcmV6?= <an*******@discussions.microsoft.com> wrote:
Is it possible to divide a class in many .cs files ?
For example one source file for each method ?


Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #3
Juarez <an*******@discussions.microsoft.com> writes:
Is it possible to divide a class in many .cs files ? For example one
source file for each method ?


Now you can't, but when with the Whidbey release of the framework
we'll have partial types you'll be able to do that.

Bye

--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
Nov 22 '05 #4
Juarez <an*******@discussions.microsoft.com> writes:
Is it possible to divide a class in many .cs files ? For example one
source file for each method ?


Now you can't, but when with the Whidbey release of the framework
we'll have partial types you'll be able to do that.

Bye

--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
Nov 22 '05 #5
Juarez,
In addition to the others comments: when I need to do this, I consider using
the Replace Method with Method Object refactoring.

http://www.refactoring.com/catalog/r...hodObject.html

Granted you wind up with 2 classes...

Hope this helps
Jay

"Juarez" <an*******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Is it possible to divide a class in many .cs files ? For example one source file for each method ?
Thanks.

Nov 22 '05 #6
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.


Why did they need to implement that to do that? Couldnt they just build a
base class which the designer code goes in and then we as users work in the
descendant?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 22 '05 #7
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.


Why did they need to implement that to do that? Couldnt they just build a
base class which the designer code goes in and then we as users work in the
descendant?


That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #8
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.


Thats quite a fine line - but I dont see how splitting a class into two files
AND modifying the language to fix a "Tools problem" is better.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 22 '05 #9
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.


Thats quite a fine line - but I dont see how splitting a class into two files
AND modifying the language to fix a "Tools problem" is better.


It's better because instead of solving one specific problem, it solves
a range of problems - wherever there's autogenerated code, it's
appropriate. It also keeps the end class design the same, just giving
the option of a slightly less conventional implementation.

I agree it's a fairly fine line, but I know I'd hate to have to have
hierarchies which were too deep just for the sake of the designer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
7
by: Juarez | last post by:
Is it possible to divide a class in many .cs files ? For example one source file for each method ? Thanks.
4
by: mchoya | last post by:
I'm so frustrated. I'm beginning school next week and I have been working on a simple program for several days now without being able to complete it. (Though I have brushed up on a lot of C++...
2
by: Matt | last post by:
Hello, I would like to generate what I call an "overall class hierarchy" in UML automatically derived from my C++ code source. An example of what I seek: ...
7
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file...
10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
20
by: Scott M. | last post by:
What are the advantages of defining a class as part of another class definition (nesting classes)?
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.