曾看到一些类似的问题:
- What is the difference between a JavaBean and a POJO?
- What is the Difference Between POJO (Plain Old Java Object) and DTO (Data Transfer Object)?
您也能够告诉我使用这些技术的背景? 或其目的如何?
曾看到一些类似的问题:
您也能够告诉我使用这些技术的背景? 或其目的如何?
A JavaBean is a section that following . Java Beans conventions S. Wikipedia对JavaBeans做了相当好的总结:
Java Beans是可再使用的软件部件,可以视像在建筑工具中加以操纵。 实际上,这些课程是用符合特定公约的 Java方案语言撰写的。 它们被用来将许多物体归为单一物体(星号),以便它们可以被作为单一物体而不是作为多个单个物体。 A JavaBean is a Java 具有序列意义的物体,具有无固定构造者,并允许使用采集器和固定方法获取财产。
为了作为 JavaBean阶级发挥作用,物体类别必须服从某些关于方法命名、建筑和行为的公约。 这些公约使得有可能拥有能够使用、再利用、取代和连接JavaBeans的工具。
所需公约包括:
- The class must have a public default constructor. This allows easy instantiation within editing and activation frameworks.
- The class properties must be accessible using get, set, and other methods (so-called accessor methods and mutator methods), following a standard naming convention. This allows easy automated inspection and updating of bean state within frameworks, many of which include custom editors for various types of properties.
- The class should be serializable. This allows applications and frameworks to reliably save, store, and restore the bean s state in a fashion that is independent of the VM and platform.
由于这些要求主要是作为公约而不是通过实施接口表达的,一些开发商认为Java Beans是符合具体命名公约的Plain古老 Java。
A Plain Old Java 反对或POJO是最初引入的一个术语,目的是指定一个简单的轻度 Java物体,而不是执行任何<代码>javax.ejb的接口,而不是重度EJB 2.x(特别是实体为人,无国籍者并非海事组织的坏事)。 今天,这一术语用于任何没有额外缺陷的简单物体。 Wikipedia在界定:
POJO is an acronym for Plain Old Java Object. The name is used to emphasize that the object in question is an ordinary Java Object, not a special object, and in particular not an Enterprise JavaBean (especially before EJB 3). The term was coined by Martin Fowler, Rebecca Parsons and Josh MacKenzie in September 2000:
"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."
The term continues the pattern of older terms for technologies that do not use fancy new features, such as POTS (Plain Old Telephone Service) in telephony, and PODS (Plain Old Data Structures) that are defined in C++ but use only C language features, and POD (Plain Old Documentation) in Perl.
The term has most likely gained widespread acceptance because of the need for a common and easily understood term that contrasts with complicated object frameworks. A JavaBean is a POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods. An Enterprise JavaBean is not a single class but an entire component model (again, EJB 3 reduces the complexity of Enterprise JavaBeans).
As designs using POJOs have become more commonly-used, systems have arisen that give POJOs some of the functionality used in frameworks and more choice about which areas of functionality are actually needed. Hibernate and Spring are examples.
数值目标或剂量为java.lang。 持有价值(历史价值物体)的Integer
。 关于更正式的定义,我经常提到Martin Fowler对:
企业应用结构模式 我将价值目标描述为一个小目标,例如货币或日间目标。 他们的主要财产是,他们遵循的是价值特性,而不是参考特性。
你通常可以告诉他们,因为平等的概念基于身份,而如果所有领域都平等,那么两个价值目标就平等。 虽然所有领域都是平等的,但如果子公司是独一无二的,那么你就不必比较所有领域,例如货币编码足以检验平等。
一种一般的犹豫是,价值物体应完全不可变。 如果你想要改变价值目标,你就应当用新的物体取代该物体,并且不允许其更新价值物体本身的价值,即假定价值物体会产生问题。
早期的J2EE文献用“价值”一词来描述一个不同的概念,我称之为“。 自那时以来,他们改变了其使用,并使用了以下术语:Transfer Object。
数据收集 目的或DTO是一种与欧洲黄麻和黄麻业联合会共同采用的(反)模式。 设想的不是向欧洲黄麻业协会发出许多遥远的电话,而是将数据归入一个可转让给网络的价值目标:数据传输 反对。 Wikipedia对
<>DTO vs VO <>DTO- 数据传输物体只是数据集装箱,用于在层和层之间传送数据。 Analogy: 计算机通信组织主要用来获取通过网络有效运输的数据,甚至可能从联合仪器到另一个联合仪器。 DTOs经常是 <>strong>VO- A Value Object *** 表示自己是一套固定的数据,类似于 Java。 A 价值 物体特性基于其状态,而不是其物体特性,是不可改变的。 一个真正的世界例子是科罗拉。 RED, Color。 BLUE, SEX。 FEMALE等。 <POJO vs JavaBeans [1]
The Java-Beanness of a POJO is that its private attributes are all accessed via public getters and setters that conform to the JavaBeans conventions. e.g. [2]
JavaBeans must implement Serializable and have a no-argument constructor, whereas in POJO does not have these restrictions. 基本情况 DTO: “数据传输物体”可在软件结构中平流层之间流动。 VO: “危险物体”持有例如Integer、Finalg等物体。 POJO: Plain Old Java 不是特别物体的物体。 Java Beans: 要求有可序列使用的 Java Beans不是EJBs。 rel=“noreferer”>Java Beans specification in Java 1.0 ,是Sun s 企图允许在像VB一样的民主选举学会中操纵 Java物体。 规定了适用于“Java Beans”的物体的规则: EJBs后来来到这里。 它们把分送的部件和交易模式结合起来,使用一个集装箱,管理read、集合、生命周期并提供各种服务。 他们是Java Beans的 cr。 海外木材组织是在 Java背景下进行的,因为人们发现,EJB1.0光谱太“聊天”数据库。 民众不为每个数据要素提供圆形,而是将这些数据包裹到大宗的 Java贝南,并带走。 POJOs是对EJBs的反应。 POJO :
It is a java file(class) which doesn t extend or implement any other java file(class). Bean:
It is a java file(class) in which all variables are private, methods are public and appropriate getters and setters are used for accessing variables. Normal class:
It is a java file(class) which may consist of public/private/default/protected variables and which may or may not extend or implement another java file(class). 第一次会谈 Normal Class - that s mean any class define that s a normally in java it s means you create different type of method properties etc. 在那次会谈之后,法国审计署 POJO - POJO is that class which have no any services it s have only a default constructor and private property and those property for setting a value corresponding setter and getter methods.
It s short form of Plain Java Object.
Simple Registration form with attributes username,
password and email id.
java.io.Serializable
——以便把数据传输到国际交易日志。 private String foo;
public String getFoo(){...}
public void setFoo(String foo){...};
Java 级
,每个领域有no-arg
的构造器和一台接机和板
Bean - Bean is nothing it s only a object of that particular class using this bean you can access your java class same as object..