Sign in

Flexible Hybris Developer | Writes about Java, Developer lifestyle, common developer issues | so-close-to-Medior Java Developer | En route to seniority

You might not know these Java practices for top-notch code

Photo by Tima Miroshnichenko from Pexels
1. You need to throw Exception on empty Optional
2. You need to test and inspect an exception
3. How to use assertion errors?

1. You need to throw Exception on empty Optional

You shouldn’t use ifPresentOrElse for exceptions. Here’s a bad example.

ifPresentOrElse — Bad example of using custom runtime exceptions

What are the snippet problems?

  • Throws unchecked exceptions only

emptyAction can throw only RuntimeException. As an example, it’s the NullPointerException if the value or action isn’t present. Runnable can throw unchecked exceptions. Runnable isn’t designed to work for checked exceptions.

  • Exceptions complicateifPresentOrElse

The use case of emptyAction isn’t to throw exceptions. Throwing exceptions from emptyActioncauses complex code.

3 reasons why the frontend is as valuable as the backend.

Backend developer looking at frontend developers.
Photo by fauxels from Pexels

The frontend is simple. Backend is the real deal. How hard it is to present the data?

I’ve worked on both. Angular and Spring Boot. Both have good sides and obstacles.

Here’s why the frontend is valuable as the backend.

Frontend is complex

You create a REST endpoint. Frontend calls that endpoint. Frontend presents the data. Simple stuff. Presentation is markup, fetching is a built-in feature (fetch API), and styling is a minor issue. We can conclude, frontend is simple.

No. Frontend worries about native markup. Frontend worries about accessibility. Frontend worries about user experience. The frontend is complex.

How remote work changed coding forever


83% of software engineers want remote work options post-pandemic.

Remote work is here to stay. Hybrid or fully remote.

You need to change. Change your habits. Change your mindset. You need to prepare for the future.

Here’s how remote work changed your work, your behavior, and how to respond to changes.

How does remote work affect your work?

Remote work creates a new working environment. Excluding freelancers, they work from anywhere. You don’t commute to the office. You don’t have random water cooler talks. You don’t need to work by the clock. Most developers like this situation.

What remote work removes? Connections. You’re now an avatar…

Lessons you don’t have to learn the hard way

Photo by Tima Miroshnichenko from Pexels

Learning Java is hard. Experience is the best teacher. Experience teaches you through mistakes.

I learned from my mistakes. You can learn from my mistakes.

Here’s what I learned the hard way, and you don’t have to.

1. Lambdas can give you a hard time

Lambdas often exceed 4 lines of code. Doing more than supposed to. More responsibility — harder for your working memory. More lines —multiple-responsibility lambda.

Do you need to change the variable from lambda? You can’t do that. Why? If lambda could access callsite variables multi-threading issues can occur. You can’t change the callsite variables from within lambda.

Happy path in lambda works excellent…

What developers hate but recruiters do anyway

Photo by Tima Miroshnichenko from Pexels — Edits by author

Most recruiters don’t tell the truth.

They hide. They’re silent about important topics. They show disinterest in you.

Here’s why the recruiter’s behavior matters.

Benefits aren’t important

Recruiters believe we care about benefits. “We have a pool!”. “We have table tennis, which employees play all the time.” Juniors care. Experienced developers don’t care.

According to studies, this is what developers care about.

5 problems — 5 Git commands

Photo by Roman Synkevych on Unsplash — Edits by author
· How to avoid force push?
· How to find a commit with specific content?
· How do you combine commits?
· How do you change a specific commit?
· How you can undo a git rebase?

How to avoid force push?

You rebase your branch onto main. You don’t want to force push. Why? You can break the remote. You erase other team member changes.

Here’s one example. Let’s have a feature branch and Alice and Bob are pushing work to that feature branch. Alice completes part of the feature, commits, and pushes to the remote. Bob finishes his work, before the push to…

Top 3 mistakes I made and you shouldn’t

Photo by Tima Miroshnichenko from Pexels — Edits by author

1. You don’t switch bad jobs

Most juniors think this job is the best. The best I can get. The thing is you don’t know what’s out there yet. You should explore different options. You need to try more and settle for one thing. I started with Angular, and now working on Java microservices. You should switch jobs if you don’t feel like doing it.

Your job is challenging? Do you like the team? You don’t want to switch jobs? Great. Stay put. You should switch jobs if you don’t progress. You should switch jobs if you’re under pressure.

5 Reasons GitHub Copilot Won’t Replace You


1. Copilot doesn’t know your domain

Copilot is an enhanced autocomplete. Copilot doesn’t know the domain. You need to provide the seed, and the copilot will plant the seed. The gist — the developer is still essential.

Copilot doesn’t know the pros and cons. Developers understand the pros and cons of a certain solution. You can’t outsource these decisions to Copilot. We need a domain expert to weigh the solution. Copilot is a utility to convert our thoughts into code. Developers understand the whys, Copilot helps with the hows.

Copilot is specific in coding. Developers are generic in coding. Developers know how the solution can be…

Here are the 5 practices I use to code faster

Photo by Tima Miroshnichenko from Pexels

You’re working on several tasks at once? You can’t choose a tech stack? Do you lose time on refactoring?

We all have these issues. You work on several tasks, quality suffers, and time flies by. You choose one library and find a better one tomorrow.

Here’s what you need to apply and reduce the time-wasters.

· Stick with one tech
· Consult first, change second, review after
· Don’t overengineer
· Focus on solving business problems
· Avoid multitasking

Stick with one tech

Work with one tech stack. This holds for experienced developers. New developers should try different tech, and see what they like…

How to use Collectors to improve refactors

Photo by Mikhail Nilov from Pexels

We use Collectors a lot. We compress huge code blocks. We compress the logic. We use them to improve code quality.

We don’t know much about Collectors. Apply them, the test passes, and we move on. That’s why we should explore this topic now.

Have a look at 3 advanced Collectors tips you should know.

· 1. How to aggregate object properties based on a key?
· 2. How to reduce lists better?
· 3. How to create SQL’s HAVING with Java?
· Takeaway

1. How to aggregate object properties based on a key?

Let’s look at this question first. …

Miloš Živković

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store