{"id":2270,"date":"2023-12-14T17:56:28","date_gmt":"2023-12-14T16:56:28","guid":{"rendered":"https:\/\/oopm.org\/?page_id=2270"},"modified":"2024-12-15T12:07:35","modified_gmt":"2024-12-15T11:07:35","slug":"data-items","status":"publish","type":"page","link":"https:\/\/oopm.org\/?page_id=2270","title":{"rendered":"5. Data items"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-page pdfprnt-top-right\"><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages2270&print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/pdf.png\" alt=\"image_pdf\" title=\"View PDF\" \/><\/a><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages2270&print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">In this chapter, we describe data-items that may represent references to objects, primitive values, string values, and composite values.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As mentioned in previous chapters, objects may have attributes in the form of data-items that represent properties characterizing the corresponding phenomena. For the <code>Account<\/code> example, we have seen examples of data-items such as&nbsp;<code>owner<\/code>,&nbsp;<code>balance<\/code>,&nbsp;and <code>interestRate<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><strong>class<\/strong> Account(owner: <strong>ref<\/strong> Customer):\n   balance: <strong>var<\/strong> float\n   interestRate: <strong>var<\/strong> float\n   -\"-<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">There is a fundamental difference between the data-items <code>owner<\/code> and&nbsp;<code>balance<\/code>. While <code>owner<\/code> is a <em>reference<\/em> to the object representing the owner of the account (represented by an object of class <code>Customer<\/code>), <code>balance<\/code> represents a property that is given by a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\">float<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-foreground-color\"> <\/mark><em>value<\/em>. We return to this in section <script>mkRef(\"Objects and values\");<\/script>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Some values are denoted <em>primitive values<\/em>, and their types are often predefined. <code>balance<\/code> and <code>interestRate<\/code> are examples of data-items holding primitive values, in this case of type <code>float<\/code>. We have also seen examples of primitive values of type <code>integer<\/code> and <code>boolean<\/code>. We summarise these primitive values below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A phenomenon may also be characterised by values that are composite values constructed from primitive values or other composite values. Examples of this is a date, which consist of a year, month and day all of type integer. Other examples are points, complex numbers, GPS-positions, etc. The type of a composite value is called a<em> composite value type<\/em> or just <em>composite type<\/em>. We describe composite values and types in section <script>mkRef(\"Composite values\")<\/script>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>String<\/code> is another example of a value type. The name attribute of <code>Customer<\/code> was in an early version the class of type <code>String<\/code>. We describe <code>String<\/code> in section <script>mkRef(\"String values\");<\/script>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We use the term <em>datum<\/em> to cover values as well as references. Data-items in general may hold datums and a datum may thus be a value or reference. <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">The tree in the figure shows a so-called classification hierarchy. The nodes in the tree are concepts and the arrows illustrates the relationships between the concepts. As said, a datum may be value or reference. A value in turn may be a primitive value, a string value or a composite value. We further discuss classification hierarchies in section <script>mkRef(\"Representing classification hierarchies\"); <\/script> \nand we show how to represent such hierarchies in a program.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:40%\">\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"489\" height=\"306\" src=\"https:\/\/oopm.org\/wp-content\/uploads\/2024\/12\/datum.jpg\" alt=\"\" class=\"wp-image-10368\" style=\"width:424px;height:auto\" srcset=\"https:\/\/oopm.org\/wp-content\/uploads\/2024\/12\/datum.jpg 489w, https:\/\/oopm.org\/wp-content\/uploads\/2024\/12\/datum-300x188.jpg 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><figcaption class=\"wp-element-caption\">Datum hierarchy<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<div style=\"display:flex; gap:10px;justify-content:center\" class=\"wps-pgfw-pdf-generate-icon__wrapper-frontend\">\n\t\t<a  href=\"https:\/\/oopm.org?action=genpdf&amp;id=2270\" class=\"pgfw-single-pdf-download-button\" ><img src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-generator-for-wp\/admin\/src\/images\/PDF_Tray.svg\" title=\"Generate PDF\" style=\"width:auto; height:45px;\"><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>In this chapter, we describe data-items that may represent references to objects, primitive values, string values, and composite values. As mentioned in previous chapters, objects may have attributes in the form of data-items that represent properties characterizing the corresponding phenomena. For the Account example, we have seen examples of data-items such as&nbsp;owner,&nbsp;balance,&nbsp;and interestRate: There is [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":21,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2270","page","type-page","status-publish","hentry"],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/2270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2270"}],"version-history":[{"count":146,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/2270\/revisions"}],"predecessor-version":[{"id":10452,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/2270\/revisions\/10452"}],"up":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/21"}],"wp:attachment":[{"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}