1 / 40

Programming for Interactivity

Programming for Interactivity. Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005. Computer Program. A way to get a computer to do something. Programming Language. A way of writing computer programs that is (potentially) comprehensible by people. Interpreted vs. Compiled.

smagoon
Télécharger la présentation

Programming for Interactivity

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 for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005

  2. Computer Program • A way to get a computer to do something

  3. Programming Language • A way of writing computer programs that is (potentially) comprehensible by people.

  4. Interpreted vs. Compiled • Interpreted – one line at a time. • Compiled: Person-> Source Code -> Machine Code -> Computer

  5. Source code • Human-readable text that can be used to make a computer operate in a certain way.

  6. Commenting • A way to get the computer to ignore certain parts of a computer program. • Useful for: • Identifying the function of certain lines of code • Temporarily removing parts of programs • Leaving notes for yourself and others

  7. Object Oriented Programming • Wikipedia – “the idea that a computer program is composed of a collection of individual units, or objects, as opposed to a traditional view in which a program is a list of instructions to the computer.”

  8. Java • A compiled language • An object oriented language • Derived largely from C/C++

  9. Java Source Code /** * Written on Sep 26, 2005 by Bill Tomlinson */ public class MinimalPrintOutProgram { public static void main(String[] args) { //Note: this program is often called "Hello World." System.out.println("Hello there."); } }

  10. Curly Braces • Demarcate different sections of code. • Nested braces { Section 1 { Section 1a } { Section 1b } }

  11. Parentheses • Different from curly braces • Enclose arguments (we’ll get to arguments in a moment)

  12. Semicolons • There’s one at the end of every statement.

  13. Line Spacing • Irrelevant to the computer. • Useful for keeping track of what is going on in complex code.

  14. Classes • These are the objects in “Object oriented programming”.

  15. Fields • Similar to nouns in the English language. • They store data. • Some important data types: • int – a number with no decimal places • float – a number with some decimal places • double – a number with lots of decimal places • String – a group of letters (and numbers) • Give examples

  16. Methods • Like verbs in English • Methods are actions that objects can perform • They manipulate fields and interact with other objects.

  17. Arguments • Methods sometimes include arguments, that is, fields which are “passed in” to the method to allow it to act on them.

  18. Types and Names • Creates a reference to a chunk of memory of a certain type. May or may not put information into that memory space. • int age; • String name = “Bill”;

  19. Arrays • A way of grouping things String [] names = new String[3]; names[0] = “bill”;

  20. Booleans • true or false • boolean myNameIsBill = true;

  21. Loops Lets the program do something over and over again (which computers are very good at). for (int i = 0; i < 5; i ++) { System.out.println(“Round number “ + i); }

  22. Conditionals if (age>18 && liveInUS) { vote(); }

  23. System.out.println(); • A way to print something out. • Useful for debugging.

  24. Three Kinds of Commenting // /* */ /** * * */

  25. // //This line is now commented out // I can also leave myself notes like this.

  26. /* */ /* This kind of comment is useful for commenting out long blocks of code. */

  27. /** /** * *This is yet a third kind of comment. *It is used to describe the content that *is coming next. * * */

  28. Capitalization • By convention: • ClassesAreCapitalizedLikeThis • methodsAreCapitalizedLikeThis • someFieldsAreCapitalizedLikeThis • OTHER_FIELDS_LIKE_THIS • (We’ll get to that distinction later.)

  29. Field and Method Names • Should be descriptive • Long is okay. There are tools in Eclipse that make it easier. For now, even with notepad and javac, make sure to use descriptive names.

  30. Questions about any of the letters? /** * Written on Sep 26, 2005 by Bill Tomlinson */ public class MinimalPrintOutProgram { public static void main(String[] args) { //Note: this program is often called "Hello World." System.out.println("Hello there."); } }

  31. A Longer Example • (From your first assignment.)

  32. Writing Code • You may not (and probably won’t) understand everything about the code you’re working with.

  33. Notepad, Javac and Java • Walk through it together.

  34. Applets • Web based applications. • Require one or more java class files and an html file.

  35. Debugging • Coding is an iterative process. • Debugging is the bulk of the work, especially at first. • Three Kinds of Bugs • Compile time • Run time • Misbehavior

  36. Compile-Time Bugs • Javac will not convert the .java files into .class files. • Need to fix the code before you can even run it.

  37. Run-Time Bugs • Javac will converty the .java files into class files, but the code crashes somewhere. • May crash before the code “works” at all, or it may crash after running for a while.

  38. Misbehavior • Code compiles and runs but… • It doesn’t do what you want. • Part of the challenge is often figuring out why it’s doing what it’s doing.

  39. Assignment 1 • Make a graphical computer program. • You may use BasicGraphicsSystem.java, which I have provided, or you may use this as an opportunity to go learn JOGL or some other graphics system.

  40. If There Is Time Left • Start working on Assignment 1, and I will help out as needed.

More Related