HHi
oday I’d like to recommend with you a guru/master in Spring framework:  John Thompson
He’s a software developer with more than 25 years experience. John has been working with Spring framework for 10 years and teaching Spring courses for 2 years, so I would like to recommend with you his most recent course on the latest update of Spring framework:

This is the most modern and comprehensive Spring Framework course available.

* What you will learn:
  • Learn the Spring Framework from an instructor who has worked for Pivotal customers as a Spring Source consultant, and has spoken at Spring One
  • Learn step by step how to build applications using Spring Framework 5 and Spring Boot 2
  • You will be taught using best practices such as SOLID OOP, GitHub, Test Driven Development, and Continuous Integration Testing
  • You will understand how to access data using Hibernate 5 and Spring Data JPA
  • Build an end to end Reactive application with Spring Framework 5 and MongoDB
  • Learn About Reactive Programming with Spring Framework 5
  • Build web applications using Spring MVC
  • See how to run a Spring Boot application inside a Docker container
  • Get access to a Spring Boot Application Cookbook

By enrolling in this latest Spring Framework course, you will have:
  • 49.5 hours on-demand video
  • 16 Articles
  • 79 Downloadable Resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion

There are over 32,651 students has enrolled in this course. Let’s see some students said about it:
“Because this course is being taught by an expert, the information I am learning is clear and complete. The content is great! I am still learning a lot of Spring Framework, so I'm glad I chose to this course!”
  - Kristin Johnston

“This guru really knows his stuff. The lessons are easy to follow and understand. Looking forward to applying this knowledge to my next project! Thanks John!”
  - John

“Outstanding! Mr. Thompson clearly is an expert in the field and has a skill for presenting that makes it easy to understand and apply to my current knowledge level. He's relaxed and informative. I feel as though its just me and him and he's teaching me personally. I would highly recommend him for all of your Spring Framework education.”
  - Eric Schweitzer

“Great course! Explanation is very good and easy to understand. I had fun doing the assignments and the resources are really helpful. This course taught me so much and I would recommend it to others.”
  - Michelle Mesiona

So if you are beginner/intermediate in Spring and want to become a guru, this course is what you need.

Click here to enroll now: Spring Framework 5: Beginner to Guru



Hi
You know, to create dynamic websites in Java you have to know two primary technologies called Java Servlet and JSP (Java Server Pages):
  • Java Servlet is responsible for processing requests on the server side, e.g. retrieving a list of books from a database.
  • JSP is responsible for displaying web pages dynamically on the client side, e.g. displaying a list of books in a web page.
Technically speaking, Servlet and JSP are the core components of the Java Enterprise Edition platform (Java EE). That means if you want to build websites using Java, you need to learn Servlet and JSP.
Rajesh Bharti, I want to tell you this…
Learning to create a website in Java is not difficult, especially if you follow the following tutorials written by me.

If you like building a website in Java from scratch (without using IDE), check out these tutorials:

In case you want to build a website in Java using IDE e.g. Eclipse, follow these tutorials:

I also published a video tutorial (HD quality) on this topic:

In addition, this tutorial helps you understand the process of deploying a Java web application on Tomcat server in depth:

I hope you will find these tutorials helpful to start creating websites using the Java programming language. And once you followed them, you know that I call they are “great tutorials” is really true.

Hi
How are you doing this weekend?
Today I’m very excited to introduce with you my latest video tutorial series that help you build a Java database-driven application with Swing and Hibernate framework.

You will be able to create a professional-looking program looks like this:

 
Throughout 16 videos (8.5 hours of live coding), you will learn how to develop a Java application from A to Z: Analysis, Design, Code, Test and Package.
Watch the introductory video here:
ATTENTION: I may take this video down at any time, so watch it now as long as it is still available.

Click here: https://swing-hibernate-guide.gr8.com/

