Presentation is loading. Please wait.

Presentation is loading. Please wait.

ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming.

Similar presentations


Presentation on theme: "ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming."— Presentation transcript:

1 ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming

2 STYLE PHILOSOPHY The principles of programming style are based on common sense guided by experience, not on arbitrary rules and prescriptions. Code should be clear and simple – straightforward logic, natural expression, conventional language use, meaningful names, neat formatting, helpful comments – and it should avoid clever tricks and unusual constructs. Consistency is important because others will find it easier to read your code, and you theirs.

3 PROGRAMMING STYLE NAMES – A name should be informative, concise, memorable, and pronounceable if possible. Much information comes from context and scope; the broader the scope of a variable, the more information should be conveyed by its name.

4 PROGRAMMING STYLE NAMES – ◦ Descriptive names for globals, short names for locals ◦ Be consistent – related things get related names to highlight their relationship ◦ Use active names for functions ◦ Be accurate.

5 PROGRAMMING STYLE EXPRESSIONS AND STATEMENTS ◦ Indent to show structure ◦ Use the natural form for expression ◦ Parenthesis to resolve ambiguity ◦ Break up complex expressions

6 CS TAPESTRY

7 PROGRAMMING STYLE CONSISTENCY – ◦ Use a consistent indention and brace style

8 PROGRAMMING STYLE COMMENTS – ◦ Don’t belabor the obvious ◦ Comment functions and global data ◦ Don’t comment bad code, rewrite it ◦ Don’t contradict the code

9 P

10 CS TAPESTRY

11 PROGRAM FLOW CONTROL Branches – (if block) ◦ Used to direct program flow through different cases based on tests. ◦ if/else blocks ◦ case blocks Loops – (for loop) ◦ Used to repeat a segment of code based on:  for loop – loops over a segment ‘for’ a specified number of times (counting loop).  while loop – loops over a segment ‘while’ a certain condition is true.

12 RELATIONAL LOGIC

13 COMBINATIONAL LOGIC

14 ERRORS Syntax – semi-colon left out. Runtime – array cell access beyond limit Logical – if/else not correct

15 DEBUGGING Examine the most recent change Don’t make the same mistake twice Read before typing Explain your code to someone else Print statements, print statements,…

16 TESTING Test as you write the code Systematic testing Test automation Stress tests

17 PROGRAM COMPONENTS Functions Subroutines Modules Classes, Objects

18 TOP-DOWN DESIGN

19 FLOW CHART

20 FLOW CHART EXAMPLE

21 PSEUDO-CODE


Download ppt "ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming."

Similar presentations


Ads by Google