1. Home
  2. Explore
  3. Computer Science
  4. Introduction to Programming

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to Programming

Introduction to Programming and Computers

What Makes Computers Special?

Most machines are designed to perform one primary task. Their physical mechanisms determine what they can do.

  • A traditional car engine converts fuel energy into movement by igniting fuel and moving pistons.

  • A traditional sewing machine moves a needle and fabric according to preset settings.

  • Once these machines are configured, their basic purpose remains limited to the task for which they were designed.

A computer is different because it is a general-purpose machine. It can perform many different tasks when given different instructions. The same physical computer can browse the web, stream video, edit documents, run games, or communicate with other devices.

For example, while watching a video, a computer may perform several tasks:

  1. Access a website or application.

  2. Send a request for the selected video.

  3. Receive the video as packets of digital data.

  4. Process the data.

  5. Display the images on the screen.

  6. Output the accompanying audio.

The computer does not need to be physically rebuilt for each task. Instead, it receives new instructions through software.

Computers Are Found in Many Devices

Computers are not limited to desktop and laptop machines. They are present in many modern devices, including:

  • Smartphones

  • Cars

  • Sewing machines

  • Musical instruments such as pipe organs

  • Home appliances

  • Industrial equipment

  • Embedded control systems

A computer may be included even in a device with only one main purpose. Using a computer can be simpler and more flexible than designing a large custom electronic or electromechanical system for every possible function. The device’s behavior can be controlled by changing its instructions rather than redesigning its physical components.

A computer is a machine whose capabilities can be changed or expanded by giving it different instructions.


Programming, Programs, and Software

Programming

Programming is the act of creating a set of instructions that enables a computer to perform a task or gain new functionality.

A programmer writes instructions that tell a computer:

  • What actions to perform

  • In what order to perform them

  • How to respond to different situations

  • How to interact with users and other programs

  • How to process and produce information

Installing an application gives a computer new functionality because the application contains instructions that the computer can follow.

Examples of programmed software include:

  • Web browsers such as Firefox and Chrome

  • Mobile applications

  • The Canvas application

  • File Explorer

  • Video games

  • Operating systems such as Windows, iOS, and Android

Programs

A program is a set of instructions that a computer can follow to accomplish a task. When the computer runs a program, it executes those instructions.

The terms program and software are closely related, but they can be used somewhat differently:

  • Program: Often refers to a particular set of instructions or application.

  • Software: A broader term referring to programs and related computer instructions generally.

A web browser, mobile app, file-management utility, and video game are all examples of programs and software.

Operating Systems

An operating system is a major piece of software that manages a computer and allows users and other programs to interact with it.

Examples include:

  • Microsoft Windows

  • Apple iOS

  • Android

The operating system itself consists of instructions that the computer follows. It manages resources and provides the basic environment in which other programs run.


User Interaction

Many programs allow users to interact with them. User interaction occurs when a person provides input or responds to information displayed by the program.

Common forms of interaction include:

  • Typing text into a form

  • Clicking a button

  • Selecting an option

  • Tapping an icon

  • Entering information into an application

  • Viewing images, messages, or results

For example, when a user schedules a medical appointment online:

  1. The user types information into a form.

  2. The user clicks buttons or selects options.

  3. The web browser receives the user’s actions.

  4. The browser sends the information to a web server after submission.

  5. The server processes the request and returns a response.

The browser and server perform complex communication behind the scenes, but the user experiences the process through visible controls such as text fields and buttons.

Programs created in Visual Basic emphasize user interaction. They commonly allow users to enter information, click controls, and receive results through a graphical interface.

Programmer

A programmer is a person who creates programs by writing instructions for computers.

A programmer:

  • Analyzes a task or problem

  • Designs a possible solution

  • Writes instructions in a programming language

  • Tests the resulting program

  • Corrects errors

  • Improves the program

  • Delivers a usable solution to users

In simple terms, a programmer programs a program so that a computer can perform a task.


How Computers Represent Instructions

Binary

Computers process information using electrical signals. At the lowest level, these signals have two basic states:

  • On

  • Off

These two states are represented using binary digits, commonly called bits. A binary digit can have a value of 000 or 111. Groups of binary digits can represent numbers, text, images, sounds, and instructions.

Computers do not understand human language in the same way people do. Ultimately, the instructions executed by a computer must be represented in a form the computer’s hardware can process: binary machine instructions.

Machine-Level Instructions

