How to Program - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

How to Program

Description:

A program is gobbledygook written in something called Java that is picky about ... Just like Blue Peter.. I have this one I did earlier over here. G52PQI ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 34
Provided by: daveel1
Category:

less

Transcript and Presenter's Notes

Title: How to Program


1
How to Program
  • Dave Elliman

2
I am confusedWhat is a program?
  • Prof Roland Backhouse
  • A program changes the truth state of a set of
    predicates such that certain axioms on the pre
    and post state are true
  • Dr Graham Hutton
  • A program is a notation for evaluating
    mathematical functions using a computer

3
I am confusedWhat is a program?
  • Dr Colin Higgins (Teaching LOG)
  • A program is an expression in mathematical logic
    written using Horn clauses
  • A Student
  • A program is gobbledygook written in something
    called Java that is picky about every stupid
    semi-colon and which makes no sense at all to me.

4
I am confusedWhat is a program?
  • Alan Turing
  • A program is a sequence of instructions which may
    be executed on a Turing Machine
  • Ada Lovelace
  • We may say most aptly that the Analytical Engine
    weaves algebraical patterns just as the
    Jacquard-loom weaves flowers and leaves.

5
I am confusedWhat is a program?
  • Dave Elliman (Lecturing CSA)
  • A program is a sequence of machine instructions
    which include arithmetic and logical operations
    and which may move data between memory locations
    and which may test and change the machine state
    including the state of the next instruction to be
    executed
  • Dave Elliman (Teaching C programming)
  • A program is a list of instructions. It is a lot
    like a recipe, or the instructions that come with
    flat-pack furniture

6
Who is right?
  • Everybody is
  • Programs can be all these things
  • Alan Turing is the most right
  • From the Java point of view we need a different
    perspective
  • Programming is about the design and interaction
    of objects
  • But Objects are programs too

7
Did that help you?Are you still confused like
Pat?
8
Or Like Me
  • Learning FORTRAN on day release from Rolls-Royce
    at Derby Tech College
  • I I 1 ?!??

9
I understand the Syntax of Java
  • Some student comments
  • I understand the lectures but what is Java for?
  • Where do I start?
  • I have broken the computer!
  • The computer wont run my program properly!

10
You need a conceptual FRAMEWORK that works
  • Programming is too hard
  • Human beings can only do easy things
  • Human beings make mistakes all the time
  • You have to check what they do carefully
  • Programming has to fit your skills

11
A More Useful Definition of a Program
  • A program does things that you can talk about in
    stories
  • Start by writing short stories about what someone
    using your program will do
  • These are called Use Cases and have a UML
    diagram

12
A More Useful Definition of a Program
  • A program is a model of the world
  • Imagine it as a thing with knobs on
  • The knobs are thing pressed in the user stories
    they will tell you what is needed
  • Think what parts your model needs
  • Make them simple
  • Think how they work
  • What do the knobs, buttons and lights do
  • How could you test it was working right?
  • Dont even think about code for a long time

13
What do you come up with using this approach?
  • A Box which does something
  • An Interface on the Box which makes it work
  • Then think what is needed inside the box to make
    it work
  • A state (ingredients)
  • Instructions (what to do next)

14
Modelling the State
  • My box needs to hold the height of the Duke of
    Edinburgh in metres
  • What sort of variable is this? (TYPE)
  • My box needs to hold the number of times button
    A has been pressed today
  • My box needs to hold the name of a student
  • My box needs to model whether the sun is shining
    or not?

15
Types
  • These are provided for you to model real things.
    You just choose the right type
  • A Harder one My Box needs to hold the turnover
    of my company in pounds and pence. It is a BIG
    company.

16
So what are Classes
  • These are the boxes in your model
  • The methods you use are the interface
  • In Java you can have several interfaces for a
    class. This can be neat.

17
What is Inheritance
  • It gets tedious always building a box from
    scratch
  • You can use something like what you need but
    simpler and add the bells and whistles
  • Just like Blue Peter..
  • I have this one I did earlier over here

18
How do I decide on the Boxes to use in my Model
  • Make it beautiful
  • One Big Object with everything on it is ugly
  • Lots of tiny little objects is a horrible rats
    nest
  • Maximise Cohesion, minimise Coupling, hide
    complexity
  • Use real things as your objects
  • An Object will have some state to model inside
    it. Otherwise it is not an object

19
What is the simplest useful story?
  • Design your model to do just this simple thing.
  • Anything harder will confuse you and take too
    long
  • Think how you will know if it works
  • Write a test for that in words
  • Go on then code something now

20
Most People think in Pictures
  • That is one reason why mind-maps can be helpful
  • Pictures are very useful for designing and
    documenting software
  • UML has some useful diagrams
  • Get ArgoUML its free!
  • http//argouml.tigris.org/

21
A program that needs to be written
Plagiarism is a nuisance to a Lecturer!
22
How do we start?
  • Step 1 Say in a sentence or two what the
    application will do
  • Step 2 Give it a name

23
I came up with
  • This application will take coursework submitted
    by a students and check if it has been copied
    from web pages.
  • I will call it Plagiarism Detector
  • OK thats not very imaginitive.

24
At this point many questions will taunt you
  • Will it check if students have copied from one
    another?
  • What file formats will it read?
  • Will it run on PCs, Macs, Linux, Solaris?
  • What programming language will I use? Etc..

25
Too many questions paralyse progress
  • I will do the simplest thing that is useful and I
    will make it work
  • If a question has popped up to soon I will say
    undecided! and leave it for now
  • Make everything as simple as possible. Small IS
    beautiful.

26
Answers
  • Will it check if students have copied from one
    another? NO. (not yet)
  • What file formats will it read? .txt
  • Will it run on PCs, Macs, Linux, Solaris?
    undecided
  • What programming language will I use? Etc..
    undecided

27
Make up user stories
The students assignments are placed in a
directory. The Plagiarism Detector Application is
started. The folder is selected in an open file
command. All selected files are checked for being
copied from web pages and a report generated for
the lecturer
28
More questions
  • What will the user-interface look like?
  • How will it discover whether the work has been
    copied from the web?
  • How will all the assignments arrive in this
    directory?

29
Some Tentative Answers
  • What will the user-interface look like? Very
    simple file open dialog box
  • How will it discover whether the work has been
    copied from the web? Same as how you do it
    Dave?
  • How will all the assignments arrive in this
    directory? Not my problem! (safileup?)

30
Lets Design the Program Then
  • First.. Can we may it any simpler?
  • YES! Lets just do one file for now
  • What was the output going to be?
  • Yes or No!

31
What are the Objects?
  • Things in the real world
  • Things that have a state and a behaviour
  • Things that have an interface and complexity
    hidden inside

32
How on earth can a program look up something on
the web?
  • This is an algorithmic part
  • Easy it can use Google
  • It could web scrape (illegal)
  • It could use the API
  • It could use a web service (XML)

33
Conclusion
  • Can you see the process from idea to objects?
  • That is most of what programming is about
  • The GUI
  • Clever (but not too clever) algorithms
  • Testing
Write a Comment
User Comments (0)
About PowerShow.com