[Year 12 SofDev] Records and Arrays
Don Morelli (Optus)
da_morelli at optusnet.com.au
Thu Aug 19 16:45:16 EST 2010
This discussion is fantastic and I understand and agree with many of the
issues raised. However, it again highlights the need for a set of
definitions that we all adhere to, no matter what our practical experience.
This type of discussion has been raised many times over different
definitions. As teachers, we need to know what is the definition according
to the assessing body and the people who are setting the exam, so that all
students can have the same opportunity at getting exam questions correct no
matter who the teacher is. I know that it would not happen, but I would be
appalled if definitions changed as a result of discussion on this list or
any other list, as these are subscribed to on an interest basis. It would
disadvantage other teachers who are not members of the list (and their
students).
We need to remember that it is the algorithm and knowledge that we are
teaching and will be tested, and not how it is implemented in a particular
language.
Adrian's definition is fine and in my opinion does not need to be changed,
as it clearly distinguishes between two different types of data structures.
Particularly if this is what the examiners are looking for in their
definition of records and arrays. We are possibly using Python next year as
we used good old VB6, but I will deal with the practical side of
implementing these data structures and still teach the "old definitions".
Anyway thanks for the discussion as it makes the job of teaching much more
interesting.
Cheers Don
-----Original Message-----
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Guy Flaherty
Sent: Thursday, 19 August 2010 11:48 AM
To: 'Year 12 Software Development Teachers' Mailing List'
Subject: Re: [Year 12 SofDev] Records and Arrays
Laurie,
I only mentioned it as Adrian had talked about it and I feel it is important
but not part of the ARRAY / RECORD discussion. Wasn't trying to belabor a
point ;)
As for RECORD, I think any definition needs to very clearly differentiate
between the 'common' use of the term and the SD use of the term, as they are
quite different. The SD definition is the 'base' functionality that the type
provides, allowing for data of different types to be stored as a group that
can be referenced using a single pointer. The common use is how we, as
humans, have come to use such a structure, but it in no way is required that
the 'RECORD' type be used in such a way. To give a very poor analogy, a
hammer is usually used for hitting nails and is probably how most people
would think of one if they had to describe it, but it is not required to hit
nails and can be used for other things as well. The problem with trying to
teach what a 'record' is comes when you start to confuse the common use,
such as for database rows and fields, and what it actually is according to
the SD definition, a simple data structure.
The more I think about it the more I feel the current definitions are simple
to understand and explain the differences the best. The trouble is they are
not accurately reflecting what many students will be seeing as they learn
about programming languages. I agree with John, in that if we have to have
them keep them as they are. To answer Adrian's question, I simply feel he
needs to include something that explains how these definitions may not apply
in real world applications. I will have to make a point of explaining to my
students that even though the vast majority of literature states something
is an array (depending on the language you are using), in SD terms it is a
record! Makes sense, right?!
Guy Flaherty
PS. Sorry Adrian, I just got your latest message now :D
>>> "Laurie Savage" <savage.john.l at edumail.vic.gov.au> 19/08/10 11:10 AM >>>
Guy,
I realised I had misused "typing" after sending the messages. I was using it
as shorthand for what we were discussing, which was pretty dumb of me.
Thanks for the extensive coverage of real world usages. I think the concept
of a RECORD has a use in the pencil and paper stages but that is very
different from the SD definition.
Laurie
-----Original Message-----
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Guy Flaherty
Sent: Thursday, 19 August 2010 10:51 AM
To: 'Year 12 Software Development Teachers' Mailing List'
Subject: Re: [Year 12 SofDev] Records and Arrays
Adrian,
An interesting question you are asking there! If you are looking for a
'standard' definition, I am unsure how you can provide one when half of the
approved languages work one way and the other half work in a different way.
If your definition is based on common usage you would likely have to
conclude that there is no 'record' type in real world usage as it is
currently defined, as only Pascal appears to use this structure and names it
as a 'record'. Other languages have similar structures but do not call them
'records', and other languages treat everything as a 'record' according to
this definition and can also use the same structure as an array. In current
usage, an 'array' can only be defined relative to any one particular
language, as what an array can actually do depends on the language.
If I were a student and I saw a definition for an array that stated that
everything I had learned about programming 'arrays' in the language I was
using was not correct, well, I think I would quickly become confused.
If you look at it in terms of language popularity:
1. Java - has array but no record like type (must use a class, so not very
helpful)
2. C - has array but doesn't have 'record' as such, as it is named as
'struct' but fulfills the same purpose
3. C++ - same as C
4. PHP - Has only 'record' type but known only as 'array'. Can be used as
both an 'array' or as a 'record'
In no order (roughly similar real world usage)
C# - very similar to C
VB - very similar to C#
Python - has 'list', 'tuple', & 'dictionary' but all commonly referred
to as 'arrays' when they are in fact either depending on use, according to
SD definition
Perl - very similar to PHP
Objective C - Allows for some use of C 'structs' but names them as
'arrays' when in fact it would be defined as a 'record' in SD (Can be used
as an 'array')
Ruby - very similar to PHP
11. Pascal - Follows the SD definitions fully, and is probably where they
originated as it is the oldest of the languages
Not even used??? Visual Fox Pro - similar to PHP
So, merging that down into a simple definition, such as we are using in the
current study design, of ARRAY and RECORD would seem rather pointless for
the 'newer' languages and completely appropriate for the more 'established'
languages.
To me, RECORD seems totally irrelevant, as it is only ever named that in
Pascal and no other language refers to their type as a 'Record'. An ARRAY
can only be defined relevant to the language you are using, and this is how
I think you should explain it in your book, for real world usage. If the new
study design insists that we continue with the current definitions then that
should be the main explanation given, with an aside about real world usage
and language difference. That would seem to be very relevant for students in
my opinion.
Finally, typing has no relevance in the definitions. It does not matter if a
language uses static or dynamic typing when comparing the current
definitions of ARRAY and RECORD. If you start talking about typing then I
believe you are just going to confuse students even more by including a
totally separate issue.
Guy Flaherty
>>> "Adrian Janson" <janson.adrian.a at edumail.vic.gov.au> 19/08/10 10:01 AM
>>>
Hi everyone,
As the one writing the text book for 2011+, here is what I have written for
the definitions of array and record (there is more detail and examples
following these definitions):
One-Dimensional Arrays
A one dimensional (or 1D) array is a data structure in which variables of
the same type are grouped together under the same name.
...
Records
A record is a structure that can be used to group together a variety of
information for a particular purpose. Records are similar to arrays but
whereas an array has to contain elements all of the same type, the variables
within a record can be of different types.
...
I do think that there is a place for a standard definition - as students
will probably not use 1 language in their lives (assuming that they progress
to an IT course of some description), and even if they don't, the standard
definition can set a context for a discussion of how the language differs
from this (if it is not strongly typed). I don't think it would hurt to say
'the definition of an array is XYZ, however in PHP, an array works in this
way....' Interesting to note that there are 6 languages for which the
definitions above do not strictly hold!
Is the concensus of this community that you would like me to include more in
these definitions about the distinction of strongly typed languages? Or
what is the general feeling about the definitions that I have written above?
Cheers,
Adrian
Adrian Janson B.Sc, Dip.Ed, M.Ed
Director of ICT
Melbourne High School, Forrest Hill, South Yarra, Victoria 3141 Australia.
Phone: 03 9826 0711 International: +61 3 9826 0711
Fax: 03 9826 8767 International: +61 3 9826 8767
E-mail: janson.adrian.a at edumail.vic.gov.au
Website: <http://www.mhs.vic.edu.au/> http://www.mhs.vic.edu.au
Blog: <http://jansona.edublogs.org/> http://jansona.edublogs.org
-----Original Message-----
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Laurie Savage
Sent: Thursday, 19 August 2010 9:23 AM
To: 'Year 12 Software Development Teachers' Mailing List'
Subject: Re: [Year 12 SofDev] Records and Arrays
Guy,
You are right, and of course I have taught this distinction. As I mentioned
to Maggie, I do object to teaching things that students need to unlearn or
that are irrelevant.
Laurie
-----Original Message-----
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Guy Flaherty
Sent: Thursday, 19 August 2010 9:19 AM
To: 'Year 12 Software Development Teachers' Mailing List'
Subject: Re: [Year 12 SofDev] Records and Arrays
Laurie,
Typing is not really the issue, and Steven's explanation is quite likely to
cause more confusion in my opinion. Let me explain my thinking:
The difference between a record and an array is simply that one allows only
one type of data to be used, the other allows multiple types of data to be
used (some languages require type to be declared, others don't).
Associative 'arrays' are called 'arrays' in their language literature, but
according to the study design they are in fact 'records' and not 'arrays'.
Java does not even have a record type, you have to create a class with no
instance methods to represent a 'record' type, so now you have to include
classes if you start thinking about Java. Additionally, other languages,
such as PHP, Python, Ruby etc can do the same thing as Java but are not
required to as their 'array' types can work as 'arrays' or 'records'.
Ruby names their 'record' type an 'array' and their 'associative array' a
'hash', making it even more difficult for students learning Ruby to
understand the Study Design definitions.
Thinking about all this, I am simply going to instruct my students that for
the purpose of completing any exam questions, the difference between a
record and an array IS that one can contain multiple types of data and the
other can only contain one type of data. Despite the fact that this is not
what they are seeing when they do their programming, this is how it would
seem to be best to approach it.
Guy Flaherty
>>> "Laurie Savage" <savage.john.l at edumail.vic.gov.au> 19/08/10 08:39 AM >>>
Well yes, and no. Thanks for the very clear description of a record which IS
an array (is ISBN an integer or a string? PHP will treat it contextually)!
However this does not take away from the fact that some major modern
languages are not strongly typed and so the study guide distinction does not
apply and this disadvantages students working in those languages.
Laurie
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Steven Bird
Sent: Wednesday, 18 August 2010 8:58 PM
To: Year 12 Software Development Teachers' Mailing List
Subject: Re: [Year 12 SofDev] Records and Arrays
The following might help you to distinguish these concepts.
Consider any kind of real world entity, e.g. a student, a school, a book, a
patient, etc. Now think about its attributes. For a book this might be
title, author, year, isbn, price... When we model such an entity using a
computer, we specify a set of attributes. This is a "record". It is just a
collection of attributes describing an entity.
A record could be stored on disk (e.g. as a row of a relational database
table, or as a row of a CSV file), or represented in volatile memory in a
data structure in a running program. Perhaps the most common data type used
for representing a record is an "associative array" ("hash" in Perl;
"dictionary" in Python; "array" (!) in PHP, "map" in C++); some languages
support a "tuple" type which is also appropriate for representing records.
However, at one level these details don't matter. What's important is just
that we have a set of attributes.
Now consider any collection of entities of the same type, e.g. students,
schools, books, patients, etc. When we model these in a computer, we
specify a collection of like entities. This is just a set or list of
entities.
This list could be stored on disk (e.g. as a relational table, or a CSV
file), or represented in a running program. The most common data type is an
"array", and that's what it is called in most languages (but it is "list" in
Python). Some languages encourage you to define array elements to be all of
the same type, but not all. In general, I think this is a good practice.
PHP blurs the distinction between records and arrays. However, a programmer
can use PHP in such a way to keep them quite distinct:
my_record1 = array('isbn'=>1441412050, 'title'=>'Alice in Wonderland',
'author'=>'Lewis Carroll');
my_record2 = array('isbn'=>1441412050, 'title'=>'Through the Looking Glass',
'author'=>'Lewis Carroll');
my_array = array(my_record1, my_record2);
my_record1['isbn']; /* access a record's attribute by name */
my_array[1]; /* access an array's element by index */
I hope this helps!
--
Steven Bird
http://stevenbird.me/
Important - This email and any attachments may be confidential. If received
in error, please contact us and delete all copies. Before opening or using
attachments check them for viruses and defects. Regardless of any loss,
damage or consequence, whether caused by the negligence of the sender or
not, resulting directly or indirectly from the use of any attached files our
liability is limited to resupplying any affected attachments. Any
representations or opinions expressed are those of the individual sender,
and not necessarily those of the Department of Education and Early Childhood
Development.
Scanned by Sonar.
Date: 2010-08-19 08:45:37.693
From: sofdev-bounces at edulists.com.au
To: g.flaherty at xavier.vic.edu.au
Profile: Default_In
Mail id: challenge-2171534856i43-0
"This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the Network Manager
at Xavier College. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent those
of Xavier College. Whilst every attempt has been made to ensure material in
this email message is free from computer viruses or other defects, the
attached files are provided, and may only be used, on the basis that the
user assumes all responsibility for the use of the material transmitted."
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority
and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers
Association Inc
Important - This email and any attachments may be confidential. If received
in error, please contact us and delete all copies. Before opening or using
attachments check them for viruses and defects. Regardless of any loss,
damage or consequence, whether caused by the negligence of the sender or
not, resulting directly or indirectly from the use of any attached files our
liability is limited to resupplying any affected attachments. Any
representations or opinions expressed are those of the individual sender,
and not necessarily those of the Department of Education and Early Childhood
Development.
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority
and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers
Association Inc
Important - This email and any attachments may be confidential. If received
in error, please contact us and delete all copies. Before opening or using
attachments check them for viruses and defects. Regardless of any loss,
damage or consequence, whether caused by the negligence of the sender or
not, resulting directly or indirectly from the use of any attached files our
liability is limited to resupplying any affected attachments. Any
representations or opinions expressed are those of the individual sender,
and not necessarily those of the Department of Education and Early Childhood
Development.
Scanned by Sonar.
Date: 2010-08-19 10:10:44.345
From: sofdev-bounces at edulists.com.au
To: g.flaherty at xavier.vic.edu.au
Profile: Default_In
Mail id: challenge-21766417764bk-0
"This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the Network Manager
at Xavier College. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent those
of Xavier College. Whilst every attempt has been made to ensure material in
this email message is free from computer viruses or other defects, the
attached files are provided, and may only be used, on the basis that the
user assumes all responsibility for the use of the material transmitted."
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority
and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers
Association Inc
Important - This email and any attachments may be confidential. If received
in error, please contact us and delete all copies. Before opening or using
attachments check them for viruses and defects. Regardless of any loss,
damage or consequence, whether caused by the negligence of the sender or
not, resulting directly or indirectly from the use of any attached files our
liability is limited to resupplying any affected attachments. Any
representations or opinions expressed are those of the individual sender,
and not necessarily those of the Department of Education and Early Childhood
Development.
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority
and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers
Association Inc
Scanned by Sonar.
Date: 2010-08-19 11:19:14.444
From: sofdev-bounces at edulists.com.au
To: g.flaherty at xavier.vic.edu.au
Profile: Default_In
Mail id: challenge-21807335425mp-0
"This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the Network Manager
at Xavier College. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent those
of Xavier College. Whilst every attempt has been made to ensure material in
this email message is free from computer viruses or other defects, the
attached files are provided, and may only be used, on the basis that the
user assumes all responsibility for the use of the material transmitted."
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority
and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers
Association Inc
More information about the sofdev
mailing list