What you will learn about Java Swing:
  • Creating professional-looking, industry-standard desktop program
  • How to use JFrame, JPanel, JTabbedPane, JDialog
  • How to use JTable with custom table model
  • How to use JMenuBar, JMenu, JMenuItem
  • How to use JToolbar, JButton, JLabel, JTextField
  • How to show message dialog & input dialog
  • How to handle events
  • How to use layout managers (GridBagLayout, FlowLayout, BorderLayout)

What you will learn about Hibernate Framework:
  • Using Hibernate Configuration file (hibernate.cfg.xml)
  • Mapping a one-to-many association using JPA annotations
  • Writing Entity Classes
  • Performing Create, Read, Update and Delete (CRUD) operations
  • Coding General Data Access Object (DAO) class
For full details of what you can learn in this HD video series, check out this page:

Happy learning!

Hi
I know you are busy. Me too. But busy for not studying how to improve your coding skills is not good.
Even you are busy, let read this email to the end, because what I am going to talk with you today will help you improve your coding skills forever.
Okay, let me ask you some questions:
•    Do you write methods and theirs parameters in your daily coding? Yesss, absolutely!
•    Do you think you have problems in writing methods? Oh, I don’t know.
•    Have you ever applied good practices to design your method’s parameters? Hmm, I never think about that.
So read on, as I’m going to share with you some cool techniques employed by the experts to write methods professionally. And you can do that, too.
Well, I have read the chapter 7 - Methods, item 40 - Design method signatures carefully in the book Effective Java, so I am eager to share what I have learned with you.
You know, there are some rules that tell us how to implement methods wisely.

* First, avoid writing a long list of parameters:

Here’s such a method:
public static void showMessageDialog(Component parentComponent,
                     Object message,
                     String title,
                     int messageType,
                     Icon icon)
This method is taken from the JOptionPane class in the javax.swing package. It has 5 parameters - good enough to make us difficult to remember which one is for what. Frankly, this method makes me confused most of the time when I use it, as I always have to double-check its Javadoc to ensure I passed the arguments correctly.
Having said that, the best practice is writing as few parameters as possible. Having many parameters is bad.
A method has more than 4 parameters is too much. Should be avoided.
A method has two parameters is good.
A method has only one parameter is the best.
And a method has no parameter is ideal.

* Second, avoid writing a sequence of parameters of the same type.

Consider the following constructor of the Insets class in the javax.swing package:
Insets(int top, int left, int bottom, int right)
And an usage like this:
    Insets inset = new Insets(10, 5, 20, 15);
This kind of method is easy to cause confusion. Because all the parameters are integer, I often run into trouble when specifying which one is the left, which one is the bottom, and so on. So I always have to look at the Javadoc to make sure.
This is also prone to error because I can put wrong parameters and the code is still compiled. The problem can be realized only at runtime.

* What if we cannot avoid a long list of parameters? For example, the following method must have 5 parameters:
void drawString(String text, int x, int y, int fontSize, int fontStyle);
According to Joshua Bloch (the author of Effective Java), there are 3 techniques to solve the problem of long parameters list.

1)    Technique #1: Break it into multiple methods
The drawString() method above can be broken into two methods like this:
void setFont(int fontSize, int fontStyle);
void drawString(String text, int x, int y);
However, the drawbacks of this technique are:
•    Increase the weight of the class (more methods).
•    It’s not always easy to break the method.
•    The client code is somewhat verbose when invoking multiple methods.
2)    Technique #2: Create a helper class with JavaBean style
In this technique, we can wrap all the parameters into a helper class that has getters and setters following JavaBean standard. For example, we can wrap the parameters of the drawString() method above into a TextObject class:
class TextObject {
    String text;
    int fontSize;
    int fontStyle;
    int x;
    int y;

    public void setText(String text) {
        this.text = text;        
    }

    public String getText() {
        return this.text;
    }    
    // other getters and setters go here…
}
Then use the helper class as follows:
TextObject textObj = new TextObject();
textObj.setText("Java World");
textObj.setX(100);
textObj.setY(200);
textObj.setFontSize(18);
textObj.setFontStyle(Font.BOLD);
Then pass this object into the drawString() method:
    drawString(textObj);
