Computational Thinking

Computational Thinking allows us to take a complex problem, understand what the problem is a develop possible solutions. We can present these solutions in a way that a computer or/and a human can understand.

Thinking Abstractly

Representational Abstraction - Remove excessive details to present a problem with only the key features.

Data Abstraction - Details about how data is stored is hidden, programmers can use data structures with knowing.

Layers of Abstraction - The large complex problems will be split into layers. Each layer will have a different role. The highest layer will be close to the user, usually that will be the interface. With the lowest layer performing tasks with amchine components.

Abstraction by generalisation - Group together similarities within a problem to identify it, problems will be categorised as being part of a particular type.

Procedural abstraction - Programmer will be able to utilise the functions without knwoing how they're implemented. This is used in decompositiona nd manipulating data structures.

The need for abstraction?

Allows non-experts to use a range of systems and models by hiding information that is too complex or is irrelevant.

Enables efficient software design as the programmers can focus on the core elements other than the unnecessary details.

Programming Languages use Layers of Abstraction: Low level, directly interact with computers. High level, abstarct the machine code that is being executed which a program is run by providing an easy syntax which is similar to english. TCP/IP is seperated into layer, each layer deals with different part of the communciation process.

Difference between Abstraction and Reality?

Simplified representation fo reality. Entities are represented as computational staructures (data structures). Real-world variables cna be sotred as constants and variables.

Objects in OOP are an abstraction of real-world entities: Attributes, represent characteristics of an object. Methods, represent actiosn of a real world object.

Devise and abstract model for a variety of situations?

When devising the abstract model you must consider: What is the problems that needs to be solved? How will the model be used? Whow ill the model be used by? Which parts of the problem are relevant based on the target audience and purpose of the model?

Thinking Ahead

Identify the inputs and outputs for a given situation.

Deisgning a solution requires thinking ahead about how the different components of a problem can be ahdnled in the best possible way.

All computational problems will consist of inputs which are processed and produce an output.

Inputs: Any data data required to solve thr problem.

Outputs: Results thar are passed back. They're essentially the solution.

Preconditions

Preconditions are requirements which must be met beofre the program is executed.

Specifying the preconditions means that a subroutine expects the arguments passed to it to meet criteria.

Advantage: Reduces the length and complexity of the program and saves time spent on debugging and maintenance.

Advantage: Makes subroutines more reusable.

Reusable Program Components

Commonly used functions can be packaged into libaries for reuse.

Reusable components include: Abstract data structures, classes and subroutines.

Caching

Store instuctions or values in cache memeory after they've been used as they may be used again.

Advantages: Saves time retrieving instructions from secondary storage again. Frequently accessed web pages are cached so content can be quickly loaded up. This frees up bandwidth for other tasks on a network.

Disadvantages: Difficult to implement.

Thinking Procedurally

Identify the components of a problem

The first stage in thinking procedurally, you break the problem down. This is called problems decomposition.

Screenshot 2023-05-13 at 10.16.36 am

Advantantages: Divides problems into levels complexity. Makes solving problems more easiar. Easiar to manage because it's divided between a team.

When the problem is being divided between teams. This is called top-down design known as stepwise refinement.

Components of a solution and Sub-procedures

Start to build the solution adfter problem decomposition. Do this by considering the lowest-level components from the top-down design and how they can be solved.

Questions to ask: Can this be implmented as a function or a procedure? What inputs are required? What output does the subroutine need to produce?

Order of steps needed to solve a problem

When constrcting the final solution you must think about the order in which operations are performed.

Programs may require certain inputs to be entered in a particular order by the user. Inputs need to be validated. Porgrammers need to decide on the order in which subroutine ares executed and how they interact with each other.