Design question

T

TS

I am developing an Java client application.
It will have a main menu screen from which you click a button (one of 4) to
open a data entry or maintenance screen.
Is it best to have all the code in one .java file or is it better to have
each screen in it's own .java file.

TS
 
V

VisionSet

TS said:
I am developing an Java client application.
It will have a main menu screen from which you click a button (one of 4) to
open a data entry or maintenance screen.
Is it best to have all the code in one .java file or is it better to have
each screen in it's own .java file.

Java is an OO language, a Screen is not really a concept that it is relevent
to model. Instead think of the GUI building blocks like a JPanel in Swing
that may be used as the UI interface. In those terms then yes each 'screen'
is best modelled as separate classes.
If you are talking about the data itself, ie the model or business tier,
then that can only be answered by analysis of the usecases that describe
your scenario.
 
C

Chris Smith

TS said:
I am developing an Java client application.
It will have a main menu screen from which you click a button (one of 4) to
open a data entry or maintenance screen.
Is it best to have all the code in one .java file or is it better to have
each screen in it's own .java file.

None of the above. Each top-level class should have its own Java source
file. In any non-trivial application, that will probably mean you'll
have dozens of source files. You'll probably end up with one class (and
therefore one source file) to contain the code for building and managing
each of these "screens", but you'll want to use classes to model non-GUI
parts of your application as well. You can (and should) use action
classes to encapsulate the various actions a user can perform with your
application. You can (and should) write one class just to contain a
main() method and get the application started.

HTH,

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

Roedy Green

Is it best to have all the code in one .java file or is it better to have
each screen in it's own .java file.

the second. Things have a tendency to grow, so you should tend to
split them up and plant them in their own pots when they are young
before they grow tangled together.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top