Plain old data structure

from Wikipedia, the free encyclopedia

In computer science and software engineering , a plain old data structure (POD) describes a data structure that consists only of simple attribute values ​​and in which no object-oriented principles have been applied.

introduction

PODs are used in particular where ensuring data integrity and processing the data is taken over by other system components. They are often used at system boundaries where data is exchanged between different systems or with persistent data carriers and where the business logic of the systems involved is therefore not directly relevant. For example, objects that are generated from external data can be implemented in the form of PODs. The checking of the semantic correctness and the data integrity is then taken over in a further step by other system components.

PODs in C ++

In C ++ , a POD data type is either a scalar data type or a POD class. A POD class has no custom copy-assign operator, no custom constructor, and no non-static attributes that are not themselves PODs. In addition, a POD class must be an aggregate type or a union , that is, it must not have any user-defined constructors, no non-static attributes that are defined as private or protected , no base classes and no virtual functions . The C ++ standard provides more details about how PODs behave in C ++.

Depending on the specific use, only POD types may be possible in C ++. For example, in C ++ 98 a union can not contain classes that have virtual functions or non-trivial constructors or destructors. This restriction comes from the fact that the compiler cannot decide which constructors or destructors to call on the elements of the union. POD types can also be used to call C functions, since C only supports PODs.

PODs in Java

In Java , the POD concept is sometimes equated with a class that contains only public attributes and no methods, which corresponds to the concept of a transfer object . Sometimes POJOs (classes that only contain getters and setters, but no business logic) and JavaBeans , as long as they do not use event handling and contain no methods other than getters and setters, are also referred to as PODs. On the other hand, POJOs and JavaBeans use the concept of encapsulation and thus violate one of the fundamental properties of a POD data type.

additional

Other structured data such as XML or JSON can also be used as PODs if no extensive semantic restrictions have been defined for the data.

See also

literature

  1. Information Technology Industry Council: Programming languages ​​- C ++, Second edition , ISO / IEC, Geneva October 15, 2003, 14882: 2003

Web links

Individual evidence

  1. Oracle Technology Network Java ( English ) oracle.com. Retrieved September 21, 2019.