At the machine level, a computer executes individual instructions represented in binary. These instructions specify actions such as:

  • Moving data

  • Performing calculations

  • Comparing values

  • Reading input

  • Writing output

  • Controlling other operations

Writing directly in binary would give a programmer very precise control over every operation, but it would be extremely difficult and time-consuming.


Binary and Assembly Language

Advantages of Low-Level Programming

Writing instructions close to the machine’s binary representation provides precise control.

Potential advantages include:

  • The programmer knows exactly which instructions are being executed.

  • Every operation can be manually selected.

  • The program can be highly optimized for speed or memory usage.

  • Hardware-specific behavior can be controlled very precisely.

For specialized tasks requiring maximum performance or exact hardware control, programmers may still use low-level languages such as assembly language.

Disadvantages of Binary Programming

Programming directly in binary has significant disadvantages:

  • Binary instructions are difficult for humans to read.

  • Large amounts of binary may be required for even simple tasks.

  • Small mistakes can be difficult to locate.

  • The code is difficult to understand and maintain.

  • Building common features requires writing many individual instructions.

  • Long periods of working with binary can cause eye strain and hand strain.

For example, creating a graphical window in binary would require manually writing instructions for many separate operations:

  • Displaying the window

  • Drawing images

  • Detecting mouse input

  • Determining where the mouse was clicked

  • Deciding whether the click occurred on a button

  • Responding appropriately to that click

This would require a large amount of detailed code.

Assembly Language

Assembly language is a low-level programming language that uses somewhat more human-readable symbols and words instead of raw binary. Assembly instructions are translated into machine-level binary instructions.

The general process is:

  1. The programmer writes instructions in assembly language.

  2. An assembler translates those instructions into binary.

  3. The resulting machine instructions are provided to the computer.

  4. The computer executes them.

Assembly is easier to read than raw binary, but it is still much more difficult to use than modern high-level programming languages. Programmers using assembly often need extensive reference documentation describing the available instructions and their exact usage.


Programming Languages

A programming language is a structured language designed to let humans write instructions that can eventually be translated into machine instructions.

Programming languages are more human-readable than binary or assembly language. They use recognizable words, symbols, and structures that are easier to remember and organize.

Examples include:

  • C

  • C++

  • Java

  • JavaScript

  • Python

  • Visual Basic

A programming language does not necessarily understand ordinary conversational sentences. A programmer must still follow the language’s rules for:

  • Vocabulary

  • Syntax

  • Organization

  • Data

  • Operations

  • Control flow

However, a programming language can combine many low-level operations into a simpler command. Instead of manually writing hundreds of machine instructions, the programmer may use a single higher-level instruction that represents a common task.

Benefits of Programming Languages

Programming languages make software development easier because they:

  • Reduce the amount of code needed for common tasks

  • Use words and structures that are easier for humans to understand

  • Make programs easier to write

  • Make programs easier to revise

  • Make errors easier to find

  • Allow programmers to build more complicated software

  • Hide many unnecessary hardware details

Programming languages have made it practical to create large systems such as web browsers, mobile applications, operating systems, and internet services.

Translation into Binary

Code written in a programming language must eventually become machine instructions. This translation may happen in different ways.

Compilers

A compiler translates source code into an executable or other machine-oriented form before the program runs.

The general process is:

  1. The programmer writes source code.

  2. The compiler analyzes and translates the source code.

  3. The compiler produces an executable program or another translated form.

  4. The computer runs the translated instructions.

Visual Basic commonly uses a compilation process.

Interpreters

An interpreter reads and executes code while the program is running. Rather than translating the entire program into an executable file ahead of time, the interpreter processes the instructions as needed.

The important distinction is:

  • Compiler: Translates code before execution.

  • Interpreter: Reads and performs code during execution.

Regardless of the approach, the computer’s hardware ultimately performs operations represented in machine-level instructions.


Programming Language Paradigms

A programming paradigm is a general style or way of thinking about how programs should be designed and organized.

Paradigms influence how programmers represent problems and how the parts of a program interact. One important paradigm is object-oriented programming.


Object-Oriented Programming

Core Idea

Object-oriented programming, often abbreviated as OOP, organizes a program around objects rather than only around a sequential list of instructions.

A purely step-by-step approach might describe a program as:

  1. Perform task A.

  2. Perform task B.

  3. Perform task C.

