JA

Fundamentals of Programming – Vocabulary Flashcards

Overview of the Course

  • The course focuses on the use of data structures and algorithms to solve computing and real-life problems efficiently.
  • Data structures covered include: dynamic arrays, lists, stacks, queues, trees, graphs, and maps.
  • Analysis of time and space complexity of algorithmic solutions is also covered.

Hardware and Software

  • A computer system is a combination of all components required to process and store data using a computer; it includes hardware and software.
  • Hardware: the physical devices (e.g., keyboards, mice, speakers, printers).
    • Devices are manufactured differently for different sizes of computers (large mainframes, laptops, small embedded devices in products like phones, cars, thermostats).
    • Operations performed by computers are similar across sizes; hardware requires instructions that control input, processing, and output/storage.
  • Software: computer instructions that tell the hardware what to do; programs are instruction sets written by programmers.
    • Can buy prewritten programs stored on disk or downloaded from the Web.
    • You can write your own programs; writing software is programming.
  • When you write software, you are programming; this book focuses on the programming process.

Application Software vs System Software

  • Application software comprises programs used to perform tasks (word processing, spreadsheets, payroll, inventory, games).
    • “Downloaded an app” is shorthand for application software.
  • System software comprises programs that manage the computer (operating systems like Windows, Linux, UNIX; Android and iOS for smartphones).
  • Together, hardware and software accomplish three major operations in most programs:
    • Input, Processing, Output.
  • Data vs Information:
    • Data items are input; after processing, information is produced and output.
  • Storage and Cloud:
    • Output can be stored on storage devices (hard drive, flash, cloud-based storage).
    • Cloud refers to devices at remote locations accessed via the Internet; data on storage devices is not directly readable by people but can be retrieved later.
  • Data can include text, numbers, images, sounds, and user interactions (e.g., touch or gesture data).

