Class - one at a time or many

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have several classes. Should I keep them as separate class files or can I
keep them all in a single file?

Thanks

Regards
 
Hello,

John said:
I have several classes. Should I keep them as separate class
files or can I keep them all in a single file?

Every class should be kept in a separate file (except nested classes).
 
Whatfor can you put many classes in one file at a time? I thought it was
just help for the programmer, so that he can organize his classes better.
But as it sounds there is another reason for that. What is the reason?
I usually create a new file for each class.

Thanx for help,

BigMomma
 
John said:
I have several classes. Should I keep them as separate class files or
can I keep them all in a single file?

I prefer separate files, but it's also possible to keep some in the same
file.
 
As others have said, it really boils down to a matter of choice, however it
could be helpful to group classes together by topic. e.g.:
Classes relating to forms in one file
Classes releating to ADO.Net in another file
etc.
 
Hello,

Stephany Young said:
As others have said, it really boils down to a matter of choice,
however it could be helpful to group classes together by
topic. e.g.:
Classes relating to forms in one file
Classes releating to ADO.Net in another file

In VS.NET, you can group the classes in folders. There is IMHO no need
to put more than one class (except nested classes) into a single file.
 
Yes, however the point is that if one want's to then one can - It is a
matter of choice.
 
Hello,

Stephany Young said:
Yes, however the point is that if one want's to then one
can - It is a matter of choice.

You are right. Nevertheless, there are a lot of VB.NET programmers who
do not know that classes can be grouped in folders.

;-)
 
Stephany,
Yes, however the point is that if one want's to then one can - It is a
matter of choice.
Yes you have the choice of putting two forms in one file.

However! be warned if you make this choice, then you will no longer be able
to design the forms in VS.NET!

I do agree with you, one of the nice benefits of VB.NET over VB6 is that I
can put any number of types in a single source file! By type I mean Class,
Module, Structure, Delegate, or Enum. In fact I can put any number of
namespaces in a single source file. Lately I'm finding I limit one class,
module or structure to a source file, however I will group many Delegates &
Enums in a single source file. Either with the class or structure that they
are closely associated with or a common file, if they are related to a group
of classes, modules, or structures. Except for nested classes, which are
implementation details any way...

Hope this helps
Jay
 
Hi John,
Because everybody active in this newsgroup did give his opinion I add too
something.
I think that is a matter of:
- size of the project
- size of the class
- choise
Most of the way I see it is written at Stephanie and Fergus.
What I add is that I prefer classes that have the same meaning in one file.
100 class files with 6 lines makes a program in my opinion needless
difficult maintanable.

But it stays a matter of choise
Cor
 
Hello,

Jay B. Harlow said:
can put any number of types in a single source file! By type
I mean Class, Module, Structure, Delegate, or Enum. In
fact I can put any number of namespaces in a single source file.
Lately I'm finding I limit one class, module or structure to a
source file, however I will group many Delegates &
Enums in a single source file.

In VB Classic you can group many Enums and Types in one source file too.

;-)
 
Hi Herfried,

|| In VB Classic you can group many Enums
|| and Types in one source file too.

This is a VB.NET languages newsgroup. When making comments about VB
Classic and other VB languages. Please turn to...

SCNR ;-)

Regards,
Fergus
 
Hello,

Fergus Cooney said:
|| In VB Classic you can group many Enums
|| and Types in one source file too.

This is a VB.NET languages newsgroup. When making comments
about VB Classic and other VB languages. Please turn to...

SCNR ;-)

ROFL
 
Back
Top