An object-oriented approach instead identifies objects and describes how they interact:

  • An application object interacts with button objects.

  • A button object responds when a user clicks it.

  • The button object communicates with the application.

  • The application performs the appropriate task.

The program is therefore modeled as a collection of objects that have properties, perform actions, and interact with one another.

Objects

An object is something represented within a program that can be seen, used, or interacted with.

Examples of program objects include:

  • A window

  • A button

  • A student

  • A teacher

  • A class section

  • An assignment

  • A list of students

  • A graphical control

Objects commonly have three important characteristics:

  • Properties: Information or characteristics associated with the object.

  • Behaviors or procedures: Actions the object can perform.

  • Interactions: Ways the object can communicate with or respond to other objects.

For example, a button might have:

  • A text label

  • A position on the screen

  • A size

  • A color

  • A procedure that runs when the button is clicked

Objects can also control access to their behaviors. Some actions may be available to other objects, while other actions may be restricted so that only the object itself can perform them.

Classes

A class is a pattern or blueprint used to create objects.

A class defines:

  • The properties each object of that type will have

  • The actions each object can perform

  • How the object can interact with other objects

  • Which operations are available to outside objects

  • Which operations are restricted internally

For example, a Teacher class could define that every teacher object has:

  • A name

  • An employee identification number

  • A list of courses taught

  • The ability to teach students

  • The ability to grade assignments

The class itself is the design or definition. It is not necessarily one specific teacher.

Instances

An instance is one individual object created from a class.

For example:

  • Teacher is a class.

  • A particular teacher created from that class is an instance of Teacher.

  • Student is a class.

  • A specific student enrolled in a course is an instance of Student.

A class can be used to create many different instances. Each instance follows the same general pattern but can contain different property values.

Instantiation

Instantiation is the process of creating an object from a class.

When a programmer asks Visual Basic to create an object based on a class, Visual Basic creates an instance of that class. The new object receives the properties and behaviors defined by the class.

The relationship can be summarized as:

  • Class: Blueprint or pattern

  • Instantiation: Creation process

  • Object or instance: Specific thing created from the blueprint


Object-Oriented Example: An Academic System

An academic information system can be modeled using multiple interacting classes and objects.

Teacher Class

A teacher class might define:

  • Properties

    • Name

    • Employee ID

    • List of courses taught

  • Behaviors

    • Teach students

    • Prepare course material

    • Deliver lectures

    • Grade assignments

A specific teacher object would contain the actual values for those properties and would represent one individual teacher within the system.

Student Class

A student class might define:

  • Properties

    • Name

    • Student ID

    • List of courses taken

    • Submitted assignments

  • Behaviors

    • Enroll in a course

    • Complete an assignment

    • Submit work

    • View grades

Each individual student is an instance of the student class.

Course or Class-Section Object

A course-section object, such as a particular section of a programming course, might have:

  • A course number

  • A section identifier

  • A teacher

  • A list of enrolled students

  • A list of assignments

The word class can be confusing because it may refer either to:

  • A programming class, which is a blueprint for objects

  • An academic class, such as a course section

Assignment Class

An assignment object might contain:

  • An assignment name

  • Instructions

  • A due date

  • A point value

  • Student submissions

  • Grades

A specific programming assignment or quiz would be an instance of the assignment class.

Relationships Between Objects

These objects interact with one another:

  • A teacher object holds a list of course objects.

  • A course object holds a teacher object.

  • A course object contains a list of student objects.

  • A course object contains assignment objects.

  • A student object interacts with assignment objects by completing and submitting work.

  • A teacher object interacts with assignment objects by grading submissions.

The course and teacher may refer to each other. This creates a relationship in which:

  • The teacher stores the course among the teacher’s courses.

  • The course stores the teacher as its instructor.

When a teacher grades an assignment, the process may involve:

  1. Accessing the appropriate course object.

  2. Finding the relevant assignment within that course.

  3. Examining student submissions.

  4. Assigning point values or grades.

  5. Updating the assignment and student records.

This example illustrates the object-oriented mindset: the program represents real-world entities as objects and models the interactions among them.


Integrated Development Environments

An integrated development environment, or IDE, is a program that combines many software-development tools into one application.

An IDE may allow a programmer to:

  • Create and edit source code

  • Run a program

  • Test a program

  • Find and correct errors

  • Build or compile an application

  • Organize project files

  • Prepare a final application for users

Before modern IDEs, programmers often used separate tools:

  1. A basic text editor for writing code

  2. A compiler or interpreter run manually

  3. Separate tools for testing

  4. Additional tools for building or packaging the application

