This course provides you with a foundation in basic programming concepts that are common to most high-level programming languages with an emphasis on structured programming.
You will start by learning what a computer program is and about the environment in which it does its job.
As you progress through the course you will move from more general topics, such as how a computer stores numbers and text, to more specific topics, such as how to implement an algorithm for sorting data.
Along the way you will have many opportunities to practice your new programming skills by writing computer programs in the
Java programming language.
By the end of the course you will be ready to study more advanced topics in Java or to move on to another high-level programming language such as C or Visual Basic.
What are the key components which make up structured programming?
Structured programming is a programming paradigm that emphasizes a logical structure in the software code and seeks to streamline the coding process by eliminating unwanted complexities. This approach increases code readability and understandability and hence reduces the cost of software maintenance. It also encourages better testing and debugging. Here are the key components that make up structured programming:
Sequence: Sequence is the ordered execution of code statements one after another. It's the simplest form of control flow and the most basic structure in any programming language. The flow of execution proceeds sequentially, with each statement being executed in the order they are written in the code, from top to bottom.
Selection: Selection, also known as conditional control flow, allows the program to choose between two or more paths of execution based on the evaluation of a condition or set of conditions. This involves structures such as "if", "if-else", "switch" statements in various languages. In selection, the program decides to execute a particular block of code based on the condition's truthfulness.
Iteration: Iteration, also known as looping control flow, allows a certain block of code to be executed repeatedly, depending on a condition. Looping constructs include "for", "while", and "do-while" loops. Iteration is fundamental to any programming language, allowing a set of instructions to be repeated until a certain condition is met.
Modularity: Modularity is a principle in structured programming that encourages code to be split into multiple, smaller modules or functions, each having a clear, well-defined functionality. Functions or procedures provide a way to encapsulate a piece of code that erforms a specific task, enhancing code reusability and readability. A well-written program often has many small and simple modules that are easy to understand independently and fit together to solve a larger problem.
Variables and Data Structures: Variables are used to store data that can be manipulated by the program, while data structures allow the organization and storage of data in a particular structure. This could be simple structures like arrays, or more complex structures like lists, stacks, queues, trees, etc., depending on the needs of the program.
Handling of Errors and Exceptions: Structured programming promotes proactive error and exception handling. This allows the program to respond gracefully to unexpected events or conditions that occur during the program's execution. Error handling structures vary between programming languages but generally include constructs like "try-catch" blocks.
These components collectively form the basis of structured programming, and it's through these components that structured programming achieves its goals of readability, maintainability, and efficiency in writing complex software systems.
Perl
Python
Basic
C++
C#
Javascript and PHP
Java
C
Course goals
After completing this course, you will be able to:
Understand what a computer program is and how it works
Describe how a computer stores numbers and text
Use structured programming concepts
Use the Java 2 Software Development Kit to develop Java programs
Use Java's primitive data types
Use Java's arithmetic, increment and decrement, remainder, relational, and logical operators
Understand numeric promotion, truncation, conversion and casting, and operator precedence
Use control flow constructs in a Java program
Use class methods in a Java program
Use arrays in a Java program
Implement an algorithm for sorting data
C++, Java, and Python focus more on computer logic and less on the presentation.
In the next lesson, you will learn about prerequisites to this course.