4.36 out of 5
7 reviews on Udemy

Clean Code with Java examples

In this Clean Code Java course you will learn useful software principles that you can use in your every day programming.
Liviu Oprisan
1,410 students enrolled
How to write clean code
How to keep your functions small
How to name your variables, functions and classes
How many parameters a function should have
What to do about boolean, nullable and return parameters
How clean code affected MVC
How to beautify predicates
Why comments are bad and when you can use them
The difference between an OOP object and a Data Structure Object
What kind of exceptions to use
Why composition is good and inheritance is bad
What are the symptoms of bad code
What state is and why it's important
Why your code should have low coupling and high cohesion
How to avoid spaghetti code
What are Command and Query separation, Tell Don't Ask and The Law of Demeter
The test pyramid and TDD
How over-engineering is not a solution to bad code

This is a course about useful clean code principles.
My aim is to teach you concepts that you can use every time you write code.

The course has Java examples and I sometimes mention things like Spring and Lombok.
The same clean code principles apply also to PHP, C# and Python.

What can this course do for you?

It can save your company and yourself a lot of development time and therefore a lot of money.
Bad code practices can make development very slow on your medium and big projects.
This means a lot of money wasted on development time.
This type of projects are also remarkably unpleasant to work on.
This course helps you avoid this by using clean code principles.

The course is structured in 4 parts:

1. Introduction – where we discuss what is clean code and why it’s important

2. Small Functions – I gave small functions an entire section because I think its one of the most important principles of clean code, together with small classes, Single Responsibility Principle and Not crossing Different Levels of Abstraction.

3. Clean code: Fundamental Principles – I discuss here about fundamental things like method and variables names, parameters, comments and exceptions

4. Clean code: Advanced Principles – Here I talk about more abstract topics like the difference between an OOP Object and a Data Structure Object, Composition over Inheritance, Symptoms of Bad Code, State, Low Coupling – High Cohesion, Command and Query Separation, Tell Don’t Ask, The Law of Demeter and more.

The course also contains some memes because you can’t spell clean code without fun.

I tried to focus on things you can use every day when programming and stay away from barren theory.
There’s no point wasting our time with useless knowledge that would just seem like it’s helping you as a programmer, but that you will forget in 2 weeks.
If that would have been the point, this would be a 10 hours course about programming patterns.
But it isn’t.

I tried to make the course full of useful information but not too long.
If you invest as little as two hours of your life in this course, about the time you would spend watching a movie, you will become a much better developer.


Why this course
Clean code: From Art to Science

In this video I explain what clean code is and how I started to be interested in it.

What people say

In episode 2 of the Clean Code course I talk about what people say related to clean code.

Sample code

In this video I take a look at samples of code: some bad code and some good/clean code.


In this episode I talk about why empathy is important for clean code.

I also recommend to check out what Robert C. Martin (Uncle Bob) has in the area of clean code.

Clean code: Small Functions

Small functions are easy to understand

In this episode I start talking about the advantages of small functions with the first one: they are easy to understand.
It's a bit of a longer episode because i go through more code than usual.

More advantages of small functions

In this episode I talk about the other advantages of small functions.
Besides being easy to understand they are easy to:
Keep bug free
They help you avoid code repetition
They beautify code
They separate concepts into their levels of abstraction

How many lines should a small function have

In this episode I talk about what size a function and a class should have.

What does small mean.

What does one thing mean.

What to do when your function is too big.

Single responsibility principle

In this clean code video I talk about Single Responsibility Principle and how it relates to Small Functions.

Levels of Abstraction - An MVC discussion

In this video I talk about:

- why you shouldn't cross different levels of abstraction

- what levels of abstraction are

- how they are important in MVC frameworks

- what MVC frameworks are

- how small methods shaped how we use MVC

- how new projects make old mistakes

High Level First - writing code using method calls first

In this video I talk about a programming technique called High level first.

Clean code: Fundamental principles

Names - for methods, classes and variables

In this episode I talk about variable and function names.

What parts of speech to use, how long or short they should be, why naming is important and what not to do.


In this episode I talk about parameters. How many parameters you should use. Why same type parameters are trickier. Why parameters that change state inside your functions are bad. Boolean and null parameters.

Programming line length

In this episode I talk about how far to the right should a line of code go.
The importance of having the code always start from the same place on the monitor.
C# starting brackets vs java starting brackets.

Beautify predicates

In this lecture I talk about beautify predicates - making the content of an if statement prettier with a function name.


In this episode I talk about comments.
Why they are bad and should be avoided except for a few cases.

Should I use exceptions?

In this video I talk about exceptions.
You should use unchecked, runtime exceptions.
You should use your own exceptions not the java ones.

Clean code: Advanced principles

OOP Objects vs Data Structure Objects

In this video I talk about the two different types of objects you will find in code, Classical OOP objects and Data structures. How you should treat each of them and how their getters and setter should look like.

Composition Over Inheritance

In this episode I talk about why composition is preferred to inheritance and how I got to understand this.
What signs I saw that inheritance was starting to turn against.
I also talk a bit about the Liskov substitution.

Symptoms of Bad Code

How does a project with bad code manifest?
What are it's symptoms?
Uncle Bob has a great video on article on cleancoders.com about these:

What is state in programming and why is it important. State and MVC.

In this lecture I talk about what state is, why it is dangerous and why immutable code is valuable.
Also I continue the discussion about state and MVC from an earlier lecture by adding the state element into it.

Low Coupling, High Cohesion

In this lecture I talk about why low coupling, high cohesion is important and why you should always keep it in mind when developing.
I talk about spaghetti code and how you can refactor to avoid high coupling and low cohesion.

Command and Query Separation, Tell Don't Ask and The Law of Demeter

In this lecture I talk about three more programming principles that will help you keep your code clean and avoid spaghetti code.

Test Pyramid and Test Driven Development

In this lecture I talk about the test pyramid;
why unit tests should form the foundation of your tests.
I explain how TDD works and why it's the best way of writing code.

Is over-engineering a solution to bad code? (spoiler: it isn’t)

In this lecture I talk about a case of over-engineering that I have witnessed a couple of times in my career.
Also how in most cases with problematic projects a complex design pattern or an exotic technology is not the solution, but clean code is.


Create a project using everything I described.

You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.4 out of 5
7 Ratings

Detailed Rating

Stars 5
Stars 4
Stars 3
Stars 2
Stars 1
Course available for 2 days
30-Day Money-Back Guarantee


2 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion

External Links May Contain Affiliate Links read more

Join our Telegram Channel To Get Latest Notification & Course Updates!
Join Our Telegram For FREE Courses & Canva PremiumJOIN NOW