An IDE integrates these functions into one environment. This makes development more efficient because the programmer does not have to switch between unrelated programs or manually perform every stage of execution and testing.

Visual Basic provides an IDE that supports the creation, execution, testing, and construction of applications.


Graphical User Interfaces

A graphical user interface, or GUI, is a component of a program that allows users to interact with software through visual elements.

A GUI may include:

  • Windows

  • Buttons

  • Menus

  • Text boxes

  • Icons

  • Images

  • Lists

  • Check boxes

  • Other clickable or selectable controls

Users interact with a GUI using input devices such as:

  • A mouse

  • A keyboard

  • A touchscreen

  • Other specialized input devices

For example:

  • A user clicks an icon with a mouse.

  • A user types information into a text box.

  • A user taps a button on a smartphone.

  • A user selects an item from a menu.

A GUI is not separate from the program’s logic. The program contains instructions that create the interface and determine how the program responds when users interact with it.

Visual Basic makes it relatively easy to create graphical interfaces. Programs in the course will use GUIs so that users can enter information and trigger actions.

Applications

An application is generally a program that includes a graphical user interface.

Applications allow users to:

  • See information

  • Click or tap controls

  • Enter data

  • Select options

  • View images and results

This distinguishes many applications from entirely text-based programs that run through terminals, shells, or command-line environments. The distinction is not absolute in every technical context, but graphical interaction is a common characteristic of an application.


The Programmer’s Job

A programmer’s professional role is to create computer-based solutions to problems faced by individuals, organizations, or companies.

A programmer may work:

  • As a full-time employee

  • As a contractor

  • As part of a software development team

  • On internal tools for one organization

  • On commercial software used by many organizations

The resulting software may become part of an organization’s:

  • Information system

  • Business workflow

  • Data-processing process

  • Customer-service system

  • Internal operations

General Problem Solving

Programming is not simply solving one fixed example. A programmer must create a general solution that can handle many possible situations.

For example, a weak solution might work only for:

  • One specific person

  • One set of numbers

  • One particular assignment

  • One fixed situation

A stronger program handles:

  • Different people

  • Different numerical values

  • Different inputs

  • Different combinations of circumstances

  • Unexpected but valid cases

The programmer therefore works at an abstract level. The goal is to design instructions that describe how to solve an entire category of problems, not just one example.

Programming is applied problem solving: it creates general instructions that can handle many possible inputs and situations.


Programming Workflow

A reliable programming process involves more than immediately writing code. A typical workflow includes understanding the problem, planning a solution, implementing it, testing it, and delivering the result.

1. Meet with Users and Understand the Problem

The programmer first communicates with the people who will use the software.

This helps the programmer determine:

  • What problem needs to be solved

  • Who will use the program

  • What users currently do

  • What information the program must accept

  • What results the program must produce

  • What features users need

  • What limitations or missing pieces exist

User involvement is important because the programmer may otherwise solve the wrong problem or create a tool that does not fit the users’ actual workflow.

2. Plan the Solution Before Coding

The programmer should design the solution before writing substantial code.

Planning may involve identifying:

  • The overall purpose of the program

  • The tasks the program must perform

  • The order of those tasks

  • The inputs required

  • The outputs expected

  • The objects or components needed

  • How users will interact with the program

  • How each individual task will be solved

Planning reduces confusion and prevents the programmer from losing direction during development.

Cowboy Coding

Cowboy coding is an informal term for beginning to write code without first adequately planning the problem or solution. It may feel fast initially, but it can lead to:

  • Disorganized code

  • Incomplete features

  • Repeated work

  • Difficulty finding errors

  • A solution that does not meet user needs

  • Problems that become expensive to fix later

Careful planning is therefore a central programming skill.

3. Code the Program

After the solution has been planned, the programmer writes the code in a programming language such as Visual Basic.

The code implements the planned:

  • Tasks

  • Data processing

  • User interface

  • Object relationships

  • Responses to user actions

4. Test the Program

Testing checks whether the program works correctly and meets user needs. Testing can identify:

  • Crashes

  • Incorrect calculations

  • Missing functionality

  • Unclear or inconvenient interactions

  • Unexpected behavior

  • Problems with different types of input

Testing is not limited to checking whether the program runs. A program may execute without crashing and still fail to solve the user’s problem effectively.

Alpha Testing

