Content deleted Content added
m →In C++ |
|||
(24 intermediate revisions by 19 users not shown) | |||
Line 1:
{{Short description|Another term for record}}
In [[computer science]] and [[object-oriented programming]], a '''passive data structure''' ('''PDS''', not to be confused with IBM's [[partitioned data set]]s; also termed a '''plain old data structure''', or '''plain old data''' ('''POD''')), is a term for a [[Record (computer science)|record]], to contrast with objects. It is a [[data structure]] that is represented only as passive collections of [[Field (computer science)|field]] values ([[instance variable]]s), without using object-oriented features.<ref name ="psd">{{cite journal |last=Black |first=Paul E. |author2=Vreda Pieterse |title=passive data structure |journal=Dictionary of Algorithms and Data Structures |year=2007 |url=https://xlinux.nist.gov/dads/HTML/passiveDataStruc.html |accessdate=11 September 2014}}</ref>▼
{{confused|Partitioned data set}}
▲In [[computer science]] and [[object-oriented programming]], a '''passive data structure''' ('''PDS'''),
==Rationale==
Line 5 ⟶ 7:
==In C++==
A PDS type in [[C++]], or [[Plain Old C++ Object]], is defined as either a scalar type or a PDS class.<ref>{{cite book |author= Information Technology Industry Council |publisher= ISO/IEC |___location= Geneva |title= Programming languages — C++ |id= 14882:2003(E) |edition= Second |date= 2003-10-15}}</ref> 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{{efn|A PDS class can have a base class whose first non-static data members differs.<ref>{{cite book |author= Bjarne Stroustrup |publisher= Pearson Education, Inc |___location= United States of America |title= The C++ programming language |isbn= 978-0-321-56384-2 |edition= Fourth |date= June 2013}}</ref>}} and no virtual functions.<ref>{{cite web |url=http://www.fnal.gov/docs/working-groups/fpcltf/Pkg/ISOcxx/doc/POD.html |accessdate=6 December 2016 |title=C++ Language Note: POD Types |author=Walter E. Brown |publisher=[[Fermi National Accelerator Laboratory]] |date=September 29, 1999 |archive-url=https://web.archive.org/web/20161203130543/http://www.fnal.gov/docs/working-groups/fpcltf/Pkg/ISOcxx/doc/POD.html |archive-date=3 December 2016 |url-status=dead }}</ref> The standard includes statements about how PDS must behave in C++. The <
In some contexts, C++ allows only PDS types to be used. For example, a <
==In Java==
In [[Java (programming language)|Java]], some developers consider that the PDS concept corresponds to a class with public data members and no methods (Java Code Conventions 10.1),<ref name=Oracle>{{cite web|url=http://www.oracle.com/technetwork/java/codeconventions-137265.html#177 |accessdate=6 December 2016 |title=Java Code Conventions 10.1 |publisher=Oracle}}</ref> i.e., a [[data transfer object]].<ref>{{cite web|url=http://www.oracle.com/technetwork/java/codeconventions-137265.html#177 |title=Java Language Data Structures |accessdate=6 December 2016 |publisher=Sun/Oracle Code Conventions |date=April 20, 1999}}</ref> Others would also include [[Plain
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]],
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 (programming language)|Python]], dataclass module provides dataclasses - often used as behaviourless containers for holding data, with options for data validation. The dataclasses in Python, introduced in version 3.7, that provide a convenient way to create a class and store data values. The data classes use to save our repetitive code and provide better readability.<ref>{{cite web | url=https://djtechnews.in/what-are-dataclasses-in-python/ | title=What are Dataclasses in Python? - DJTECHNEWS | date=30 August 2023 }}</ref>
In [[C (programming language)|C]], structs are used in the same manner.
==See also==▼
==Notes==
Line 22 ⟶ 33:
==References==
{{Reflist}}
▲==See also==
▲* [[Plain Old CLR Object]]
[[Category:C++]]
|