Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITM 352 - © Port, Kazman 1 ITM 352 How to Think Like a Programmer.

Similar presentations


Presentation on theme: "ITM 352 - © Port, Kazman 1 ITM 352 How to Think Like a Programmer."— Presentation transcript:

1 ITM 352 - © Port, Kazman 1 ITM 352 How to Think Like a Programmer

2 ITM 352 - © Port, Kazman 2 Coding Tips and Tricks

3 ITM 352 - © Port, Kazman 3 Coding Advice r Know exactly what you want before starting to code r Have some idea of how to implement what you want before writing code r Start small and evolve gradually m Break down into basic parts, simplify, do one part, test, expand until satisfied r Write comment first explaining what is needed then write code to implement it r Do not write too much code before testing r Make a backup of your program after any substantial amount of effort r Backup only “working” versions, if program gets broken, revert to that last known working version

4 ITM 352 - © Port, Kazman 4 Defensive Programming r Always use meaningful variable and file names r Keep code neat, clean, and easy to read AS YOU GO r Follow code formatting conventions (e.g. indent under if and loop statements) r Anticipate errors! Always expect data may be bad or invalid – test to ensure data is valid when first used. r Add “debugging” statements (e.g. print out important variable values) – comment out when not needed r Think of small validation tests as you go and perform tests – make sure you get what you expect at every step

5 ITM 352 - © Port, Kazman 5 Follow Along Exercise Participation is MANDATORY – you are expected to ask questions and make suggestions!

6 ITM 352 - © Port, Kazman 6 Programming from Concept to Testing r Concept: write a program that prints a 2D “star field” *…*.*…*…* …*…**..*….*.*…*….*.* Basic S teps F or starting a program from scratch: 1. Establish objectives, constraints, and priorities 2. Build simple prototype (esp. UI) 3. Negotiate requirements 4. Analyze information and data needs 5. Design program structure (modules, algorithms, …) 6. Implement designs (code) 7. Test and debug

7 ITM 352 - © Port, Kazman 7 1. Establish Objectives, Constraints, and Priorities Objective 1: Working program that displays stars on screen Objective 2: Some form of user adjustable parameters (e.g. length and height, density, different characters) Constraint 1: Complete in less than 20 mins. Constraint 2: use only PHP and HTML Priorities: - Objective 1 is top, 2 is “if there is time”

8 ITM 352 - © Port, Kazman 8 2. Build a Simple Prototype

9 ITM 352 - © Port, Kazman 9 3. Negotiate Requirements - User interface? - Max / min number of stars? - Density definition?

10 ITM 352 - © Port, Kazman 10 4. Analyze Information and Data Needs

11 ITM 352 - © Port, Kazman 11 5. Design Program Structure (Modules, Algorithms, …)

12 ITM 352 - © Port, Kazman 12 6. Implement Designs (Code)

13 ITM 352 - © Port, Kazman 13 7. Test and Debug


Download ppt "ITM 352 - © Port, Kazman 1 ITM 352 How to Think Like a Programmer."

Similar presentations


Ads by Google