### Digital Analysis, Legislation & Emerging Issues

Content Area 1: Problem Solving
Computational Thinking
Algorithms
Content Area 2: Introduction to Programming
Program Data
Operators
File Handling
Program Structure
Built-In Functions
Standard Algorithms
Validation & Error Handling
Maintainable Code
Testing
Content Area 3: Emerging Issues & Impact of Digital
Moral & Ethical Issues
Content Area 4: Legislation & Regulatory Requirements
Legislation
Guidelines & Codes of Conduct

# Pattern Recognition

Once a problem has been decomposed into smaller tasks, it is useful to try and identify common themes or patterns that might exist within our program or with other programs. This helps the programmer to save time reinventing the wheel when a solution to a given problem may already exist.

In this lesson we will learn about:

1. What is a pattern?
2. Identifying and describing trends and similarities within and between problems and processes
3. Identifying and describing common features between a given problem and existing solutions
4. Making predictions and assumptions based on identified patterns

## 1. What is a Pattern?

A pattern is something that repeatedly occurs in many different programming problems.

Patterns exist everywhere. If you were to look at how your day is organised from school to college, you would see that it follows a pattern:

1. Your day will start at a set time.
2. It will be broken up into a number of lessons of a set time.
3. You will have a lesson with a teacher.
4. The teacher will take a register.
5. You may or may not be set homework for a particular lesson.

This pattern holds true for each day of the week for most students in most schools and colleges.

This pattern can then be applied to any systems that track and monitor student data, including attendance, punctuality and recording homework marks. Such systems are known as Information Management Systems (IMS).

This is because most schools and colleges follow the same pattern.

This means that one program solution can be used by many different educational organisations.

Recognising patterns – things that are common within or between problems or programs – is one of the key areas of computational thinking.

### Further Thought

Think about what you did yesterday, are doing today and are going to do tomorrow. Can you identify any patterns?

## 2. Identifying trends between problems

Once you identify patterns in your problem, you might find that you need to use the same pattern again and again within your problem.

For example, you might want to display a graph of student attendance. This may be needed by:

• Staff to be able to monitor overall student attendance.
• Parents to be able to monitor the attendance of their son or daughter.

This would have the same graph pattern being used twice within the program.

### Further Thought

Think about any of the computer programs you are using in your school or college. Can you spot any patterns that might be used by students in other schools?

## 3. Identifying common solutions tO a problem

Once you identify a common pattern, there is more than likely going to be an existing solution to the problem.

For example, you might want to search for a student in a school IMS. To do this, you would need to use a searching algorithm, like a binary or linear search. We will look at searching algorithms later on in the course.

Also, looking at the graph drawing problem from the previous section, Python contains a module called Matplotlib. Matplotlib is a low-level graph plotting library that serves as a simple way of drawing and visualising graphical data.

Matplotlib is open source and can be used freely by anyone. This could be used as a solution for drawing graphs of student attendance.

Matplotlib is one of the modules you are required to know for Paper 1 and the Employer Set Project.

### Further Thought

You need to create a relational database. How many different programs are there that will allow you to solve this problem?

## 4. Making predictions Using patterns

Once you have identified a pattern you can speculate whether it can be reused in your existing program or used in another program.

You can also examine the pattern to identify any software or hardware components you might need.

For example, you identify that you need a login system for a program.

• The inputs are compared to the data stored in a database.
• If the inputs match the user is logged into the system.

Based on this, you can predict you will need:

• A user interface.
• Some means of connecting the interface code to the database.
• There needs to be some form of loop if the user gets their username or password wrong.

### Further Thought

Have a look at the following website about the Gang of Four design patterns: https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm

Can you spot any patterns about the patterns?

## Lesson Summary

So to summarise what we have learned in this lesson:

• Patterns are things that are the same within a problem and between problems.
• Identifying patterns means that there is probably an existing solution already out there.
• Patterns can be repeated within a problem.
• Patterns can be repeated between problems.
• If a pattern is identified, then it is possible to predict what hardware and software components may be needed to solve that problem.
Quizzes