What is meaning of Plain Old Java Object (POJO)?

前端 未结 8 1510
别跟我提以往
别跟我提以往 2020-12-12 15:43

What does the term Plain Old Java Object (POJO) mean? I couldn\'t find anything explanatory enough.

POJO\'s Wikipedia page says that POJO is an ordinary Jav

8条回答
  •  一生所求
    2020-12-12 16:19

    Plain Old Java Object :)

    Well, you make it sound like those are all terrible restrictions.

    In the usual context where POJO is/are used, it's more like a benefit:

    It means that whatever library/API you're working with is perfectly willing to work with Java objects that haven't been doctored or manhandled in any way, i.e. you don't have to do anything special to get them to work.

    For example, the XStream XML processor will (I think) happily serialize Java classes that don't implement the Serializable interface. That's a plus! Many products that work with data objects used to force you to implement SomeProprietaryDataObject or even extend an AbstractProprietaryDataObject class. Many libraries will expect bean behavior, i.e. getters and setters.

    Usually, whatever works with POJOs will also work with not-so-PO-JO's. So XStream will of course also serialize Serializable classes.

提交回复
热议问题