fbpx
Wikipedia

Passive data structure

In computer science and object-oriented programming, a passive data structure (PDS, also termed a plain old data structure, or plain old data, POD) is a term for a record, to contrast with objects. It is a data structure that is represented only as passive collections of field values (instance variables), without using object-oriented features.[1]

Rationale

Passive 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. PDSs 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 irrelevant. For example, PDS 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 are not applied yet.

In C++

A PDS type in C++, or Plain Old C++ Object, is defined as either a scalar type or a PDS class.[2] A PDS class has no user-defined copy assignment operator, no user-defined destructor, and no non-static data members that are not themselves PDS. Moreover, a PDS class must be an aggregate, meaning it has no user-declared constructors, no private nor protected non-static data, no virtual base classes[a] and no virtual functions.[4] The standard includes statements about how PDS must behave in C++. The type_traits library in the C++ Standard Library provides a template named is_pod that can be used to determine whether a given type is a POD.[5] In C++20 the notion of “plain old data” (POD) and by that is_pod is deprecated and replaced with the concept of “trivial” and “standard-layout” types.[6]

In some contexts, C++ allows only PDS 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. PDS types can also be used for interfacing with C, which supports only PDS.

In Java

In Java, some developers consider that the PDS concept corresponds to a class with public data members and no methods (Java Code Conventions 10.1),[7] i.e., a data transfer object.[8] Others would also include Plain old Java objects (POJOs), a class that has methods but only getters and setters, with no logic, and JavaBeans to fall under the PDS concept if they do not use event handling and do not implement added methods beyond getters and setters.[citation needed] However, POJOs and Java Beans have encapsulation, and so violate the fundamental definition of PDS.

Records (introduced in Java 16, in 2021) are shallowly immutable carriers of data without encapsulation, and therefore they can also be considered PDS.

In other languages

In PHP, associative arrays and stdClass objects can be considered PDS.[citation needed]

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

In Python, dataclass module provides dataclasses - often used as behaviourless containers for holding data, with options for data validation.

In C, structs are used in the same manner

See also

Notes

  1. ^ A PDS class can have a base class whose first non-static data members differs.[3]

References

  1. ^ Black, Paul E.; Vreda Pieterse (2007). "passive data structure". Dictionary of Algorithms and Data Structures. Retrieved 11 September 2014.
  2. ^ Information Technology Industry Council (2003-10-15). Programming languages — C++ (Second ed.). Geneva: ISO/IEC. 14882:2003(E).
  3. ^ Bjarne Stroustrup (June 2013). The C++ programming language (Fourth ed.). United States of America: Pearson Education, Inc. ISBN 978-0-321-56384-2.
  4. ^ Walter E. Brown (September 29, 1999). . Fermi National Accelerator Laboratory. Archived from the original on 3 December 2016. Retrieved 6 December 2016.
  5. ^ "is_pod C++ Reference". cplusplus.com. Retrieved 6 December 2016.
  6. ^ "P0767R1: Deprecate POD". www.open-std.org. Retrieved 2020-01-20.
  7. ^ "Java Code Conventions 10.1". Oracle. Retrieved 6 December 2016.
  8. ^ "Java Language Data Structures". Sun/Oracle Code Conventions. April 20, 1999. Retrieved 6 December 2016.

passive, data, structure, confused, with, partitioned, data, computer, science, object, oriented, programming, passive, data, structure, also, termed, plain, data, structure, plain, data, term, record, contrast, with, objects, data, structure, that, represente. Not to be confused with Partitioned data set In computer science and object oriented programming a passive data structure PDS also termed a plain old data structure or plain old data POD is a term for a record to contrast with objects It is a data structure that is represented only as passive collections of field values instance variables without using object oriented features 1 Contents 1 Rationale 2 In C 3 In Java 4 In other languages 5 See also 6 Notes 7 ReferencesRationale EditPassive 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 PDSs 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 irrelevant For example PDS 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 are not applied yet In C EditA PDS type in C or Plain Old C Object is defined as either a scalar type or a PDS class 2 A PDS class has no user defined copy assignment operator no user defined destructor and no non static data members that are not themselves PDS Moreover a PDS class must be an aggregate meaning it has no user declared constructors no private nor protected non static data no virtual base classes a and no virtual functions 4 The standard includes statements about how PDS must behave in C The type traits library in the C Standard Library provides a template named is pod that can be used to determine whether a given type is a POD 5 In C 20 the notion of plain old data POD and by that is pod is deprecated and replaced with the concept of trivial and standard layout types 6 In some contexts C allows only PDS 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 PDS types can also be used for interfacing with C which supports only PDS In Java EditIn Java some developers consider that the PDS concept corresponds to a class with public data members and no methods Java Code Conventions 10 1 7 i e a data transfer object 8 Others would also include Plain old Java objects POJOs a class that has methods but only getters and setters with no logic and JavaBeans to fall under the PDS concept if they do not use event handling and do not implement added methods beyond getters and setters citation needed However POJOs and Java Beans have encapsulation and so violate the fundamental definition of PDS Records introduced in Java 16 in 2021 are shallowly immutable carriers of data without encapsulation and therefore they can also be considered PDS In other languages EditIn PHP associative arrays and stdClass objects can be considered PDS citation needed Other structured data representations such as XML or JSON can also be used as a PDS if no significant semantic restrictions are used In Python dataclass module provides dataclasses often used as behaviourless containers for holding data with options for data validation In C structs are used in the same mannerSee also EditPlain old CLR objectNotes Edit A PDS class can have a base class whose first non static data members differs 3 References Edit Black Paul E Vreda Pieterse 2007 passive data structure Dictionary of Algorithms and Data Structures Retrieved 11 September 2014 Information Technology Industry Council 2003 10 15 Programming languages C Second ed Geneva ISO IEC 14882 2003 E Bjarne Stroustrup June 2013 The C programming language Fourth ed United States of America Pearson Education Inc ISBN 978 0 321 56384 2 Walter E Brown September 29 1999 C Language Note POD Types Fermi National Accelerator Laboratory Archived from the original on 3 December 2016 Retrieved 6 December 2016 is pod C Reference cplusplus com Retrieved 6 December 2016 P0767R1 Deprecate POD www open std org Retrieved 2020 01 20 Java Code Conventions 10 1 Oracle Retrieved 6 December 2016 Java Language Data Structures Sun Oracle Code Conventions April 20 1999 Retrieved 6 December 2016 Retrieved from https en wikipedia org w index php title Passive data structure amp oldid 1117381999, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.