Computional Thinking (Leaving Cert Computer Science): Revision Notes
Computational Thinking
Computational Thinking
Computational thinking is a way of approaching a problem. It refers to looking at a problem in a logical way to try and find a solution.
There are four areas or 'pillars' of computational thinking:
-
Abstraction The process of simplifying something by removing unnecessary characteristics to focus on its essential characteristics
-
Pattern matching : identifying patterns
-
Decomposition : breaking a large, complex tasks into smaller, more approachable ones
-
Algorithms : using a step-to-step process to solve a problem
Computational thinking: looking at a problem in a logical way to try and find a solution.
Abstraction
Abstraction: the process of simplifying something by removing unnecessary characteristics to focus on its essential characteristics.
In computer science we generalise problems, meaning we try and hide details to capture some commonality between difference instances.
Consider three instances of vehicles - a truck, car and motorcycle. Abstraction of a vehicle involves the following :
- Ignoring irrelevant details : This involves omitting characteristics that do not contribute to the essential function of the abstraction. This may involve the manufacturing details, aesthetic features or internal engine mechanics.
- Identifying patterns : This involves looking for key features that are general to all vehicles. A motorcycle has two wheels but a car has four, meaning that the number of wheels is specific to an instance of a vehicle. However, starting the engine is something every vehicle can do.
- Define an abstract model : With the commonalities of a vehicle identified, we can define a blueprint for a vehicle that captures the behaviour that every vehicle should have.
Functions
- Functions achieve abstraction by allowing code to be written once and reused whenever needed.
- By calling a function instead of rewriting code, programmes become shorter and simpler, especially when dealing with repetitive tasks.
Consider we want to write a function called startEngine() that can be used for any type of vehicle. Starting the engine involves complex operations, but by encapsulating these complexities within the startEngine() function, we can abstract the internal processes. This allows us to reuse the startEngine() since we won't have to write this function for every instance of a vehicle.
Decomposition
Decomposition: the process of breaking down a large task into a set of smaller tasks.
Writing a function for startEngine() can be complex, so we can use decomposition to break the task into smaller components. Starting the engine involves a series of smaller functions :
- checkFuel()
- checkBattery()
- initialiseEngine()
- igniteEngine() Writing these functions individually is a simpler task, which will aggregate to the functionality of startEngine() .