"There you are."

"I thought about it and decided to teach you one more small lesson that will be very helpful for you. Until you work as a programmer, you likely never encounter some special terminology, so I want to introduce you to several common concepts now."

"About 10 years ago, Enterprise Java Beans (EJB) became widely used."

"What does JavaBeans mean?"

"JavaBeans basically means coffee beans (Java is a kind of coffee). It's IT humor."

"A program's business logic took the form of a group of high-level objects, or beans, which could exchange messages, save themselves, find each other by name, and a whole lot more. Usually, this was achieved through a special super-fancy parent class though there were other approaches. The behavior of such objects was highly regulated."

"The three most famous types of EJB beans are:"

"An Entity Bean is a bean whose purpose is to store certain data. This type of bean has a built-in mechanism for saving itself and its fields into a database. This type of object can be destroyed and then recreated later from the database. But aside from storing data, it doesn't have any logic."

"A Session Bean is a functional bean. Each session bean has its own function. One does one thing, and another does something else. Such beans work with other objects and beans, not with their own data."

"Session Beans are divided into two categories."

"A Stateless Session Bean is a bean whose internal variables do not store important data that it needs to function. This type of bean can be destroyed and then recreated, and it will perform its function just as before."

"A Statefull Session Bean is a bean that internally stores the data that it uses when working. If we call methods on such a bean, then each subsequent call can use some of the data passed to the bean in previous calls. Still, this bean is not the same as a regular object."

"But using beans wasn't all that great either, so soon the pendulum swung in the opposite direction. And developers began using ordinary objects more frequently. They even came up with a special name."

"A POJO is a Plain Old Java Object. These objects didn't have any super-functions and didn't inherit super-objects. They were just regular Java objects."

"When you get to know EJB in practice, you'll understand the difference. Roughly speaking, a POJO is a knife, and an EJB is a Swiss Army knife that you can also use to make phone calls."

"Interesting comparison."

"Yes, and here's one more thing."

"Over time, objects and classes began to be specialized. As a result, developers identified certain roles and gave new names to the corresponding objects."

"A data transfer object (DTO) is an object created to transport data. These objects usually have two requirements. They must: a) be able to store data, b) be serializable. In other words, they are used only for transferring data."

"You create an object, write the required data from the business logic into it, serialize it into JSON or XML, and send it where it needs to go. Or the other way around: a message arrives, you deserialize it into a DTO object, and extract data from it."

"An Entity is an object that is stored in a database. But they don't contain any business logic. You could say that this the business model's data."

"We also have the data access object (DAO). A DAO is used to save objects to and retrieve them from a database. The entity doesn't do this, since it doesn't have any logic, so it can't save anything anywhere."

Example:

Relationship between a DAO and an entity
UserEntity user = UserDAO.getUserById("1535");
if (user.getAge() > 18)
{
 user.setMobilization(true);
 UserDAO.save(user);
}
Comments
UserEntity is a class that stores user data
UserDAO is a class that retrieves data (UserEntity objects) from the database and stores it there again after modifying it.

"That's all for now."

"Even though this is a small introductory lesson, you still won't be able to understand more right now. We could spend days talking about each of these topics, and we could spend years covering EJB."

"But I want you at least to be able to imagine what is being said if you come across these things in conversations and messages, on forums, or in an interview."

"Hmm. Thank you, Bilaabo. Yeah, I think I don't know enough technical terms. Again, thank you so much."