Plain Old Data Structures
Encyclopedia
A plain old data structure (POD) is a data structure
that is represented only as passive collections of field values, without using encapsulation or other object-oriented features.
Plain old data structures are appropriate when there is a part of a system where it should be clearly indicated that the detailed logic for data manipulation and integrity are elsewhere. PODs are often found at the boundaries of a system, where information is being moved to and from other systems or persistent storage and the business logic that is found in other parts of the system is not relevant. For example, PODs would be convenient for representing the field values of objects that are being constructed from external data, in a part of the system where the semantic checks and interpretations needed for valid objects have not yet been applied.
A POD type in C++
is defined as either a scalar type or a POD class. A POD class has no user-defined copy assignment operator, no user-defined destructor, and no non-static data members that are not themselves PODs. Moreover, a POD class must be an aggregate, meaning it has no user-declared constructors, no private nor protected non-static data, no base classes and no virtual functions. The standard includes statements about how PODs must behave in C++.
In certain contexts, C++ allows only POD types to be used. For example, a union in C++ cannot contain a class that has virtual function
s or nontrivial constructors or destructors. This restriction is imposed because the compiler cannot know which constructor or destructor should be called for a union. POD types can also be used for interfacing with C
, which supports only PODs.
In Java
, some developers consider that the POD concept corresponds to a class with public data members and no methods (Sun Code Conventions 10.1), i.e., a data transfer object
. Others would also include POJO
s (a class that has methods but only getters and setters, with no logic) to be a POD. Java Beans fall under the POD concept if they do not use event handling and do not implement additional methods beyond getters and setters.
Other structured data representations such as XML
can also be used as PODs if no significant semantic restrictions are used.
Data structure
In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks...
that is represented only as passive collections of field values, without using encapsulation or other object-oriented features.
Plain old data structures are appropriate when there is a part of a system where it should be clearly indicated that the detailed logic for data manipulation and integrity are elsewhere. PODs are often found at the boundaries of a system, where information is being moved to and from other systems or persistent storage and the business logic that is found in other parts of the system is not relevant. For example, PODs would be convenient for representing the field values of objects that are being constructed from external data, in a part of the system where the semantic checks and interpretations needed for valid objects have not yet been applied.
A POD type in C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
is defined as either a scalar type or a POD class. A POD class has no user-defined copy assignment operator, no user-defined destructor, and no non-static data members that are not themselves PODs. Moreover, a POD class must be an aggregate, meaning it has no user-declared constructors, no private nor protected non-static data, no base classes and no virtual functions. The standard includes statements about how PODs must behave in C++.
In certain contexts, C++ allows only POD types to be used. For example, a union in C++ cannot contain a class that has virtual function
Virtual function
In object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature...
s or nontrivial constructors or destructors. This restriction is imposed because the compiler cannot know which constructor or destructor should be called for a union. POD types can also be used for interfacing with C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
, which supports only PODs.
In Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
, some developers consider that the POD concept corresponds to a class with public data members and no methods (Sun Code Conventions 10.1), i.e., a data transfer object
Data Transfer Object
Data transfer object , is a design pattern used to transfer data between software application subsystems. DTOs are often used in conjunction with data access objects to retrieve data from a database....
. Others would also include POJO
Pojo
Pojo may refer to:* Pohja, the Swedish name for the Finnish municipality* POJO, abbreviation of Plain Old Java Object in computer programming...
s (a class that has methods but only getters and setters, with no logic) to be a POD. Java Beans fall under the POD concept if they do not use event handling and do not implement additional methods beyond getters and setters.
Other structured data representations such as XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
can also be used as PODs if no significant semantic restrictions are used.