Improving Your Java Programs - Tips & Resources

In summary: There are legal reasons why freeware is not embraced in the US, and it only becomes acceptable once a company like Oracle buys it.I disagree with this, because there are many developers who use freeware for personal projects. It is just not a popular choice in the United States.
  • #1
noagname
144
5
In school I'm in a class AP Computer Science where we learn java. In the past few weeks I have learned the basics of java which came very easy to me. Now I want to know what can I do to my programs to make them stand out? What should I strive for, least amount of lines or looks the best(we aren't learning Gui's.) Or is there something else I can strive for? Also if you have any good resources like these http://www.java2s.com/Tutorial/Java/CatalogJava.htm" that would be greatly appreciated.

Thank You

Here is my latest program, which was meant to just add two numbers but I added the dashes and the quit command to make it better.

-------------------------------------------
Please enter 2 numbers for me to add

Enter first number: 20.625
Enter second number: 21.375

Answer is: 42.0

To quit press 9 or press 1 to start over: 1
-------------------------------------------
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Sun, now Oracle, has a good java tutorial as well:
http://download.oracle.com/javase/tutorial/index.html
(Interesting, my link was actually to sun.java but it got
mapped to oracle...what will they think of next?)

Wikibooks has a good java book too:
http://en.wikibooks.org/wiki/Java_Programming

Are you assigned specific problems in the class or do you get to invent stuff yourself? If the latter, find something to do in a field that interests you, making astronomical calculations, doing astrological charts, calculating parameters for your hot-rod engine...whatever. While doing assigned homework problems, aside from consistent code formatting and good commenting, I would concentrate on elegant design and algorithms. Try to decompose the problem into a good Object Model using Abstraction, Inheritance, and Polymorphism...see the wiki article for more: http://en.wikipedia.org/wiki/Object-oriented_programming

ps...I would change your adder program to use a "q" or some other non-numeric input instead of "9" to quit...
 
  • #3
Devshed is one of the better resources for coding.

At this point in your education you should explore techniques with the technology. I am not a big fan of Java and the only reason it is widely used is because it was free. In the US free software is a big no-no, but globally developers like free tools even though you are giving away the code.

There are legal reasons why freeware is not embraced in the US, and it only becomes acceptable once a company like Oracle buys it. That is why everywhere else in the world they scratch their heads and wonder why freeware has not boomed in the US, like it has in Europe, India, and China.

But if you must use java, learn all of the flavors, awt, console, and jsp. Implement your code in all of them and you will learn alot.

Learn the core classes for each data type and how the operations are inherited. Understand typing to a science.
 
  • #4
airborne18 said:
In the US free software is a big no-no

I disagree with that. Many corporations and government agencies prefer to use freeware. Getting the customer to pay for software that is freely available is not an easy sell. There has to be a very good reason to not take the freeware over something that costs money but does the same thing.
 
  • #5


I understand the importance of continuous improvement and striving for excellence in any field of study. In the case of programming, there are several things you can do to make your programs stand out and improve their overall quality.

Firstly, it's important to focus on writing efficient and well-structured code. This means using appropriate data structures and algorithms, avoiding unnecessary lines of code, and following coding conventions. This can make your programs run faster and be easier to understand and maintain.

In terms of the appearance of your programs, while GUIs may not be a part of your current studies, you can still make your programs visually appealing by using proper indentation, commenting your code, and choosing meaningful variable names. This not only makes your code look better, but it also makes it easier for others to read and understand.

Another aspect to consider is error handling. As your programs become more complex, it's important to anticipate and handle potential errors to prevent your program from crashing. This can also make your programs more user-friendly and professional.

In terms of resources, the website you mentioned (java2s.com) is a good starting point for learning Java. However, I would also recommend checking out the official Java documentation and tutorials from Oracle, as well as online coding communities like Stack Overflow for tips and advice from experienced programmers.

Overall, the key to making your programs stand out is to continuously practice and strive for improvement. Keep learning new concepts and techniques, and don't be afraid to experiment and try new things. With dedication and hard work, you will be able to create high-quality, efficient, and visually appealing programs. Good luck with your studies!
 

Related to Improving Your Java Programs - Tips & Resources

1. How can I improve the performance of my Java programs?

To improve the performance of your Java programs, there are a few key things you can do. First, make sure your code is well-structured and organized. This will help with readability and maintainability. You should also optimize your code by avoiding unnecessary loops or using more efficient data structures. Additionally, consider using multithreading to take advantage of your computer's processing power. Finally, regularly profile and test your code to identify any bottlenecks and make necessary improvements.

2. What are some best practices for coding in Java?

Some best practices for coding in Java include following naming conventions, using proper indentation and formatting, writing clear and concise comments, and using appropriate data types. It is also important to handle exceptions properly and avoid using deprecated methods. Keeping your code modular and reusable can also make it easier to maintain and improve in the future.

3. Are there any tools or resources that can help me improve my Java programs?

There are many tools and resources available to help you improve your Java programs. Some popular ones include IDEs like Eclipse or IntelliJ, which offer features such as code completion, debugging, and refactoring. Code review tools like Checkstyle can also help you identify and fix potential issues in your code. Additionally, there are many online tutorials, blogs, and forums where you can find tips and advice from other Java developers.

4. How can I make my Java programs more secure?

To make your Java programs more secure, you should always sanitize user input to prevent SQL injection and other attacks. Use encryption for sensitive data and follow secure coding practices, such as avoiding hard-coded passwords and using HTTPS for web applications. Regularly updating your libraries and keeping up with security updates is also important.

5. Can I make my Java programs more user-friendly?

Yes, there are many ways to make your Java programs more user-friendly. First, you should design your user interface with usability in mind, making it intuitive and easy to navigate. You can also provide helpful error messages and feedback to guide users. Adding features like keyboard shortcuts and tooltips can also enhance the user experience. Finally, regularly testing your program with real users and incorporating their feedback can help you identify areas for improvement.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
6
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
8
Views
3K
Back
Top