Alpha testing focuses primarily on internal correctness.

It helps determine whether:

  • The program runs

  • Features function as intended

  • Errors and crashes have been addressed

  • The implementation matches the design

  • The programmer has written the program correctly

Alpha testing is often performed internally by the development team.

Beta Testing

Beta testing involves potential users or a broader group of testers.

It helps determine whether:

  • Users understand how to operate the program

  • The program solves the intended problem

  • The workflow is practical

  • Users are satisfied with the result

  • Additional improvements are needed

Alpha testing asks whether the program works technically, while beta testing asks whether it works well for its intended users.

5. Revise and Repeat

Testing may reveal that the program needs changes. The programmer may need to repeat parts of the process:

  1. Gather additional feedback.

  2. Revise the plan.

  3. Modify the code.

  4. Test the changes.

  5. Gather more feedback.

The amount of repetition depends on the development approach and on how frequently users are available for testing.

6. Deliver the Final Product

After the program has been tested and improved, the programmer delivers the final software to its users or organization.

The final product should:

  • Address the original problem

  • Function reliably

  • Be usable by its intended audience

  • Fit into the organization’s workflow

  • Provide the planned functionality


Software Development Approaches

Software Development Life Cycle

The Software Development Life Cycle, or SDLC, is a structured approach to developing software. It generally organizes development into stages such as:

  • Understanding requirements

  • Planning

  • Designing

  • Coding

  • Testing

  • Delivering

  • Maintaining or improving the software

A traditional approach may attempt to complete major phases in sequence, with relatively limited repetition between phases.

Agile Development

Agile development emphasizes short cycles of development, testing, and feedback.

A typical Agile cycle is:

  1. Develop a small portion of the program.

  2. Test that portion.

  3. Ask users or stakeholders for feedback.

  4. Improve the program based on the feedback.

  5. Develop the next portion.

  6. Repeat the cycle.

Agile methods allow a project to adapt as developers and users learn more about the problem. They can be especially useful when the complete requirements are not known at the beginning.

Choosing an Approach

The best development approach depends on:

  • The project’s requirements

  • The organization

  • The users

  • The size of the development team

  • The availability of users for testing

  • The amount of change expected during development

Regardless of the specific approach, the central goals remain understanding the problem, creating a solution, testing it, obtaining feedback, and delivering useful software.


Programming as a Tool for Problem Solving

A computer’s physical design does not need to include a separate mechanism for every possible task. Instead, a programmer can create a program that gives the computer new capabilities.

This makes programming powerful because it allows a computer to become a flexible tool. Without programming, a user is limited largely to the applications and operating system created by others. By learning programming, a person can begin to:

  • Design custom tools

  • Automate repetitive tasks

  • Process information

  • Build applications

  • Create graphical interfaces

  • Solve problems specific to a person or organization

  • Adapt computer behavior to new needs

Programming therefore expands the usefulness of an existing computer. It transforms the computer from a device that merely runs existing applications into a platform for creating new solutions.

Programming allows a general-purpose computer to perform new tasks without changing the computer’s physical hardware.

Key Concepts

  • Computer: A general-purpose machine that performs tasks based on instructions.

  • Programming: The creation of instructions that give a computer functionality or enable it to perform a task.

  • Program: A set of instructions a computer can execute.

  • Software: A broad term for computer programs and related instructions.

  • Operating system: Software that manages the computer and provides a platform for users and applications.

  • Binary: A representation based on 000 and 111 that corresponds to the computer’s fundamental electrical states.

  • Assembly language: A low-level, human-readable representation of machine instructions.

  • Programming language: A structured, human-readable language used to write computer instructions.

  • Compiler: A program that translates source code before execution.

  • Interpreter: A program that reads and executes code during execution.

  • Programming paradigm: A general style for organizing and thinking about programs.

  • Object-oriented programming: A paradigm that organizes programs around interacting objects.

  • Class: A blueprint or pattern used to create objects.

  • Object or instance: A specific object created from a class.

  • Instantiation: The process of creating an object from a class.

  • IDE: Software that combines tools for writing, running, testing, and building programs.

  • GUI: A visual interface through which users interact with a program.

  • Alpha testing: Internal testing focused on technical correctness.

  • Beta testing: User-oriented testing focused on usability and satisfaction.

  • SDLC: A structured process for planning, developing, testing, and delivering software.

  • Agile development: An iterative approach based on short development cycles and frequent feedback.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent