aspose file tools*
The moose likes Beginning Java and the fly likes Review of Greenhorn Code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Review of Greenhorn Code?" Watch "Review of Greenhorn Code?" New topic
Author

Review of Greenhorn Code?

Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
I have just started programming, and I would very much like to have someone review my code so that I don't compound mistakes when I modify it. Essentially, I want to know if I am making any fundamental mistakes that could hurt me later when I try to make the code more sophisticated. Is there a forum or service available? Can it be done here?
BTW, the code I wrote is short and easy to understand. And it compiles and works with no errors. But naturally that doesn't mean errors, or substandard programming, don't exist.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
The Cattle Drive --
cattle drive
about the cattle drive
is the only service like this that I am aware of.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4726
    
    7

Marilyn,
The Cattle Drive is now a fee-based service, right? Do you mean to say that folks can't post non-Cattle Drive related code here and get it nitpicked for free?

Junilu - [How to Ask Questions] [How to Answer Questions]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
>Do you mean to say that folks can't post non-Cattle Drive
>related code here and get it nitpicked for free?

That is not what I intended to say. I had the impression that Tina was looking for more than what she can get in the regular forums by posting code here.

Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
How about if I post the code and see? If so, in which forum?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If it's only a page or so I'd dump the code anyway
If it belongs somewhere else you'll find out.
(don't worry about the semi-militant nature 'round these parts, comes from giving ppl guns )
Dave
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
This, Java in General (beginner), is a good forum to begin in.
Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
Okay, here is the code. It is designed to draw vectors with the mouse. I stripped it down quite a bit to shorten it, including the import statements. I am most concerned with the Canvas call (is there a better way?) and the drawRect() method I implemented in order to draw a border around the applet window. (There has to be a better way.) But most importantly, I am concerned about the overall structure -- I want a code that is robust. At any rate, thanks in advance. I loooove this forum!
__________________

(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited July 28, 2001).]
Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
Should I interpret the lack of responses as a good sign -- that there are no recommendations needed?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
It's just that we are in awe of your wonderful code, and don't want to sound stupid by critiquing it .
Actually it looks pretty good to me.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Nura Horne
Ranch Hand

Joined: Jul 26, 2001
Posts: 40
Yup, I lloked through it also and it has no errors in it that will be detrimental to programming more sophisticated works.
Good luck, A
Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
Great!
I do have one question -- what about the rectangle? In the above code I explicitly tell the program to draw a rectagle to use as a border around the applet window. Is this preferred?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well if you switched over to Swing and used a JApplet then you could have a BorderFactory and do cool stuff.
The sun tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html
Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
Thanks, but I have had my fill of Swing.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Ok, see, now I like Tina just for saying that.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
jQuery in Action, 2nd edition
 
subject: Review of Greenhorn Code?