Re: Need some basic help with program



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
.



Relevant Pages

  • Re: Static variables - saving state!
    ... I think that static variables in ASP.NET will have application scope and ... > public static string firstName; ... > public string LastName; ... > my data classes use static method to access/modify data) .. ...
    (microsoft.public.dotnet.general)
  • Re: mess CString content in pWnd->postmessage method
    ... So avoid static variables. ... >If you are certain your worker thread will continue to exist, ... Although I checked the sender end, it sent out the correct string. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: Variable must be in a Module??
    ... static variables. ... > Module Test ... > Public A As String ... You'll find when you look around the Framework, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Static is REALLY Static!
    ... for some reason static variables in asp.net have application-wide scope. ... Function GetPerms() as string ... Static myperms as string ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [PATCH REPOST] printk: fix possible printk buffer overrun introduced with recursion check
    ... asmlinkage int vprintk(const char *fmt, va_list args) ... it's easy to miss a static variable inside a function local variables ...
    (Linux-Kernel)