COMPUTATIONAL THINKING | THINKING PROCEDURALLY
SECTION 1 | IDENTIFY THE PROCEDURE APPROPRIATE TO SOLVING A PROBLEM
When tackling any problem in computer science (and, really, in many areas of life), it's crucial to break the problem down into manageable steps and ensure those steps are in the correct sequence. This is the essence of procedural thinking.
1. Breaking Down Problems
Any complex problem can often be made more understandable by dividing it into smaller, more manageable subtasks or steps. Each of these smaller tasks can then be tackled individually.
For example: If you're coding a game, you might break it down into:
-
Designing the user interface.
-
Developing game mechanics.
-
Coding character movements.
-
Implementing game scoring.
-
Adding music and sound effects.
2. Sequencing
Once you've identified the steps, it's vital to determine the correct order in which they should be executed.
For example: When baking a cake (a non-computer example, but a useful analogy), you can't just randomly choose when to mix ingredients, preheat the oven, or decorate the cake. There's a specific order to follow for the cake to turn out right.
3. Visualization Tools
Visual aids like flowcharts or block-arrow diagrams can help in conceptualizing the flow of the procedure.
Block-Arrow-Block-Arrow: This is a simplistic way to demonstrate procedural flow. Each block represents a step or action, and each arrow points to the subsequent action.
For instance, in a recipe:
Preheat Oven to 350°F
↓
Mix dry ingredients
↓
Add wet ingredients and stir
↓
Pour batter into greased and floured pan
↓
Bake for 30-35 minutes, or until a toothpick inserted into the center comes out clean
↓
Let cool completely before frosting
... and so forth.
SECTION 2 | EVALUATE WHETHER THE ORDER IN WHICH ACTIVITIES ARE UNDERTAKEN WILL RESULT IN THE REQUIRED OUTCOME
When embarking on a task, especially in computer science, it's essential to be certain that the steps you're taking will lead to the desired outcome. This involves both prediction (thinking ahead) and sometimes even executing multiple tasks simultaneously or considering multiple factors at once (thinking concurrently).
THINKING AHEAD
This means planning and forecasting the possible outcomes of a decision before actually executing it.
Example: When writing code, it's essential to anticipate potential errors or bugs. If you're creating a software application that needs to handle user data, you might think ahead about potential security risks and plan to encrypt that data.
THINKING CONCURRENTLY
Concurrency, in computing, refers to the ability of a system to handle multiple tasks at the same time. In a broader sense, thinking concurrently means considering several factors or tasks simultaneously to achieve an optimal solution.
For example: When designing a multi-threaded application, you'll need to think about how different threads might interact, share resources, and potentially conflict with each other.
Algorithm Design: Involves predicting the outcomes of various operations, ensuring that they produce the desired results. This is an example of thinking ahead.
Concurrency and Parallelism: In program design, especially with the rise of multi-core processors, concurrency is a significant consideration. It requires the programmer to think concurrently, ensuring that tasks running simultaneously don't interfere with each other in undesirable ways.
It's crucial to anticipate the outcomes of different parts of your code. For instance, understanding that a certain piece of code will change a variable's value, and predicting how that change will affect the program downstream.
SECTION 3 | EXPLAIN THE ROLE OF SUB-PROCEDURES IN SOLVING A PROBLEM
Sub-procedures, often called subroutines, functions, or methods in various programming languages, play a pivotal role in problem-solving, especially in programming and algorithm design. Here's why they're crucial:
MODULARITY
Sub-procedures promote modularity. Instead of having a long sequence of code or instructions, you can break down a problem into smaller, more manageable chunks. Each chunk, or module, can be tackled independently.
For example: If you are designing a calculator program, instead of writing a single long piece of code, you might have sub-procedures for addition, subtraction, multiplication, and division. Each of these sub-procedures handles a specific operation.
REUSABILITY
Once a sub-procedure is defined, it can be used multiple times without needing to rewrite or duplicate the code. This promotes code reusability and reduces redundancy.
For example: In the calculator program, once you've written the subroutine for addition, any part of the program can use it by referring to its identifier whenever additional functionality is needed.
ABSTRACTION
Sub-procedures allow for a level of abstraction. The main routine or other sub-procedures don't need to know the details of how a specific sub-procedure works, just what it does (i.e., its interface).
For example: If you're using a sorting subroutine, you don't necessarily need to know the inner workings of the sorting algorithm. You just need to know that it will sort your data.
EASY DEBUGGING AND MAINTENANCE
By isolating functionality into separate sub-procedures, if there's a bug or an error, it's often easier to locate and fix. Maintenance becomes more straightforward because changes to one sub-procedure don't automatically mean changes to the entire program.
IMPROVED RELIABILITY
Programs that utilize sub-procedures are generally easier to read and understand. Each sub-procedure has a clear purpose, and by naming them descriptively, the flow and functionality of the program become clearer.
PASSING PARAMETERS
Sub-procedures can accept parameters (inputs) and return outputs. This allows for flexibility and dynamic behavior. By changing the parameters, you can change the behavior of the sub-procedure without altering its internal code.
CONSTRUCTING PROCEDURES REFERRED BY THEIR IDENTIFIER
When you define a sub-procedure, it's given a unique name or identifier. This identifier acts as a reference to the set of instructions encapsulated by the sub-procedure. By invoking or calling the sub-procedure using its identifier, you execute those instructions. This methodology simplifies complex tasks and promotes the principles mentioned above like modularity, reusability, and abstraction.
Sub-procedures are fundamental building blocks in programming and algorithmic problem-solving. They help break problems into smaller, more digestible parts, making code cleaner, more efficient, and more maintainable. By defining and then referring to these procedures by their identifier, programmers can tackle complex challenges in a systematic and organized manner.