0

I'm self learning Java now and I have only vary basic knowledge of object oriented programing. I have chosen to make a project that could be used in real life, a Computer Repair Shop software for tracking tickets, devices, clients and other related things.

I have two questions.:

  1. I have chosen to learn the language by using it while making a project. Is this good or bad way to learn programing?

  2. While I am learning the language I have also focused on learning good coding style so I don't pick up bad habits in code writing. Am I focusing on code style prematurely, or is it good to learn that hand in hand with the language itself?

5
  • You might want to look at stackoverflow.com/questions/22961733/… for the java code conventions. Commented Oct 13, 2019 at 19:08
  • 1
    1) It's hard to think of a better alternative. You may struggle, but at least you have an objective. If you didn't have a project, what would you do? 2) It's never a bad time to learn good programming practices. Commented Oct 13, 2019 at 19:11
  • 1
    Your question is off-topic. But I'd say that learning by doing is basically the only real way, and that obeying the standard code style is pretty much mandatory if you want to be able to read your own code, and thus be able to understand what you're doing, where your errors are, how to change the code. Commented Oct 13, 2019 at 19:12
  • It is good to now I am on the right path. Thank you. Commented Oct 13, 2019 at 19:14
  • Should I delete this question? Commented Oct 14, 2019 at 11:07

1 Answer 1

1

Trying to create a project is a pretty good way to learn! A few things:

Class names should start with upper case letters, like String, variable and method names should use the camel case naming convention: myVariable, myMethod. An exception is when a variable is constant, full upper case name in that case:

 final in MY_CONSTANT = 3;

Always give clear names for your variables and methods, so it's possible to know what they do just by reading the name.

Comment your code! This is very important, as good, informative comments will help you and others understand the code. You can also take a look at (Javadoc comments).[https://www.tutorialspoint.com/java/java_documentation.htm]

You already mentioned object oriented programming, so don't be afraid to make classes for the entities in your project, like Customer or Device. You can combine the classes to better model your Computer Repair Shop:

public class Customer {

 private String name;
 private List<Device> devices; //all devices of the customer 

 public Customer(String name) {
      this.name = name;
      devices = new ArrayList<>();
 }

 public void registerDevice(Device d) {
      devices.add(d); 
 }

}

This is just a stupid little example of course, but you get the point.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes of course, I am already pass that point an I have already implemented all data-structure of the project. Ticket, Client, Device, Model, Device Type, Manufacturer, Notification, and other related things. And objects of that classes are put in HashMap with one of the unique field of those objects as keys. i have done some of the GUI with Java swing and Windowbuilder. I was asking about things like: Writing Short Units of Code, Writing Simple Units of Code, Keeping Unit Interfaces Small, Separate Concerns in Modules, Coupling Architecture Components Loosely, Writing Clean Code...
Oh forgive me, if you are at GUI programming already then surely you know all this. Anyways, I will leave my answer up, could be useful for someone else!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.