1 / 24

Programming

Programming. Objects Methods and Instantiation. Programming. Programming is the act of writing instructions that tell a computer how to do something. This module is a starting point into a huge topic You will almost certainly not get this on the first attempt

Download Presentation

Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Objects Methods and Instantiation

  2. Programming Programming is the act of writing instructions that tell a computer how to do something. This module is a starting point into a huge topic You will almost certainly not get this on the first attempt I assume no prior knowledge of programming In this first lecture we will consider… • How we may use a system of notation to control computer technology • How objects may be used to represent and control computer technology via methods and properties • The relationship between an object and a class and how instantiation creates an object from a class

  3. Sending a Simple Instruction to a Computer I want the computer to shut down How would I do this? (Use of my senses) How would I tell one of you to do it? (Use of natural language) How do we tell the computer to turn itself off?

  4. Natural Language and Computers “ok computer turn your self off now” • Does the computer understand the words we have used? • Strong regional accents? • Consider the following… • Off computer turn now • OK puter turn theselov now • Cmptrtrnyrslf ff nw • Natural language allows for ambiguity and imprecision • Computers are really quite thick

  5. Computer Programming and Music • Parallels may be drawn between programming a computer and playing an instrument. • (It is my observation that many programmers are also musicians) • With music we have the same problem as with a computer • How do we tell the instrument / musician what it is we want to hear?

  6. What is this?

  7. Add the words…

  8. Music Notation as a Program • Once you understand the rules you may create / play music of varying complexity • The same tune may be reproduced on different instruments • The basic rules are very simple • The staff indicates the pitch of the sound… • The shape of the notes tell us how long they should be played for… • Sequence matters!

  9. Symbols and Meaning • We use symbols all of the time in our daily life • “Represents” the tune “three blind mice” but it isn’t the tune De Montfort University The Gateway Leicester LE1 9BH • Represents the address but it isn’t the place

  10. Understanding the Symbols • Understanding the symbols is the first problem you will face in learning how to program

  11. Which Code is Correct? DimMyAgeAsInteger MyAge = 23 IfMyAge > 21 Then lblError-Text = "You are old enough" EndIf Or… DimMyAgeAsInteger MyAge = 23 IfMyAge > 21 Then lblError.Text = "You are old enough" EndIf

  12. Computer Programming We want to create: • A system that accurately identifies the individual components in a computer so we may control them • A system that may be used to set the sequence of instructions such that they are carried out in the way we intend • A system of representation that is easy to maintain avoiding unnecessary duplication and excess baggage • Something that is reasonably easy for us as human beings to write and understand (we don’t want the symbols to get in the way of the meaning)

  13. Objects, Classes, Methods, Properties and Instantiation • Lots of new terms to understand • Objects provide tools for referencing and controlling bits of the computer • Classes are the “recipes” that define objects • Methods tell objects to do something • Properties control the settings of an object • Instantiation is the act of making an object out of a class

  14. Cuba the Cat - Properties Legs 4 Tails 1 Ears 2 Fangs 3 Properties tell us how the object is set up

  15. Cuba the Cat - Methods Release - let Cuba outside Feed - give Cuba some food Scoop - clean up after Cuba • Methods make the object do something

  16. The Computer as an Object • Properties and methods not about Cats • We want to represent and control the computer • View the computer system as a set of objects • We may think of the computer expressed as an object MyComputer.TurnOff() • MyComputer represents the entire computer • TurnOff is a method that turns the computer off • Starting to develop a system of notation rather like musical notation

  17. Classes • Classes contain the code defining an object

  18. Instantiation • Takes the recipe contained in the class and makes an object we may use

  19. The Computer System • We will be looking at a range of objects and classes allowing us to control different parts of the computer system • The screen (buttons, text boxes and lists) • The RAM (variables) • A Database (DataConnection class) • + others • Also look at control structures (assignment, functions, loops, if statements)

  20. The Three Layer Architecture

  21. Overview • Don’t get bogged down in the detail! Programming is the act of writing instructions that tell a computer how to do something We need a standard system of notation allowing us to represent what the computer is to do that makes reasonable sense to human beings

  22. Important Key Concepts Object A way of representing computer technology so that we may control it Method Used to tell an object to do something Property Used to find out or control something out about the object Class The definition for an object Instantiation The process of making an object from a class

  23. Computer System Split into Layers • The Presentation Layer – the part the user interacts with • The Middle Layer – containing classes allowing us to do things • The Data Layer – where are database is stored

  24. Finally… There is one final way in which programming is like music! Both require constant hands-on practise! You must do the work! You will not learn how to program on the first second or third attempt You must practise and refine your skills

More Related