This solution is fairly good to solve the problem of long parameters list. However there are some disadvantages:
•    The client code may be too wordy as using many setters.
•    The helper class is mutable, which is not good for being passed into the method ((Effective JavaItem 39 - Make defensive copies when needed)).
•    It’s difficult to validate all the parameters in one place since the setters are invoked separately.

3)    Technique #3: Using the Builder pattern
This technique combines the previous two techniques with the builder pattern to solve the problem of long parameters list.  Consider the following class:
public class Person {
    // required fields:
    private String name;
    private int age;

    // optional fields:
    private Date birthday;
    private String email;
    private String phone;
    private String address;
    private float weight;
    private float height;

    // getters and setters
}
This Person class has only two required fields: name and age, and the rest are optional.
Besides the getters and setters, we tend to implement various constructors like these:
public Person(String name, int age);
public Person(String name, int age, Date birthday);
public Person(String name, int age, Date birthday, String email);
public Person(String name, int age, Date birthday, String email, String phone);
and so on, until the last constructor covers all the fields, which is equivalent to 8 parameters. Ouch!
Suppose that we want to create a new Person object with full details, we tend to use two ways:
•    First way: sing the full-parameter constructor:
Person me = new Person("Name", 31, new Date(), "nam@codejava.net", "0904277091", "Hanoi", 65, 172);
8 arguments to pass! Too much to remember which is for what. Such long list of parameters cause the code hard to read and maintain.
•    Second way: using setter methods:
Person me = new Person();
me.setName("Name");
me.setAge(31);
me.setBirthday(new Date());
me.setEmail("nam@codejava.net");
me.setPhone("0904277091");
me.setAddress("Hanoi");
me.setWeight(65);
me.setHeight(172);
This looks better than using the full-parameter constructor, however it is too wordy. Also the Person object is mutable, which is not good to pass into the method.
Now, let’s see how the Builder pattern can solve the problems above.
First, we create a Builder class which is nested inside the Person class:
public class Person {
    public static class Builder {

    }
}
Remember to remove all the setters of the Person class.
Here’s the detailed implementation of the Builder class:
    public static class Builder {
        private String name;
        private int age;

        private Date birthday;
        private String email;
        private String phone;
        private String address;
        private float weight;
        private float height;

        public Builder(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder age(int age) {
            this.age = age;
            return this;
        }

        public Builder birthday(Date birthday) {
            this.birthday = birthday;
            return this;
        }

        public Builder email(String email) {
            this.email = email;
            return this;
        }

        public Builder phone(String phone) {
            this.phone = phone;
            return this;
        }

        public Builder address(String address) {
            this.address = address;
            return this;
        }

        public Builder weight(float weight) {
            this.weight = weight;
            return this;
        }

        public Builder height(float height) {
            this.height = height;
            return this;
        }

        public Person build() {
            return new Person(this);
        }
    }
You see, this builder class has same fields as the enclosing class, but the methods for setting values are different. Take a look at this method:
        public Builder address(String address) {
            this.address = address;
            return this;
        }
The interesting point here is that this method returns the Builder itself. Why? It’s for easily chaining multiple invocations together. You will see how in the usage example below.
The second interesting point is in the build() method:
        public Person build() {
            return new Person(this);
        }
Look, this method returns a new object of the Person class. We need to make the Person’s constructor private like this:
    private Person(Builder builder) {
        this.name = builder.name;
        this.email = builder.email;
        this.age = builder.age;
        this.birthday = builder.birthday;
        this.phone = builder.phone;
        this.address = builder.address;
        this.weight = builder.weight;
        this.name = builder.name;
    }
This is the sole constructor of the Person class, it copies values of the fields from the builder to itself.
In addition, we can add code to validate the fields in the build() method before returning the new Person object. For example:
        public Person build() {
            if (name == null) {
                throw new IllegalArgumentException("Name cannot be null");
            }

            return new Person(this);
        }
That’s done for the implementation of the Person class’ builder. Now, let’s see how to use this pattern:
        Person me = new Person.Builder("Nam", 31)
                                .email("hainatu@gmail.com")
                                .address("Hanoi")
                                .build();
Wow!  This looks more readable than using a full-parameter constructor, right?
Let’s see another usage which creates a Person object with full details:
        Person you = new Person.Builder("You", 27)
                                .birthday(new Date())
                                .email("hainatu@gmail.com")
                                .phone("0123456789")
                                .address("Hanoi")
                                .weight(62)
                                .height(170)
                                .build();
You see, Rajesh Bharti? This is very flexible and easy to read, right? The Person object created is now immutable (remember to remove all its setters).
This builder pattern solves the problems of long parameters list nicely. It takes more time to implement but it will pay off in the long term as the code evolves.
So far I have focused on the implementation of the Builder pattern, for more good practices about methods, consult the Effective Java book.

Hi
Today I would like to share with you this Udemy course that helps you learn how to use design patterns in Java:
There are several courses about design patterns, but I see this one is the best so I recommend it to you (I already purchased and learned it).
In this course, you will learn to write better software by understanding common problems and applying design patterns for a better solution.
This course will give you insight in the more than 20+ design patterns from the book "Design Patterns: Elements of Reusable Object-Oriented Software", by Gamma, Helm, Johnson and Vlissides, which is the most famous book about design patterns in computer programming.
For each pattern a clear example is given to understand the problem the pattern will solve, as well as its advantages and disadvantages. You will be able to practically understand how the pattern works with the detailed included Java lessons.
At the end of this course, you will be able to
  • Identify common problems in your code
  • Apply the correct design pattern
  • Talk with colleagues using a common vocabulary (and be a hero)
  • Implement a better object oriented solution that is a lot more maintainable and readable

“I have been trying to learn Java Design Patterns many times and read many books and web pages on and off. This course provided a way to go through the patterns systematically at a steady pace. The examples also helped to really understand what a pattern is for and how to apply it in a real-world situation.” – Kevin Liao
So if you want to quickly learn and apply design patterns into your program, click the following link to take this course:
12.99 USD – 23 hours left at this price!

Enjoy learning!
rajesh bharti
hi
Do you remember that last week I shared with you some tutorials for getting started with Java Servlet and JSP? It’s just the beginning…
Today I’m going to share with your another great tutorial that helps you take your Java EE programming skills to the next level. Here it is:
Throughout this tutorial, I will guide you how to build a Books Store web application that manages a collection of books in a database. The application looks like this:
By following this tutorial step by step, you will learn:
  • Developing a Java web application with Eclipse IDE
  • Deploying and running a Java web application on Apache Tomcat server
  • Using Maven for a Java dynamic web project
  • Writing a controller class with Java Servlet
  • Displaying list data and handling web forms with JSTL in JSP
  • Working with MySQL database (Workbench and command line client)
  • Executing CRUD operations (Create, Read, Update, Delete) with JDBC
  • Organizing and structuring code
I bet you will benefit a lot from this tutorial, as I’ve spent a lot of time to make it easy to follow and updated with latest technologies. Click here to start this awesome tutorial:



Hi Rajesh Bharti,
How are you doing today?
I’m a little bit tired but nothing can stop me from writing for you today. You know, writing for you has been my habits for months. I hope you have the habits of reading my emails as well.
Well, many friends ask me to explain the concepts of interfaces in Java. I think is this an important topic in Java which may cause some confusions to almost beginners, so I promised with myself to write an article dedicated for this topic on CodeJava.net.
Rajesh Bharti, I know you already know something about interfaces in Java. Can you please check the rules below and correct me if I am wrong?
1)    Fields in an interface are public, static and final implicitly:
That means the following 2 code snippet has the same meaning:
Implicit:
interface Color {
    int RED = 0xff0000;
}
Explicit:
interface Color {
    public static final int RED = 0xff0000;
}
In other words, you actually declare a constant when you put a field into an interface. So an interface can be used to group some related constants together.
That also means that you cannot declare a field whose access specifier is more restrict than public. For example, the following code won’t compile:
interface Color {
    private int RED = 0xff0000;
}
2)    Methods in an interface are public implicitly:
Because the interface defines a contract with the outside world, it’s weird if something in the interface is private. The following example shows two methods are both actually public  though they are declared with different access specifier:
interface Dog {
    void bark();
  
