ENGR/CS 101 CS Session Lecture 2 Tuesday, October 22, is the Annual CECS "Kegger", 5-7pm, Hale basketball courts Starting with the next class, we will be using Visual Studio C#. If you would like to have a copy for your own computer: Lecture 2 All students in EECS classes are enrolled in the UE MS Alliance program. Email with instructions should have been sent at beginning of term. Full Visual Studio 2012 is available. (Windows 8, too.) ENGR/CS 101 Computer Science Session 1 Outline Software life cycle Project 1: Dot Chaser Game Lecture 2 ENGR/CS 101 Computer Science Session 2 Software Life Cycle Specification of the problem/task Analysis and design of a solution Implementation of the solution Testing and debugging Maintenance and evolution of the system Obsolescence Lecture 2 ENGR/CS 101 Computer Science Session 3 Specifications How does the user interact with the program? What are the results of the computation? Lecture 2 ENGR/CS 101 Computer Science Session 4 Analysis and Design How will the program accomplish the specifications? Lecture 2 Identify the data being used Identify the algorithm that will compute the result ENGR/CS 101 Computer Science Session 5 Implementation Use a programming language to implement the program. Syntax: What are the legal "sentences" in the language? Semantics: What do the "sentences" mean? Compilers and interpreters enforce syntax. Semantics determine whether the computation is correct. Lecture 2 ENGR/CS 101 Computer Science Session 6 Compiling vs. Interpreting Some languages are compiled with a program called a compiler. Source code file is translated into a machine code file. Examples: C/C++, Java, Pascal, COBOL, Fortran Other languages are interpreted. An interpreter is a program that receives programming language statements and executes them directly. Lecture 2 Examples: (original) BASIC, LISP, Prolog, LOGO ENGR/CS 101 Computer Science Session 7 Testing and Debugging Testing should try to cover all possible ways a user might interact with a program A bug is a logic error that causes an incorrect result. Debugging is the process of finding and correcting bugs. A debugger is a program that displays the internals of a program as it runs to aid in debugging. Lecture 2 ENGR/CS 101 Computer Science Session 8 Maintenance/Obsolescence It is estimated that 80% of the cost of a software product is expended after the first release. Maintenance includes fixing bugs, adapting to changing environments, increasing functionality Obsolescence is handling the transition when a software product will no longer be available Lecture 2 ENGR/CS 101 Computer Science Session 9 Project 1: Dot Chaser Game A game is specified by Lecture 2 User interactions Rules of the game ENGR/CS 101 Computer Science Session 10 User interactions Game starts with a randomly placed dot. When the user clicks on the dot, it moves to another random place in the game area. Otherwise, the dot is to move periodically to another random place in the game area. User must be able to start and stop the game. User must be able to reset the game. Lecture 2 ENGR/CS 101 Computer Science Session 11 Graphical User Interface (GUI) Design Form – main application window Panel – container that is a subarea of a window Button – control with default action of mouse click Label – area of text, good for displaying results Lecture 2 ENGR/CS 101 Computer Science Session 12 GUI Mockup Form Labels Buttons Panel Lecture 2 ENGR/CS 101 Computer Science Session 13 Game Rules Basic rule: when a user clicks on the dot, her score increases by 1. Some other ideas? Lecture 2 ENGR/CS 101 Computer Science Session 14 Analysis and Design Program = Data + Algorithm Data is the information needed to do the computation. What data do we need for this game? Lecture 2 the score, an integer with initial value of 0 … ENGR/CS 101 Computer Science Session 15 Algorithm Algorithm: a series of well-defined steps that can be followed as a procedure. Example: Move the dot Compute new x and y coordinates Set the x and y coordinates of the dot Example: Update the score Lecture 2 Compute new numeric score Update user interface score ENGR/CS 101 Computer Science Session 16 Algorithm More complex algorithm: Handle a dot click Lecture 2 Update the score Move the dot Reset the timer ENGR/CS 101 Computer Science Session 17 Implementation We will use the C# language. Start with implementing the GUI next time Lecture 2 ENGR/CS 101 Computer Science Session 18