Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

What Not To Do

Thread view: 
Roedy Green - 03 Jan 2006 23:36 GMT
I decided to update a little program I wrote for my personal use.  It
was very much a one-shot, quick and dirty.

But in coming back to do a simple change -- move the data from
internal to the program to external CSV files, the work took a lot
longer than it should have.

If I had this to do over:

1. always document variables.  In particular I did not document
whether various arrays always had an entry for each day or just
selected days in a range.

2. When you have to do a theme and variations DON'T copy clone the
code and modify.  Encapsulate the common part.  Otherwise the common
part will gradually diverge over time and be harder and harder to
maintain.

3. keep asking yourself, is this piece of code even POTENTIALLY
reusable.  If so, bundle it up, and keep the application specific code
out of it.

4. get very clear on responsibility areas and the interfaces between
them so you know exactly where any given piece of code belongs.
It is not good enough to get the code in the stream somewhere. It must
go at the right responsibility point.

5. Rather than displaying error messages, throw an exception you catch
at a higher level and treat them in a consistent way.   Otherwise you
will find messages  being ignored or sent to a mixture of System.out
and System.err.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Alex Molochnikov - 04 Jan 2006 00:12 GMT
All these amounts to:

- observe the OOP methodology
- document your work by (at least) commenting your code
- create reusable components

And the following tidbit for completeness:

- don't drink and drive :-)

> I decided to update a little program I wrote for my personal use.  It
> was very much a one-shot, quick and dirty.
[quoted text clipped - 31 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 09 Jan 2006 20:32 GMT
> 5. Rather than displaying error messages, throw an exception you catch
> at a higher level and treat them in a consistent way.   Otherwise you
> will find messages  being ignored or sent to a mixture of System.out
> and System.err.

   If you're going to display error/warning/informational messages to the
console, use a logger instead. Sun provides one
(http://java.sun.com/j2se/1.5.0/docs/api/java/util/logging/Logger.html), and
there's a good one by Apache as well. The advantage of a logger is that you
can filter the messages based on their severity (info, warning, severe,
etc.) and based on where they are coming from (the GUI module, the DB
module, etc.) so can enable debugging messages during development, and
disable them in your release version.

   You can also control where the messages go to. You could have them
display on standard out, or standard err, or to an XML file, or an ASCII
file, or you could have them sent to a central database for intranet
applications, etc.

   - Oliver
Alex - 09 Jan 2006 20:50 GMT
Yeah! I have nothing to do too :(((
Alex.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.