• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the most effective way to learn to code?  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just started learning Java in college and going to be a CS major and eventually want to get my MS in CS. My question is what is the most effective way to learn to code? i will learn C++ as well and who knows what else later down the road. right now my classes at school are just lectures and a lab once a week. not much coding going on unless its on my own time so i want to know how to effectively use the time i do have. When i say im new i mean im super new haha.


This is a little thing i wrote just getting used to coding and typing it out and everything. nothing fancy obviously. any tips or pointers would be appreciated. thanks all!

 
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the real world currency is almost never represented by a double but a BigDecimal instead. You might try to modify your code to use BigDecimal.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Carey. yeah i have been told by a few people to look into that now. wasnt aware that existed obviously lol xD i will be working on figuring all that out tomorrow after i get home from classes. i had a bigger program written but now both of my classes in BlueJ are saying no source so i might have to remake all of it. going to ask my prof if she knows how to fix that and call it a night for tonight. thank you again!
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Open your folders and see whether the .java and .class files are where you think they are. Maybe stop using BlueJ (I have suffered from it in the past and have a disliking for it) and use NotePad++ instead. But the important thing is to move that code out of the main method and start creating objects.
You can see examples of BigDecimal in use here
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good style and indentation on your code!

Here's something to start doing in Java: declare local variables just before you need them.  Declaring all your variables at the top is not necessary.  So,

...becomes...
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch

Open your folders and see whether the .java and .class files are where you think they are. Maybe stop using BlueJ (I have suffered from it in the past and have a disliking for it) and use NotePad++ instead. But the important thing is to move that code out of the main method and start creating objects.
You can see examples of BigDecimal in use here


yeah I just got out of my CS class and my professor explained what the issue was with my files not being found so I am going to try and fix that soon. Thank you for the welcome! so far this has been the most helpful and quick thing to get a response
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Good style and indentation on your code!

Here's something to start doing in Java: declare local variables just before you need them.  Declaring all your variables at the top is not necessary.  So,

...becomes...


I can definitely see how much that would clean up my code. I didn't think about doing that even. didn't occur to me that I could ask for input, declare, and store a value all in the same line :P thank you!
 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:Just started learning Java in college and going to be a CS major and eventually want to get my MS in CS. My question is what is the most effective way to learn to code?

This is a more general answer to your question. They say French is the language of love, possibly because of the beautiful ways you can use it to express that emotion. Code is just another way of expressing yourself not only to a computer but also to other people. At their core, computer languages are languages of logic and math. Java itself is an object-oriented computer programming language. To code effectively in general, you need to learn how to be logical, organized, and systematic, just as you need to be in other disciplines that involve math and logic. To code effectively in Java, you need to understand object-orientation.

The replies you've received from others like the suggestion to move code out of your main() method, to start creating objects, and the comment about good style and indentation all hint at the kind of logical, organized, and systematic thinking you need to develop. They are different ways of expressing your ideas in code more effectively.

I think you would benefit from reading the book Think Like a Programmer by V. Anton Spraul. That book is all about thinking logically and being systematic and organized. It also uses examples in C++ which you'll be learning as well in the near future.

Other books I'd recommend you read are Clean Code by Robert Martin, Refactoring by Martin Fowler, Effective Java Programming by Joshua Bloch, and Understanding the Four Rules of Simple Design by Corey Haines.  All these books go beyond basic language mechanics and touch more on the heart of the kind of thinking you need to master the skill of writing computer programs effectively. If you study and master the principles you'll find in these books, then I think you'll be well equipped to meet any challenges you'll have in your further studies.

Good luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!