What are pre-specified classes?

Asked

Viewed 93 times

4

Reading the wikipedia publication about POJO (Plain Old Java Objects), I came across the term pre-specified classes. I understood very superficially that perhaps these are the classes of specification, but it was not very clear.

Could explain better?

https://en.wikipedia.org/wiki/Plain_old_Java_object

Definition

Ideally speaking, a POJO is a Java object not limited by some other constraint than these enforced by Java Language Specification. In other words, a POJO must:

Do not extend pre-specified classes, as in public class Foo extends javax.servlet.http.Httpservlet { ... Do not implement pre-specified interfaces, such as in public class Bar Implements javax.ejb.Entitybean { ... Do not contain any pre-specified annotations, as in @javax.persistence.Entity public class Baz { ...

2 answers

4


In this case this term gets a little weird or without giving context, but it’s simple. Is it easier if it was written "previously declared" or "already created"? The latter even flirts with the error, but it seems to make it more obvious what it is. That is, it is only talking about classes already existing in the code.

But there is one caveat: every Java class inherits from at least the class Object, this is not counted in this constraint. This is because the language specification forces all classes to have a common root. The text is a little poorly written and does not make it so clear.

POJO classes are simple, and run away from what is conventionally used in object orientation, they have no inheritance, sophisticated mechanisms, or even behaviors beyond the trivial of the object, but nothing that creates extra mechanisms of object manipulation, as is common.

  • right, I think I understand, but as so either previously stated or already created. At some point I will create the class I want to inherit, no?

  • 1

    Yes, without creating something, it does not exist and what does not exist cannot be used.

  • Okay, so the conclusion is, doesn’t Pojos inherit (extends, Mplements or receive annotatios) in any way (except Objects)? .

  • At that point it’s not confused, it’s in others.

  • I understood better now, after reading Deitel

1

The question of the pre-specified classes is as follows:.

Plain Old Java Objects means more or less "The good old Java objects". It means a purely Java object created by you, using at most libraries already included in Java, created without any kind of particularity of external frameworks, such as the Servlets or JEE framework (EJB), which are later JDK technologies that require Java objects to have "particularities" in their declaration/implementation, such as implementing an interface or extending a specific class of the framework, which is what the text calls "pre-established class"or have certain annotations, with the intention of running on a Container. Pojos could be called "Vanilla Java Objects" that would have the same effect.

This answer explains well what they are.

I didn’t mess with JEE and I don’t remember exactly what a Java Bean Enterprise looks like, but Fowler and colleagues wanted to show in the talk that you could program without EJB, just with ordinary objects, and called these ordinary (non-JB) objects POJO, as he says here.

A domain object, such as a Pedido or a Cliente is a typical POJO. A Javabean is a POJO with certain particularities, but that does not depend on anything external, so it is still a POJO.

An EJB, Servlet and Hibernate entity are not Pojos, implement JDK-specific interfaces, specific annotations.

A DAO or Repository that uses Hibernate I don’t know if it’s POJO. A subclass of a Java Swing component I don’t know if it’s POJO. But it could be angel sex, and I don’t know if it’s worth arguing about. The term POJO arose as a reaction to the Java EE Ejbs, and that’s what it is, a common object that doesn’t need to be an EJB.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.