    public void waveTail();
}
3)    A class can implement multiple interfaces:
Let’s see an example:
class MyFrame extends JFrame implements Runnable, ActionListener {
    // implement method from Runnable:
    public void run() {
        // code
    }

    // implement method from ActionListener
    public void actionPerformed(ActionEvent evt) {
        // code
    }
}
Here, the MyFrame class implements the Runnable interface so its instances can be executed by a thread. It also implements the ActionListener interface in order to handle click events of buttons. In this case, the MyFrameclass overrides method run() and actionPerformed() from its super interfaces.
4)    The overriding methods cannot have more restrict access specifiers:
Because methods in the interface are public implicitly, the overriding methods in the subclass cannot have more strict access specifier. For example:
interface Runnable {
    void run();
}

class Runner implements Runnable {
    void run() {
        // cause compile error...
    }
}
The Java compiler will complains: attempting to assign weaker access privileges; was public. The run() method in the interface has public access, whereas its overriding version in the Runner class has package access. Thus the code won’t compile.
5)    Non-abstract classes must override all methods declared in the super interfaces:
Let’s see an example:
interface Animal {
    void eat();
    void sleep();
}


class Dog implements Animal {
    public void eat() {
        // dog eats...
    }
}
This code won’t compile because the Dog class overrides only one method eat() from the Animal interface.
6)    Abstract classes are not forced to override all methods from their super interfaces. The first concrete class in the inheritance tree must override all methods:
Let’s see an example:
interface Animal {
    void eat();
    void sleep();
}
abstract class Felidae implements Animal {
    public void sleep() {
        // sleeping
    }

