Content deleted Content added
Jeffryfisher (talk | contribs) Describe term as acronym and retronym (linked) |
m oops, fix duplicate ref |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 1:
{{Short description|Type of object in Java programming language}}
In [[software engineering]], a '''plain old Java object''' ('''POJO''') is an ordinary [[Java (programming language)|Java]] [[object (computer science)|object]], not bound by any special restriction. The term was coined by [[Martin Fowler (software engineer)|Martin Fowler]], Rebecca Parsons and Josh MacKenzie in September 2000:<ref name="bliki">{{cite web |url=http://www.martinfowler.com/bliki/POJO.html |title=MF Bliki: POJO |work=MartinFowler.com }}</ref>
"We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely."<ref name="bliki">{{cite web |url=http://www.martinfowler.com/bliki/POJO.html |title=MF Bliki: POJO |work=MartinFowler.com }}</ref>▼
▲
The term "POJO"
</ref> For [[PHP]], it is [[plain old PHP object]] (POPO).<ref>{{cite web |url=http://jan.kneschke.de/2007/2/19/typesafe-objects-in-php/ |title=typesafe objects in PHP |first=Jan |last=Kneschke |date=2007-02-19 |work=kneschke.de |access-date=2012-05-27 |url-status=dead |archive-url=https://web.archive.org/web/20120326195616/http://jan.kneschke.de/2007/2/19/typesafe-objects-in-php/ |archive-date=2012-03-26 }}</ref><ref>{{cite web |url=http://jym.sg/controller-with-bare-bone-plain-old-php-objec |title=Controller with bare-bone Plain Old PHP Object aka POPO |first=Jym |last=Cheong |date=2011-06-26 |work=jym.sg |access-date=2012-05-27 |url-status=dead |archive-url=https://web.archive.org/web/20120326195611/http://jym.sg/controller-with-bare-bone-plain-old-php-objec |archive-date=2012-03-26 }}▼
The term continues an [[acronym]] pattern to coin [[retronym | retronyms]] for constructs that do not use fancy new features:
▲The POJO phenomenon has most likely gained widespread acceptance because of the need for a common and easily understood term that contrasts with complicated object frameworks.{{Citation needed|date=April 2013}}
* "Plain old JavaScript object" in [[JavaScript]]<ref>{{cite web |url=http://ajaxian.com/archives/return-of-the-pojo-plain-ole-javascript |url-status=dead |archive-url=https://web.archive.org/web/20140913151352/http://ajaxian.com/archives/return-of-the-pojo-plain-ole-javascript |archive-date=2014-09-13 |title=Return of the POJO: Plain 'Ole JavaScript |last=Almaer |first=Dion |work=Ajaxian |date=2006-07-17 |access-date=2014-08-19 }}</ref>
* "Plain old Ruby object" (PORO) in [[Ruby (programming language)|Ruby]]
* "Plain old Documentation" (pod) in [[Perl]]
* [[Plain old CLR object]] (POCO)<ref>{{cite web |url=http://msdn.microsoft.com/en-us/library/cc681329.aspx |title=POCO Support |work=microsoft.com |access-date=2012-05-27 }}
</ref> in the [[.NET Framework]]
▲
</ref> in [[PHP]]
* [[Plain old telephone service]] (POTS) in [[telephony]]
==Definition==
Line 34 ⟶ 39:
The definition of the POJO can be as follows:
<syntaxhighlight lang="java">public class MyBean {
public class MyBean {▼
private String someProperty;
Line 46 ⟶ 50:
this.someProperty = someProperty;
}
}</syntaxhighlight>▼
▲</syntaxhighlight>
Because of the JavaBean naming conventions the single "someProperty" reference can be automatically translated to the "getSomeProperty()" (or "isSomeProperty()" if the property is of [[Boolean type]]) method for getting a value, and to the "setSomeProperty(String)" method for setting a value.
The [https://projectlombok.org/ lombok] library allows to change the code dynamically to integrate those conventions without the hassle to write them. The following code would generate the same bean, with the addition of an empty constructor :<syntaxhighlight lang="java">@NoArgsConstructor
▲public class MyBean {
@Getter @Setter
private String someProperty;
}</syntaxhighlight>Other libraries or framework generate code (or bytecode) with those conventions directly. The addition of those tools help alleviate the [[Boilerplate code|boilerplate]], which in turn reduces the bugs frequency and maintenance cost .
===Transparently adding services===
Line 108 ⟶ 119:
* [[Data transfer object]] (DTO)
* [[Anemic ___domain model]]
* [[KISS principle]]
==References==
Line 117 ⟶ 129:
[[Category:Java (programming language)]]
[[Category:
|