|||

Y10 AU – P2 – Abstraction and Decomposition

Accessibility Settings
  • DIN
  • Objectives
  • Activity 1 – Algorithmic Thinking
  • Activity 2 – Decomposition
  • Activity 3 – Abstraction
  • Plenary

⏱️ Do It Now

Copy this title into a new OneNote document:

Y10 AU – P2 – Abstraction and Decomposition

Complete this table and copy it into the OneNote document:

⏱️ Do It Now:
Answer the following questions

(1) Explain what is meant by each of the terms Initialisation and Assignment


(2) Explain why it is important for code to contain suitable spacing and suitable comments.
What can go wrong if these standards aren’t adhered to?

🎯 Learning Objectives

(1) We will understand what is meant by algorithmic thinking

(2) We will be able to explain what is meant by decomposition and describe decomposition through suitable examples

(3) We will be able to explain what is meant by abstraction and describe abstraction through suitable examples

⌨️ Activity 1 – Algorithmic Thinking

  • Tab 1
  • Tab 2
  • Tab 3

What is Algorithmic Thinking?

The way a program should behave is called its algorithm

When writing code, it is really important that the programmer understands the algorithm they are attempting to code.

Most algorithms have lots of possible outcomes and can respond differently depending on the inputs they receive.

Therefore it is important for the programmer to plan out the algorithm.

Planning Ahead

Before coding a program, programmers can plan out the algorithm with several methods.

Flowcharts

Flowcharts allow for a visual representation of an algorithm; enabling a programmer to see all of the possible outcomes of an algorithm.


Pseudocode

Pseudocode is a written description of the algorithm. It looks similar to actual programming code but doesn’t require strict rules found in most programming languages.

Responsive task:

With the Mini-Whiteboard app we will answer the following questions:

(1) What is the name we give to the way a program will behave?

(2) When a programmer thinks through the flow of a program, what do we call it?

(3) What is the name we give to a visual representation of a program?

(4) What do we call a textual representation of a program, that resembles actual code?



Paste a screenshot of each response into OneNote

⌨️ Activity 2 – Decomposition

  • Tab 1
  • Tab 2
  • Tab 3
  • Tab 4

📖 What is Decomposition?

Some computer programs can be absolutely huge and require multiple programmers to work on the code together!

This is best managed by breaking the idea of the program into pieces called modules.

Each module can then be assigned to a separate member of the team.

The process of breaking down the program into parts/modules is called decomposition.

📖 Best for All Programs

Whilst decomposition is important for a large team working on a large program, it is also important for individual programmers who may be working on spaller programs.

Even if you are working on a small application (like a calculator) it is highly useful for you to identify each of the individual parts that make up the program.

Once you have identified all of the parts/modules you can begin to think about how they connect/relate to one another.

You can then establish the best way to start building the program.

📖 Subprograms – How decomposition works in Python

Python is designed with decomposition at the core of its philosophy.

Python programs can be split into segments called subprograms that can each work on their own when called into action; and can be called into action more than once.

To the left you can see an example of subprograms:

They are each defined (a bit like making a reusable blueprint)

They are each called into action within the main program, by simply referencing their name.

You will begin to use subprograms regularly when your programming skills develop throughout the course…

#------------- Subprograms------------------------

def ending():
    print("I guess I'll see you then")

def greeting():
    print("Hello, nice to meet you")
    
def middle():
    print("Funny weather we are having... hey?")
    print("Looking at the floor and whistling")
    
#------------------ Main Program ----------------

print("Bob recognises Margaret as they pass each other in the street")

greeting() # Calling greeting into action
middle()   # Calling middle into action
ending()   # Calling ending into action

✍️ Task – Decomposition

Every day you complete many complex tasks without thinking about them.
One example is getting ready for school and arriving on time.

(1) Break this task down into specific parts (what modules can this be broken down into?)

(2) Identify what happens in each of these modules – are there other modules within these?

(3) Complete this activity in OneNote with the title “Decomposing Getting Ready for School”.

⌨️ Activity 3 – Abstraction

  • Tab 1
  • Tab 2
  • Tab 3
  • Tab 4

📖 Defining Abstraction

Computer programs are made for a specific purpose. For example, Minecraft is made for users to play and interact with an imaginary world.

When Minecraft was first developed, its creators decided to strip back the visual aspects to a simple block-based world, and focus more on playability.

Surprisingly the game is still immersive and it is easy to recognise elements and other characters in the game (even if they may just be blocks).

The process of removing unnecessarily detail is called abstraction.

📖 Abstraction in The Real World

A clear example of abstraction would be the London Underground map.

It serves the purpose of showing travellers:

🚆 What lines they can take (different colours)
🚉 The stops on each line (spurs with the names next to them)
🚄 The junctions between different lines (white circles)

The map also features other major transport hubs (again, useful for people travelling in and out of the city).

The map is an abstraction in that no other information about the city is present.

Additionally, the map is not to scale, and the underground lines in real life are not straight (as they are presented in the map).

📖 Abstraction for Instructions

Instructions for building furniture (such as Ikea) can be abstracted.

The customer doesn’t need every single action they will carry out to be put in the instruction book.

If this was the case, the instructions would need tens/hundreds of pages!

Ikea, instead, relies on the fact that by giving the bare minimum of instructions, the customer can work out what to do for the rest of a particular stage.

Do you think you would be able to disassemble the bookshelf with just these instructions to guide you?

✍️ Abstraction Task

🎓 Plenary

Complete this quiz: Y10 – Abstraction and Decomposition

Screenshot your result into OneNote

If you have time, correct any answers you got wrong