1 / 23

Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology

Introduction to Programming <Lecture 1>. Spring 2014. Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology. Basic Components of a Computer. Computer : machine that performs different tasks according to specific instructions. It has two major components:

ursa
Download Presentation

Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology

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. Introduction to Programming <Lecture 1> • Spring 2014 Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology

  2. Basic Components of a Computer • Computer: machine that performs different tasks according to specific instructions. • It has two major components: • Hardware: composed of electronic and mechanical parts • Software: data, and computer programs Rommel AB Palomino - UDC Spring 2014

  3. Hardware Rommel AB Palomino - UDC Spring 2014

  4. Software Types of Computer Programs: • Operating Systems: Windows, Linux, Solaris • Application Programs: Word, Games, Browsers • Compilers: Translate high level programming languages into machine language Rommel AB Palomino - UDC Spring 2014

  5. Programming Languages • What is a Programming Language? • Express human instructions to computers • Each language has its own syntax • Languages evolved over time. There exist five different programming languages generations. Rommel AB Palomino - UDC Spring 2014

  6. Interpreted vs. Compiled Language • Interpreted: Source code is directly executed at runtime by the interpreter. • Compiled: source code goes to the compiler and creates object code or machine code. Then it is executed in the host CPU. Rommel AB Palomino - UDC Spring 2014

  7. Interpreted vs. Compiled Language Compiled • Needs compilation every time you change the code. • Hard to debug • Compiled language is faster because source code is reduced to machine code, and then is executed. • Interpreted • Easy to develop • Easy to debug • Slower to execute because source code is directly executed (“interpreted”) at runtime Rommel AB Palomino - UDC Spring 2014

  8. Generation Languages • Human • Machine Sixth Generation: ??? 5GL or Fifth Generation: use of constraints rather than an algorithm. Comp. solves problem w/o prog. Use in AI research such as ProLog. 4GL or Forth Generation: reduce programming effort, developing time, and cost. 3GL or Third Generation: more programmer friendly. High level lang. such as C, C++, Java. 2GL or Second Generation: Assembly languages. push ebx / mov ebx,1 / decebx 1GL or First Generation: Machine Language (0110101100110000011) Rommel AB Palomino - UDC Spring 2014

  9. Program Development Life Cycle • The process of developing a software, according to the desired needs of a user, by following a basic set of interrelated procedures. Rommel AB Palomino - UDC Spring 2014

  10. Tasks of Program Development Rommel AB Palomino - UDC Spring 2014

  11. Tasks of Program Development • Define clearly the problem in terms of their inputs, outputs and constraints. • A clearly defined problem is half the solution. • This step is very critical for success of the completion of the program. Problem Example: “Create a Program that will give the sum of consecutives numbers from 0 to a determined number” • Invest a significant portion of your time in this phase! Rommel AB Palomino - UDC Spring 2014

  12. Tasks of Program Development • Once identified the problem, we should find the most effective and simplest solution. • Divide and Conquer: Break problem into smaller and simple sub-problems Problem Example: “Create a Program that will give the sum of consecutives numbers from 0 to a determined number” Input: certain natural number (n) Output: sum of consecutive natural numbers from 0 to n Rommel AB Palomino - UDC Spring 2014

  13. Tasks of Program Development • After doing the analysis, we need to design our proposed solution. • The solution has to be expressed in a step-by-step manner, so the computer will understand it: Algorithm. • Ways of representing it: • Human Language: flowchart • Pseudocode: human lang/prog. lang. • Design techniques: • Modular Programming • Top-Down Design • Structured Programming Rommel AB Palomino - UDC Spring 2014

  14. Pseudocode • Get number “n” • Set count to 0 • Set sum to 0 • While count is less than or equal to “n“ do • Add count value to sum • Increment count by 1 • Return sum Problem Example: “Create a Program that will give the sum of consecutives natural numbers from 0 to a determined number” Rommel AB Palomino - UDC Spring 2014

  15. Flowchart Process: represents process of executing an or group of operations that results in a change of value, form or location of information. i.e.: Add 1 to X Sum = sum + 1 Process Data: Input/output. i.e.: Read N Get N Display X Data Cond Conditional: Yes/No questions. It has two outputs, one for Yes, and one for No. Rommel AB Palomino - UDC Spring 2014

  16. Flowchart Flowline symbol: Represents the flow of information or the correct sequence of steps in the flowchart. Connector: Connects parts of flowcharts. Terminal Terminal Symbol/Terminator: Represents the start or end point of a flowchart. Rommel AB Palomino - UDC Spring 2014

  17. Flowchart Problem Example: “Create a Program that will give the sum of consecutives natural numbers from 0 to a determined number” Start Read n count = 0 sum = 0 count<=n? no Print sum yes sum = sum + count count = count + 1 End Rommel AB Palomino - UDC Spring 2014

  18. Tasks of Program Development • Algorithm ready! • Process of translate it into computer instructions. • Each prog. language has its own syntax. • Actual software. Start Read n count = 0 sum = 0 int n = 5; // let’s pretend we are reading int sum =0, count = 0; while( count <= n ){ sum = sum + count; count = count + 1; } System.out.println(sum); count<=n? no Print sum yes sum = sum + count count = count + 1 End Rommel AB Palomino - UDC Spring 2014

  19. Tasks of Program Development • Don’t expect your program works the first time! • Debugging: finding errors (bugs) in your program and fix them. • Two error types: • Compile-time: before running your program. Syntax errors. • Runtime: occurs when you are running your program Compile-time error: int n = 0 Runtime error: int n = 0; int x = 5/n; Division by zero! Rommel AB Palomino - UDC Spring 2014

  20. Tasks of Program Development • Testing: process of validation of the program. Three major types: • Unit testing: test basic units of software • Integration testing: tests two or more tested units • System testing: based on functional/requirement specification Is my program really doing what it was required to do? Look back into your requirements, and your problem definition! Formulate basic tests. i.e. entering the min and max values for parameters. Rommel AB Palomino - UDC Spring 2014

  21. Tasks of Program Development What if your requirements change? • Maintenance: • Updating and correcting of the program for changing conditions or newly discovered bugs. What if your boss wants to add more functionality to your program? Should I start all over again from scratch? NO!!!! … as long as you do all your previous steps correctly  Rommel AB Palomino - UDC Spring 2014

  22. Exercise • Write a program that can calculate the factorial of a given number “n”. Rommel AB Palomino - UDC Spring 2014

  23. Questions? Rommel AB Palomino - UDC Spring 2014

More Related