Passive data structure: Difference between revisions

Content deleted Content added
m Fix Linter errors.
 
(12 intermediate revisions by 10 users not shown)
Line 1:
{{Short description|Another term for record}}
{{confused|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 (computer science)|record]], toin 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>
 
==Rationale==
Line 12 ⟶ 13:
==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 old Java object]]s (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|date=February 2010}} However, POJOs and Java Beans have [[encapsulation (computer programming)|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 <code>stdClass</code> objects can be considered PDS.{{citation needed|date=September 2019}}
 
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==