Avoiding Newspeak PowerPoint PPT Presentation

presentation player overlay
1 / 13
About This Presentation
Transcript and Presenter's Notes

Title: Avoiding Newspeak


1
Avoiding Newspeak
  • Michael Jones
  • Bournemouth University

2
The Scenario
  • First year Computing unit
  • 20 credits
  • Runs throughout the academic year
  • 85 students
  • 1 hour lecture 2 hour workshop per group of 15
    students
  • Other units include
  • Databases
  • Web Application Development

3
Newspeak in Programming
  • Changing the meaning of something
  • Using different meanings simultaneously
  • Examples
  • Time-based arrays
  • Default properties
  • Hidden dependencies

4
Finding the sum of 10 numbers
  • import java.util.Scanner
  • public class Example
  • public static void main(String argStrings)?
  • throws Exception
  • int sum 0
  • Scanner keyboard new Scanner(System.in)
  • for (int i 0 i lt 10 i)?
  • int number keyboard.nextInt()
  • sum number
  • System.out.println("The sum is " sum)

5
Issues
  • More than 30 concepts
  • Precision
  • Arcane language
  • Contextual
  • Learners assimilation and retention of concepts

6
Time-based arrays
  • Points
  • Collection in specification ('numbers') becomes
    singleton ('number') in code
  • 'number' re-used because of scoping rules
  • 'number' has a different meaning than 'sum' and
    'index'
  • 'numbers' is implemented as a time-based array
  • Only relevant if only one operation is required
  • An advanced example of optimisation
  • The meaning is changed depending on the situation
  • Hence 'newspeak'

7
Second Issue Default properties
  • Specification write a program to read in a list
    of countries the student has visited, and display
    them in alphabetical order
  • Question
  • Variable name of the collection
  • Why is this 'newspeak'?

8
Third issue Hidden dependencies
  • Examples
  • Import of java.lang
  • 'extends Object'
  • 'throws Exception'
  • Why is this newspeak?

9
An Alternative
  • import java.lang.
  • public class Example extends Object
  • public static void main(String argStrings)?
  • throws Exception
  • int numbers 1, 3, 5, 7, 9, 8, 6, 4, 2, 0
  • int sum 0
  • for (int index 0 index lt 10 index)?
  • sum numbersindex
  • System.out.println("The sum is " sum)

10
Another Alternative
  • import java.lang.
  • import java.util.
  • public class Example
  • public static void main(String argStrings)?
  • throws Exception
  • int sum 0
  • ArrayListltIntegergt numbers new
    ArrayListltIntegergt()
  • Scanner keyboard new Scanner(System.in)
  • for (int i 0 i lt 10 i)
  • numbers.add(keyboard.nextInt())
  • for (int i 0 i lt 10 i)?
  • sum numbers.get(i)
  • System.out.println("The sum is " sum)

11
Points
  • Why 2 loops?
  • Fundamental programming 'pattern'
  • Linkage with full specification
  • Read 10 numbers from the user, and find the sum
    of the numbers

12
Pedagogical Points
  • All learning is partial, and inefficient
  • Changes in meaning increase the complexity
  • Additional features can be on the periphery
  • No need to draw attention to them
  • Until student asks a question
  • Until the concepts are to be covered

13
The experience
  • Much more opportunity for reinforcement of the
    relationship between loops and collections
  • More space in the programme for different facets
    of programming (graphics, text processing, etc.)?
  • More opportunity for students to experiment much
    earlier
  • Student response very positive
  • Previous SUE 3.5 current SUE 4.3
  • Previously 70 completion current 90
Write a Comment
User Comments (0)
About PowerShow.com