    // this abstract class doesn't override the eat() method
}

class Cat extends Felidae {
    public void eat() {
        // cat eats...
    }
}
Here, the Felidae class is abstract so that it is not forced to override all methods from the Animal interface. However, Cat is a concrete class so it must override the remaining method eat() from the super interface.
7)    An interface cannot extend another class
8)    An interface can extend from multiple interfaces:
Let’s see an example:
interface Animal { }

interface Predator extends Animal { }

interface Herbivore extends Animal { }

interface Human extends Predator, Herbivore { }
9)    An interface can be nested within a class:
For example:
class A {
    interface B { }
}
10)    An interface can be nested within another interface:
For example:
interface C {
    interface D { }
}
11)    Methods in an interface cannot be static and final
12)    Since Java 8, an interface can have a default method:
Java 8 allows an interface can have a concrete method which is called default method. See: Default Methods in the Java Tutorials.
13)    Functional interface is an interface that has only one method:
For example, the following is a functional interface:
interface Runnable {
    public void run();
}
Functional interfaces are used in Lambda expressions.
Okay. So far I have covered the key rules regarding interfaces in Java. If you found I missed something, feel free to contribute.
Nam Ha Minh
A Java Lover
P.S1: To understand interfaces in depth, I recommend you take a look at the section 9 - Interfaces in the Java language specification.
P.S2: A worth-reading section: Program to an Interface, not an Implementation, page 30 in the well known book: Design Patterns: Elements of Reusable Object-Oriented Software.
P.S3: Can you review this article? Everything you need to know about Interfaces in Java

hii

Have you ever dreamed about creating additional sources of income from the Internet? Imagine you can make more money besides your salary.
In fact, you have many abilities to make money online. You just don’t know or you are not aware of it.
I’ll show you how in Freelance Magic.

In this e-book, I will reveal 23 different services you can offer in order to make money online as regular streams of income. This will open your mind in making money online. Download it here:

Hurry up, because I’m offering this e-book freely for only few persons. That page can be taken down very soon.