Programming Languages and Programs

  • Programs are written in programming languages (e.g., Visual Basic, C#, C++, Java).
  • Source code is translated into machine language by a compiler or interpreter.
  • Machine language (binary) is a sequence of 0s and 1s.
  • The rules governing a language’s word usage and punctuation are its syntax; mistakes are syntax errors.
  • When typing instructions, you typically use a keyboard, and the instructions are stored in memory (RAM, a form of volatile memory).

Computer Memory and Storage

  • RAM (Random Access Memory): internal, volatile memory; used for running programs and data in use; its contents are lost on power loss.
  • Permanent storage devices (nonvolatile): retain data when power is lost (e.g., hard drives, SSDs).
  • If work is recovered after power restoration, it isn’t because RAM retained it; it was saved to nonvolatile storage or autosaved.
  • After typing program statements, they are stored in memory as source code; they must be translated to machine language for execution (object code).

Translation to Machine Language

  • A compiler or interpreter translates source code into machine language.
  • Machine language execution is possible after successful translation.
  • The translation process also reveals syntax errors early via error messages.

Program Development Cycle

  • A programmer’s job goes beyond typing: understanding, planning, coding, translating, testing, production, and maintenance.
  • The program development cycle consists of at least 7 steps:
    1. Understand the problem.
    2. Plan the logic.
    3. Code the program.
    4. Use a compiler/interpreter to translate to machine language.
    5. Test the program.
    6. Put the program into production.
    7. Maintain the program.

Understanding the Problem and Documentation

  • Understanding the problem is aided by documentation: original user requests, sample output, and descriptions of input data items.
  • Documentation helps programmers capture user needs and constraints, especially for mobile apps (mart about evolving requirements).

Planning the Logic

  • The heart of programming is planning the program’s logic.
  • Planning tools include flowcharts and pseudocode; both express steps in English before coding.
  • Pseudocode is an English-like representation of steps; flowcharts are pictorial representations of the same logic.
  • Desk-checking is the process of walking through the logic on paper before writing code.

Pseudocode and Flowchart Standards

  • Pseudocode standards include:
    • Programs begin with start and end with stop; alignment is important.
    • When a module name is used, it is followed by parentheses.
    • Modules begin with the module name and end with return; alignment is maintained.
    • Each statement performs a single action (input, processing, or output).
    • Statements are indented relative to start or module name.
    • Each statement fits on a single line when possible; continuation lines are indented.
    • Statements begin with lowercase letters.
    • No punctuation ends statements.

Flowchart Symbols and Drawing

  • A flowchart uses geometric shapes connected by arrows to show sequence.
  • Input/output: parallelogram symbols contain English text representing input/output operations.
  • Processing: rectangle symbols contain the processing statement.
  • Output is shown with the same I/O symbol as input (parallelogram) because input and output share the same symbol in some conventions.
  • Arrows (flowlines) indicate sequence; flow should typically move top-to-bottom or left-to-right.
  • Flowcharts should include terminal symbols (start/stop) at both ends; racetrack-shaped terminal symbol is standard.

Repeating Instructions and Loops

  • A loop is a repeated sequence of steps; instead of manual repetition, a computer executes the same set of instructions multiple times.
  • Example: program repeats a small set of three instructions many times; a computer can execute the loop many times rather than performing the manual repetition.
  • A simple loop example: the computer gets a number, doubles it, displays the answer, and then repeats from the first instruction.
  • A common practical reason to loop is to process a series of inputs until a termination condition is met.

Sentinel Values and End-of-Data Markers

  • A sentinel (dummy) value ends a program when reached, e.g., entering 0 to stop when doubling numbers; if 0 has legitimate use, a different sentinel value like 999 or –1 can be used.
  • In flowcharts, decisions use a diamond symbol to evaluate a condition; true/false or yes/no outcomes are used.
  • A sentinel value represents an exit point for data input, not real data.
  • Some languages use eof (end of file) markers to indicate the end of data; eof acts as an automatic sentinel when data ends.

Programming Environments and User Environments

  • Planning and coding can be done in plain text editors (e.g., Notepad) or inside an Integrated Development Environment (IDE).
  • Plain text editor advantages: small file size (e.g., a sample program might be around 314 bytes).
  • IDEs provide a richer set of tools: editor, compiler, debugger, etc.
  • IDE features commonly include:
    • Syntax highlighting with different colors for language components.
    • Visual syntax error highlighting.
    • Automatic statement completion.
    • Step-through debugging (execute one statement at a time) to follow program logic and locate errors.
    • IDEs typically require more disk space than plain text editors.
  • Regardless of the tool, the logic planning stage (pseudocode/flowchart) is independent of the coding environment.

Understanding Programming and User Environments

  • Users may run programs in different environments:
    • Command line environment: user types commands to interact with the OS.
    • Graphical User Interface (GUI): user interacts via text boxes, buttons, menus, and graphical elements.
  • A simple number-doubling program might have identical logic whether run at a command line or in a GUI; the interface differs, not the underlying logic.

Evolution of Programming Models

  • Early programming from the 1940s required memory addresses and machine-language-like codes; modern languages are closer to natural language and support abstraction.
  • Modern programs are built from modular components, not written as a single monolithic piece of code.
  • Two major programming models/paradigms:
    • Procedural programming focuses on the procedures (actions) performed on data.
    • Object-oriented programming focuses on objects (things) with attributes and behaviors, which can be composed to form applications.
  • Example of object-oriented design: payroll application thinking in terms of Employees (attributes: name, SSN) and Paychecks (attributes: amount) with behaviors like raises and calculations.

Summary of Key Concepts (Lesson Summary)

  • Computer hardware (physical devices) and software (instructions) accomplish three major operations: ext{input}, ext{processing}, ext{output}.
  • Programs are written in a programming language that requires a specific syntax; they are translated into machine language by a compiler or interpreter.
  • A correctly syntactically and logically designed program can be executed to produce desired results.
  • Correct problem understanding, planning, coding, translation, testing, production, and maintenance are the lifecycle stages of programming.
  • Planning logic uses flowcharts or pseudocode; parallelograms represent input/output and rectangles represent processing; decision diamonds control repetition.
  • Sentinel values can prevent infinite loops; eof markers indicate end-of-data when using file input.
  • Programs can be entered via plain text editors or in IDEs; input can come from command lines or GUI components.
  • Procedural vs. object-oriented approaches reflect different focuses: actions on data vs. objects and their interactions.

Assessment Tasks (Examples)

  • Task 1: Draw a flowchart or write pseudocode for a program that reads a value, multiplies it by 10, and outputs the result.
  • Task 2: Flowchart/pseudocode for a program that, given an edge length of a cube, computes the surface area of one side, the surface area of the entire cube, and its volume; output all results.
  • Task 3: Input hours worked in a day; compute hours in a 5-day week and in a 252-day year; output all results.
  • Task 4: Input two values; output their sum and difference.
  • Task 5: Input current year and birth year; output the user’s age this year.
  • Task 6: a) Input hourly pay rate and hours worked; output gross pay. b) Extend to include withholding tax rate; output net pay after taxes.
  • Task 7: Research current exchange rates; convert a user-entered amount of dollars to Euros and Japanese Yen using a flowchart/pseudocode.
  • Task 8: Timer app: start/stop timer; input elapsed seconds and output minutes and seconds (e.g., 130 seconds -> 2 minutes and 10 seconds).

References (as listed in the transcript)

  • Burd, B. (2021). Beginning Programming with Java for Dummies. (6th ed.).
  • Crutcher, P. (2021). Essential computer science: a programmer’s guide to foundational concepts.
  • Ellison, B. (2022). Java for Beginners: A Crash Course to Learn Java Programming in 1 Week (Programming Languages for Beginners).
  • Horstmann, C. (2019). Core Java: Volume II - Advanced features.
  • Sebesta, R. (2020). Concepts of Programming Languages. (11th ed.)
  • Farrel (2024). Programming Logic and Design, 10th Edition.
  • © 2024 Cengage. REFERENCES