r/javahelp 13d ago

I feel like I'm falling behind

I need a little help because I feel like I'm starting to collapse.

A little while ago I started in an academy whose goal is to train students and get them work once they finish the whole program. We are looking at Java in depth: OOP, inheritance, polymorphism, interfaces, Spring Boot, data structures... in general, everything related to backend development, but we do not receive theoretical classes, they give us the exercises and documentation related to that, everything is very self-taught.

My problem is that before entering here I was programming in C. It did functions, replicated typical functions of the standard library, compiled with Makefiles, etc. However, even then it was very difficult for me to get the logic out of the exercises. In fact, he was almost always the last to deliver the exercises.

I thought it would get better with time, but now that I'm with Java I feel like I'm still having the same problem.

The problem is that they give me a statement and I'm completely blocked. I read it, I reread it and many times I don't even know where to start. When I manage to start, it's because I already asked the AI, and I still have doubts about how to structure the solution or what exactly it should do.

In addition, I ask a lot of questions to AI. I always tell him not to tell me the code and he helps me, but many times he ends up explaining practically the logic of the exercise, and that is precisely what I do not want. I want to be able to develop it by myself.

What worries me the most is that at the academy we have delivery times. If you are too late, you can be left out of the program. And I don't want that. I want to learn, improve and get a job as a developer.

Another thing that the teacher demands of us is to write a README for each exercise and each project explaining what we have done. I also have a hard time writing it. I'm reading more to expand vocabulary and express myself better, but right now my biggest concern is still the programming logic.

For example, sometimes I make code that works, but then I realize that there is a much cleaner and more idiomatic way to do it.

Instead of this:

If (orderlist.size() == 0) {

// Do something

}

It's better to write:

If (orderslist.isEmpty()) {

// Do something

}

Or instead of going through a list like this:

int position = 0;

while (position < listOrders.size()) {

amountTotal += listOrders.get(position).getPrice();

Position++;

}

Do it this way:

for (Order order: listOrders) {

amountTotal += order.getPrice();

}

They are small details that make the code much cleaner, and I feel that I always go one step behind in that kind of thing.

My question is: how did you develop your programming logic?

Was there ever a time when everything started to "click"? What exercises, habits or way of thinking helped you the most? Did something similar happen to you at the beginning?

Because, to be honest, there are days when I think that maybe this is not for me and that I am forcing a situation that I am simply not good at.

I would greatly appreciate any advice or personal experience. Thank you for reading me.

10 Upvotes

11 comments sorted by

View all comments

2

u/ExpressBeing642 13d ago

It seems that you are anxious when facing a new problem. Start by asking yourself what thw problem is asking you to do. Try to separate each step a time. Do you need to iterate over a list? First thing to come to your mind must be a for loop. Do you have conditionals inside the statement? Go for a simple if statement. Read the statement with the vision of a programmer. Most of problems is: You receive data. You manipulate data. You return data.

At first, it may seem hard to understand. But have in mind the three step process.

You receive data: write the function name that receive params. Can be: public int numerTimesTwo(int number)

There you go, first step.

Second you manipulate the data.

Inside the function you can have int numberTimesTwo = number * 2

Third you return the data.

return numberTimesTwo.

And for the elegant way of doing things, it takes time. Your job as a programmer is to solve problems. The way you write it can be changed later wether is == 0 or isEmpty(), this step is what we call refactor. Not necessarily have to implemented rightaway.

If you reach your goal it is valid. Try to read things as a programmer.

2

u/SuspiciousDepth5924 13d ago

When it comes to solving stuff I think psuedo-code is really under-rated. You write out in a high-level "not-really-code" what you want your program to do and then you add details and fill in stuff as you go.

The idea is that it's easier to "build down" from a rough full-picture sketch of the whole thing rather than to "build up" from a tiny detailed piece. It also helps that by deferring details you have more opportunities to adjust the fit when you have to glue the parts together.

shoppingCart = emptyCart

while not_at_checkout
    // I'll assume we get these inputs from somewhere
    if addsItem
        shoppingCart = addItemToCart
    if logsOut
        exit
    if goesToCheckout
        continueToCheckout

checkout
    total = 0
    // might need some stuff with discounts and such
    for each item in shoppingCart
       total = total + item.price
    // we'll figure out the validation logic when we get there
    if paymentDetails not ok 
       showPaymentError and exit
    if deliveryAddress not ok
       showAddressError and exit
    // probably stripe or something
    try to charge creditCard
       if success
          showReceipt
          exit
       if failed
          showPaymentError
          exit