Re: Need some basic help with program
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 13 Oct 2007 02:16:43 GMT
On Mon, 08 Oct 2007 02:54:01 -0000, mara.aelene@xxxxxxxxx wrote,
quoted or indirectly quoted someone who said :
public static void main (String[] args)
this method goes on and on. Break it into much smaller pieces each in
its own method. It will make your code easier to understand and to
debug.
E.g. static int askOccupants()
You can then test each little method in isolation, feeding it dummy
inputs and printing its outputs.
Variables you need to access everywhere, you can make static variables
rather than locals in main with parameters.
Breaking the problem up lets you focus on just a tiny part of the
problem at a time, ignoring the rest. This helps avoid overwhelm.
Further when you have all the pieces, you have abstractions to think
with. The way they fit together will become obvious once you hide all
the details in method bodies. encapsulation clears the decks of
distracting detail.
see http://mindprod.com/jgloss/tackling.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.
- References:
- Need some basic help with program
- From: mara . aelene
- Need some basic help with program
- Prev by Date: Re: Need some basic help with program
- Next by Date: Re: Critical security updates for JVM
- Previous by thread: Re: Need some basic help with program
- Next by thread: Re: Need some basic help with program
- Index(es):
Relevant Pages
|