CST8116 Intro to Comp. Prog. Programming Overview PDF

Summary

This document is a presentation about computer programming concepts. It covers computer systems, programming languages, including the Java language. Also covered is the program development cycle and introduces pseudocode, flowcharts, and other important concepts for the programming process.

Full Transcript

CST8116 Intro. to Comp. Prog. Week 01 Lesson 02 Programming Overview Week 01 Lesson 02 Programming Overview Computer Systems Computer Program Processes Programming Languages Programming Language versus Machine Language What is the Java compilation process...

CST8116 Intro. to Comp. Prog. Week 01 Lesson 02 Programming Overview Week 01 Lesson 02 Programming Overview Computer Systems Computer Program Processes Programming Languages Programming Language versus Machine Language What is the Java compilation process? What is a Variable? What is an algorithm? Program Development Cycle and Software Development Process Pseudocode, Flowcharts Programming Models / Paradigms 2 Welcome This presentation introduces some theory and basic concepts related to computer programming. 3 Computer Systems Computer Systems are composed of two categories Hardware and Software Hardware is the physical parts of the computer and include input and output devices, a Central Processing Unit (CPU), Primary Storage also referred to as Random Access Memory (RAM), and Secondary Storage e.g. hard drive or memory card. Software are the instructions that control how the hardware operates, as well as execute instructions to process data to perform tasks. Software can be broken down further into two categories: System Software like operating system software that controls the hardware, and Application Software i.e. Apps that process data to perform tasks. 4 Computer Program Processes Computer Programs typically follow three processes Input Processing Output Input may come from a user, a keyboard, touch screen, from a file, from the internet etc. Processing are logical steps that act on the data to perform a task, typically to convert data into information. Output is displayed to the user either on a screen, via an audio device, or written to a computer file etc. 5 Programming Languages Programming Languages are used by programmers to create software. There are many different programming languages. In our course we will use the Java programming language. Like spoken and written languages (English, French and more), programming languages have rules for vocabulary and grammar, collectively these are referred to as the languages syntax and are enforced. Like spoken and written languages there are accepted styles, for example starting sentences with an upper case letter, indenting paragraphs and more. Similarly programming languages have accepted styles, these are referred to as programming conventions of the language. (Not enforced but should be used) 6 Programming Language versus Machine Language The CPU within computers only executes instructions in what is known as Machine Language, this is not easily read by people as it consists of sequences of zero’s and ones in patterns understood by the CPU. Programming Languages are written by programmers using an editor, in a human readable format, then a program generally called a Translator converts (translates) the programming language instructions into machine language instructions for processing by the CPU when running the program. The Translator software, is either referred to as a Compiler, or an Interpreter depending on the programming language. The Java programming language uses a Compiler. 7 What is the Java Compilation Process? Figure 1.0 “From Source Code to Running Program” Steps taken in creating and running Java programs: Editor, Source File, Compiler, Class Files and Library Files, Java Virtual Machine, Running Program. Note! Errors in syntax, at run time, or in program logic will result in going back to the editor to fix the problem, then recompiling running and testing again. 8 Time to check your learning! What are the two things computer systems are made of? (Hardware Software) What are the three processes that computer programs follow? (I/O processing) What programming language are we using in this course? (Java) What aspect of a programming language is enforced? (syntax or conventions) What is the language understood by the CPU? (Java or Machine Language) What is the name of the software used to translate Java programs (Compiler) Can we run a Java program before we Compile it? 9 What is an Algorithm? An algorithm is a solution to a problem, as a sequence of steps initiated with one starting point, and finishing at one exit point. Computer programs are algorithms. Each step is referred to as a statement, statements can contain expressions. Example: sum = number1 + number2 sum, number1, number2 are variables. The entire line (starring with sum) is a statement, however the “number1 + number2” is an expression. The = is not equality. Here it instructs the computer to assign a new value into the memory represented by variable sum, after retrieving values from number1 and number2 and assumedly adding them. 10 What is Variable? A name (identifier) used by a programmer to refer to a part of the computers memory to store and retrieve data. Variables generally consist of two types of data, numerical and text. Programming languages usually specialize the data types further. A future lecture will detail Java’s data types. Examples: Age = 23 Name = “Stanley” Note that the presence of the double quotes or absence is important, “23” would be understood by the computer to be text, while Stanley (without the quotes) might be treated as a variable name or may cause an error. 11 Program Development Cycle Your textbook author Joyce Farrell introduces the program development cycle: 1. Understand the Problem 2. Plan the logic 3. Write the code 4. Translate the code 5. Test the program 6. Put the program into production 7. Maintain the program (return to the top if needed and repeat the cycle again) 12 Software Development Process Your textbook by Cay Horstmann introduces a software development process 1. Understand the Problem 2. Develop and Describe an Algorithm 3. Test Algorithm with Simple Inputs 4. Translate the Algorithm into Java 5. Compile and Test Your Program There are similarities to both authors process overviews, Horstmann’s software development process is more closely aligned with our course. While Farrell’s program development cycle is closer to on the job. Both authors are correct, however each place you work may vary slightly in how they develop software. 13 Time to check your learning! What is an Algorithm? What is a Variable? How many steps are there to Joyce Farrell’s Program Development Cycle? Both Farrell and Horstman have the same 1st step, what is it? 14 Pseudocode, Flowcharts, UML Class Diagrams Programmers use pseudocode and flowcharts to plan an algorithm, following from understanding the problem. Pseudocode is brief statements in plain English, like explaining to another person how to solve a problem in steps. E.g. a food recipe Flowcharts do the same thing, but in a diagram format. UML Class diagrams are document blueprints for objects which are used by programmers who are using an Object-Oriented Programming Language (like Java), and will be introduced later in the course. 15 Pseudocode, Flowcharts example This example is taken from your textbook by Joyce Farrell 16 Flowchart Symbols Note that Farrell also uses an Internal module call (not shown), however we will use the External module call symbol in our course instead for any module call. 17 Time to check your learning! What two ways do programmers plan an algorithm? What does the flowchart symbol for a starting point look like? (Circle, Ellipse, Diamond or Square?) 18 Programming Models / Paradigms There are two programming models or paradigms used by programmers Procedural Programming (PP) and Object Oriented Programming (OOP) PP programmers focus on breaking a problem into a sequence of tasks and sub-tasks. OOP programmers focus on objects that group data and behaviors together. Higher level of classification of programming Paradigms is Imperative and Declarative. Imperative programmers are required to detail how the program will process data to get to the result. Both PP and OOP are imperative. Declarative programmers request the software to provide a result, the software determines how to get the result. For example Structured Query Language (SQL) used with database systems is a declarative language. 19 Time to check your learning! What type of programming language is the Java programming language? Imperative, Declarative, Procedural, Object Oriented (or two of these at the same time)? 20 Conclusion In this lesson we reviewed: Computer Systems Computer Program Processes Programming Languages Programming Language versus Machine Language What is the Java compilation process? What is a Variable? What is an algorithm? Program Development Cycle and Software Development Process Pseudocode, Flowcharts Programming Models / Paradigms 21 References Joyce Farrell. 2018. Programming Logic & Design Comprehensive. 9th Ed. Cengage Learning. Chapter 1, pp 1 to 29 Cay Horstmann. 2019. Big Java Early Objects. 7th Ed. Wiley. Chapter 1, pp 1 to 22 22

Use Quizgecko on...
Browser
Browser