• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Advice on coding

 
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!

I'm new here in the forum and i have a question...

I'm starting to learn Java and i would like to know if it's ok with you guys if a post here my code to get some advice and suggestions about it.
I'm not in no course (i'm a self learner) so none of my questions are homework. just some tasks that i find and start to try to code them.
I don't want "the job done" so to speak. just insights on what may be wrong, ways to improve and such.
Many foruns don't like this kind of things so that's why i'm asking first.

Thanks

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carlos and welcome to the Ranch!  We have a page about How To Ask Questions On Java Ranch -- follow even half the advice enshrined there and you're gold!
 
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!!

Carlos wrote: i would like to know if it's ok with you guys if a post here my code to get some advice and suggestions about it.

yes we are much ok with it.on ranch we have plenty of volunteers who have a sole intension to help others.so ask the questions or about suggestions without any hesitation.

Carlos wrote:I'm not in no course (i'm a self learner) so none of my questions are homework. just some tasks that i find and start to try to code them.

I appreciate your effort.in my opinion that's is a best way to learn something.so just best of luck for your future.

Carlos wrote:I don't want "the job done" so to speak. just insights on what may be wrong, ways to improve and such.

Bingo!! That's what we want from your side in fact we do not provide solutions but a hint or some kind of help so that you can build your solution yourself.

Carlos wrote:Many foruns don't like this kind of things so that's why i'm asking first.

Ranch is Different from those many forums..
never feel guilt or shy to ask questions.feel free to ask.
Here is the link for frequently asked questions on ranch→FAQ.try to explore through all the pages in the link,it has everything how to ask questions,code ranch features etc...

Kind regards,
Praveen.
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your kind answers!

Hi Carlos and welcome to the Ranch!  We have a page about How To Ask Questions On Java Ranch -- follow even half the advice enshrined there and you're gold!



I'm taking a look at the page Darryl. Will try my best to follow those advices!

I appreciate your effort.in my opinion that's is a best way to learn something.so just best of luck for your future.  



Thanks Praveen.

Bingo!! That's what we want from your side in fact we do not provide solutions but a hint or some kind of help so that you can build your solution yourself.



I believe that if someone does all the job for you, than you won't ever learn anything. And i like to get to the "finish line" by miself...

Ranch is Different from those many forums..  



I'm glad to ear that! But nevertheless i had to ask cause "time is money" and you are all volunteers here... And some of the code i may post can be lengthy (for instance i'm currently doing an implementation of an HugeInteger class that i found in book "Java How to Program - 10th ed". As you can imagine it has a lot of lines of code already...).

Again thanks

Best regards
Carlos
 
praveen kumaar
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos wrote:I'm glad to ear that! But nevertheless i had to ask cause "time is money" and you are all volunteers here... And some of the code i may post can be lengthy (for instance i'm currently doing an implementation of an HugeInteger class that i found in book "Java How to Program - 10th ed". As you can imagine it has a lot of lines of code already...).

no worries first of all here is a quote from Martin Fowler, "Refactoring: Improving the Design of Existing Code

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

so try to write that lengthy code in a way so that we can understand it.ask for code reviews here.we will help you at our best.
You can also insert comments for the part which is less intuitive in a code(we have a feature CodeTags,click here→UseCodeTags,to know about it).

kind regards,
Praveen.
 
praveen kumaar
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos wrote:ear that...ask cause

Please use complete words.if you would look into the link,Darryl has given,it is mentioned there to avoid acronyms,abbreviation etc..because here on ranch we have volunteers and members from different countries and they all have not the English as the native language(like me) so they may find it hard to parse those words.

Kind regards,
Praveen.
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry...
Not "cause" but "because"!
I myself i'm not a native english speaker so I understand that.

But I for some reason can't edit my posts. I made a couple of mistakes (again not native english) and couldn't correct them!
 
praveen kumaar
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually Editing a post is a topic of Subject to change whenever Ranch Authority find it should be.like for me,i had got my editing option when i earned 5 cows.but i am not sure what is the present policy regarding this.however we have another feature called "Preview" button which will show you how does a post look after you submit it.the button is just adjacent to the submit button.so take a preview before submitting.

Kind Regards,
Praveen.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm a moderator on the ranch, and even I'm not sure what the edit policy is for non-moderators. I think tehre is a window of time when you can edit your own post, but couldn't say how long it is.

Having said that...don't worry about it too much.  We understand typos.  We understand people make mistakes. you can always post a follow-up, quoting the relevant part of your post, and say "oops, I meant this...".  
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:I think tehre is a window of time...


obviously I meant "there is a window..."
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i think there isn't any window because i noticed my typos/errors right after submitting my reply and couldn't edit it.

I don't worry that much because, as already stated, everyone makes mistakes.
But when i see my typos they make me itchy and i like to correct them...

Praaven the code in the class i'm coding is all commented out... I read a lot of times already that we should do that so that "the next guy" that reads the code can easily understand it.

Regards
Carlos
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

praveen kumaar wrote:... a quote from Martin Fowler, "Refactoring: Improving the Design of Existing Code

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.


The reality is, however, that it takes a special kind of fool to write code that a computer can understand but humans can't.  More often, it's the case that if a human can't understand the code, a computer is more likely to understand it in a way the human didn't expect.

A corollary to that is "To err is human but it takes a computer to really screw things up."  It's a funny saying, for sure, but it shifts the blame to the innocent. A computer only does what the programmer told it to do. If the programmer doesn't really know what he/she is telling the computer to do, the computer simply reflects the programmer's own muddled thoughts back as muddled action. The hard truth is really this: "Garbage In, Garbage Out."
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Carlos: Welcome to the Ranch!

Carlos Reves wrote:I read a lot of times already that we should do that so that "the next guy" that reads the code can easily understand it.


Remember, too, that next guy could be you a few days, weeks, months, or years from now.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for your advices.

I'll try to remember them all, everytime.
Especially this last one...

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.



Best regards
Carlos
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just one more question...
Even though in the How To Ask Questions On Java Ranch page is said to post my code in the message using the code tags, if it is a long code, is it acceptable to attach the .java source files instead?

Thanks
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Reves wrote:Just one more question...
Even though in the How To Ask Questions On Java Ranch page is said to post my code in the message using the code tags, if it is a long code, is it acceptable to attach the .java source files instead?


We prefer that you UseCodeTags to share short snippets of code that is most relevant to your question. We may later on ask you to share more code to give more context.  Sharing all of your program is hardly ever necessary if the program is more than 50 lines long.
 
Carlos Reves
Ranch Hand
Posts: 116
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.
Thanks.

Best regards.
Carlos
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic