Simple Data Structure

From GM-RKB
Jump to navigation Jump to search

A Simple Data Structure is a



References

2014

  • (Wikipedia, 2014) ⇒ http://en.wikipedia.org/wiki/Plain_old_data_structure Retrieved:2014-5-19.
    • In object-oriented programming, plain old data structure (PODS), or plain old data (POD) is a term for a record, to contrast with objects. That is, a PODS is a data structure that is represented only as passive collections of field values (instance variables), without using 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. PODSs are often found at the boundaries of a system, where information is being moved to and from other systems or persistent storage and the problem domain 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 PODS type in C++ is defined as either a scalar type or a PODS class. A PODS 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 PODS 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. [1] The standard includes statements about how PODS must behave in C++. The type_traits library in the STL, provides a function known as is_pos that can be used to determine whether a given type is a POD. [2] In certain contexts, C++ allows only PODS types to be used. For example, a union in C++98 cannot contain a class that has virtual functions or nontrivial constructors or destructors. This restriction is imposed because the compiler cannot determine which constructor or destructor should be called for a union. PODS types can also be used for interfacing with C, which supports only PODS. In Java, some developers consider that the PODS concept corresponds to a class with public data members and no methods (Java Code Conventions 10.1),[1] i.e., a data transfer object. [3] Others would also include POJOs (a class that has methods but only getters and setters, with no logic) and Java Beans to fall under the PODS concept if they do not use event handling and do not implement additional methods beyond getters and setters.However, POJOs and Java Beans do have encapsulation and so violate the fundamental definition of PODS.

      Other structured data representations such as XML or JSON can also be used as a PODS if no significant semantic restrictions are used.

  1. "C++ Language Note: POD Types", by Walter E. Brown, Fermi National Accelerator Laboratory, September 29, 1999; last updated November 29, 1999.
  2. is_pod — C++ Reference
  3. "Java Language Data Structures", Sun/Oracle Code Conventions from April 20, 1999.