One class per file

R

rolo

Hi

Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.

rolo
 
H

Hal Fulton

rolo said:
Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.

Matter of opinion. Personally I see no reason for a class-file
correspondence unless someone is in love with Java.

Hal
 
S

Stephan Kämper

Hi.
Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.

It depends how you organise your code, I'd guess.
If you develop several classes that somehow belong together (all are
data analisys related, web-oriented or whatever the 'theme' is), I'd
probably tend to put them into one file - or into one module in one
file. Which kind of leads back to the one class per file...

Stephan
 
R

Robert Klemme

Hal Fulton said:
Matter of opinion. Personally I see no reason for a class-file
correspondence unless someone is in love with Java.

Even in that case there's no need for 1 class per file... ;-)

robert
 
M

Mark Hubbart

Hi

Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.

For me, it has little to do with classes. I just group related code,
and split it up when/if the file gets too big. I rarely put two things
in one file though, if they are not closely related; ie, subclasses,
dependencies, etc.

cheers,
--Mark
 
J

Jim Freeze

We base this decision on reuse. Classes are essentially libraries
(or software IP if you will) that can be reused. The 'how many
classes to put in a file' question is answsered by the 'what block
of functionality can be reused independently by the others' question.
 
E

Edgardo Hames

rolo said:
Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.

Of course! It's faster to recompile... oh, nevermind.

Ed
 
D

Dmitry V. Sabanin

Hi

Do you not think that one class per file has lot of advantage is
distribution of classes to be used by other programmers.
IMHO, i think that file-oriented development gives you a freedom
of choosing your program structure. You can choose whatever the
style you want, of course you can choose class per file structure.
But for me, classes related to each over should be in their own file,
that's my rule.
 
S

Sascha Doerdelmann

Jim Freeze said:
We base this decision on reuse.

My favourite answer.

I find myself making new files whenever I notice pieces of code I'd
like to use in different applications.

But what's the best way to organize those files? Groups of files
naturally belong to directories. Using a single folder per application
works fine if I don't reuse files. One day I will come to the point
where I have to maintain reusable files in different directories. The
next step will be that wo different applications need different
versions of the files and as far as I can see neither cvs nor
subversion help me with this kind of problem.

I am sure that the Ruby community will find appropriate anwers to
different kind of code reuse problems. As I am coding VisualWorks
Smalltalk most of the time, I like the idea of managing code rather
than files. The current Ruby way has the advantage that there is no
special build procedure and you can distribute applications by just
distributing their sources.

Cheers
Sascha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top