28
Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS MODELLING DECOMPOSITION ALGORITHMS: PSEUDOCODE AND FLOWCHARTS EXAM QUESTIONS AND ANSWERS

Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Embed Size (px)

Citation preview

Page 1: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Mastering AbstractionNATURE OF ABSTRACTIONNEED FOR ABSTRACTIONDIFFERENCES BETWEEN ABSTRACTION AND REALITYDEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONSMODELLINGDECOMPOSITIONALGORITHMS: PSEUDOCODE AND FLOWCHARTSEXAM QUESTIONS AND ANSWERS

Page 2: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Did you know?Did you know?

Plato was a famous ancient Greek philosopher. He postulated that all the objects that are seen in this world are not real, but literally mimic the real Forms.

Plato was a famous ancient Greek philosopher. He postulated that all the objects that are seen in this world are not real, but literally mimic the real Forms.

These Forms are the essences of various objects: they are that without which a thing would not be the kind of thing it is. For example, there are countless tables in the world but the Form of tableness is at the core; it is the essence of all of them

These Forms are the essences of various objects: they are that without which a thing would not be the kind of thing it is. For example, there are countless tables in the world but the Form of tableness is at the core; it is the essence of all of them

Page 3: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Plato’s theory of formsPlato’s theory of formsA Form is an objective "blueprint" of perfection.

The Forms are perfect themselves because they are unchanging.

A Form is an objective "blueprint" of perfection.

The Forms are perfect themselves because they are unchanging.

In the Phaedrus the Forms are in a "place beyond heaven" and in the Republic the sensible world is contrasted with the intelligible realm in the famous Allegory of the Cave.

In the Phaedrus the Forms are in a "place beyond heaven" and in the Republic the sensible world is contrasted with the intelligible realm in the famous Allegory of the Cave.

One interpretation of this is to say that Plato was suggesting that everything on this earth is just a instantiation of its respective true and perfect “form

One interpretation of this is to say that Plato was suggesting that everything on this earth is just a instantiation of its respective true and perfect “form

Page 4: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

…and what is Abstraction…and what is AbstractionAbstraction is one of the four cornerstones of Computer Science. It involves filtering out – essentially, ignoring - the characteristics that we don't need in order to concentrate on those that we do.

Abstraction is one of the four cornerstones of Computer Science. It involves filtering out – essentially, ignoring - the characteristics that we don't need in order to concentrate on those that we do.

Abstraction is the process of filtering out – ignoring - the characteristics of patterns that we don't need in order to concentrate on those that we do. It is also the filtering out of specific details. From this we create a representation (idea) of what we are trying to solve.

Abstraction is the process of filtering out – ignoring - the characteristics of patterns that we don't need in order to concentrate on those that we do. It is also the filtering out of specific details. From this we create a representation (idea) of what we are trying to solve.

Any idea what these two objects are?Any idea what these two objects are?

Page 5: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Chairs and the concept of abstractionChairs and the concept of abstractionImagine you were given a task: to draw a series of chairs …Imagine you were given a task: to draw a series of chairs …

You’ll note that though they take different forms, chairs all have certain general characteristics that are common to all (legs, back, seat type etc.)You’ll note that though they take different forms, chairs all have certain general characteristics that are common to all (legs, back, seat type etc.)

In addition, each chair has specific characteristics, colour (black legs), type of seat =hard/soft; material = leather/fabric. These details are known as specifics.

In addition, each chair has specific characteristics, colour (black legs), type of seat =hard/soft; material = leather/fabric. These details are known as specifics.

Page 6: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Abstraction: Drawing a basic chairAbstraction: Drawing a basic chairIn order to draw a basic chair, we do need to know that it has legs (of some sort), a seat, a back, etc. (if it didn’t have a back I suppose it would be a stool) These general characteristics are relevant and essential

In order to draw a basic chair, we do need to know that it has legs (of some sort), a seat, a back, etc. (if it didn’t have a back I suppose it would be a stool) These general characteristics are relevant and essential

We don’t however, need to know what fabric the chair is made of, or what colour the legs are. We don’t even need to know what the size of the chair is. These specifics can be filtered out.

We don’t however, need to know what fabric the chair is made of, or what colour the legs are. We don’t even need to know what the size of the chair is. These specifics can be filtered out.

From our basics (general characteristics) we can build a basic idea of a chair i.e. what a chair basically looks like. We would then be able to describe how to draw a basic cat.

From our basics (general characteristics) we can build a basic idea of a chair i.e. what a chair basically looks like. We would then be able to describe how to draw a basic cat.

This filtering out of the irrelevant details is ABSTRACTION.This filtering out of the irrelevant details is ABSTRACTION.??

Page 7: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Need for AbstractionNeed for AbstractionSo as we’ve been learning, Abstraction allows us to create a general idea of what the problem is and how to solve it. The process instructs us to remove all specific detail, and any patterns that will not help us solve our problem. This helps us form our idea of the problem. This idea is known as a ‘model’.

So as we’ve been learning, Abstraction allows us to create a general idea of what the problem is and how to solve it. The process instructs us to remove all specific detail, and any patterns that will not help us solve our problem. This helps us form our idea of the problem. This idea is known as a ‘model’.

If we don’t abstract we may end up with the wrong solution to the problem we are trying to solve. If we don’t abstract we may end up with the wrong solution to the problem we are trying to solve.

In the chair example, if we didn’t abstract we might think that all chairs are gold and velvety and look like the one in the picture! We know however, that although chairs have a colour and size, not all chairs are as grand as the one shown. In this case, abstraction has helped us to form a clearer model of a chair

In the chair example, if we didn’t abstract we might think that all chairs are gold and velvety and look like the one in the picture! We know however, that although chairs have a colour and size, not all chairs are as grand as the one shown. In this case, abstraction has helped us to form a clearer model of a chair

Page 8: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

How to abstractHow to abstract

So, abstraction is the gathering of general characteristics that we need and filtering out unnecessary details.

So, abstraction is the gathering of general characteristics that we need and filtering out unnecessary details.

I don’t know if you like Chocolate, but if you do, and you’ve ever tried making some, there are some general things that you always need to know:

I don’t know if you like Chocolate, but if you do, and you’ve ever tried making some, there are some general things that you always need to know:

For example, here are some general essentials

1.Chocolate needs ingredients2.Each ingredient needs a specified quantity3.Making chocolate needs timings

For example, here are some general essentials

1.Chocolate needs ingredients2.Each ingredient needs a specified quantity3.Making chocolate needs timings

Page 9: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

How to abstractHow to abstractRecap: abstraction is the gathering of general characterises that we need and filtering out unnecessary details. Recap: abstraction is the gathering of general characterises that we need and filtering out unnecessary details.

For example: 1.Chocolate needs ingredients2.Each ingredient needs a specified quantity3.Making chocolate needs timings

For example: 1.Chocolate needs ingredients2.Each ingredient needs a specified quantity3.Making chocolate needs timings

When abstracting we can remove specifics and keep the relevant patterns - essentialsWhen abstracting we can remove specifics and keep the relevant patterns - essentials

General Patterns Specific DetailsWe need to know chocolate has ingredientsWe need to know chocolate has ingredients

We need to know the quantities requiredWe need to know the quantities required

We need to know the timings required We need to know the timings required

We don’t need to know what the ingredients areWe don’t need to know what the ingredients are

We don’t need to know specific quantities ….We don’t need to know specific quantities ….

We don’t need to know the specifics of timingsWe don’t need to know the specifics of timings

Page 10: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Creating a ModelCreating a ModelA Model is a general or essential/basic idea of the problem that we are hoping to solve. A Model is a general or essential/basic idea of the problem that we are hoping to solve.

Take elephants, a model elephant would not be an indian elephant will small ears, because a model has to represent ALL elephants.

Take elephants, a model elephant would not be an indian elephant will small ears, because a model has to represent ALL elephants.

Once we have a model in place, we can design an algorithm to solve the problem!Once we have a model in place, we can design an algorithm to solve the problem!

From our model of elephants, we should be able to learn about what any elephant might look like in the real world. From our model of elephants, we should be able to learn about what any elephant might look like in the real world.

An algorithm is just a sequence of instructions that can be used to solve a problem.An algorithm is just a sequence of instructions that can be used to solve a problem.

General: TrunkGeneral: Trunk

TrunkTrunk

General: EarsGeneral: Ears

EarsEars

The sizes of the ears or trunk won’t be needed for our modelThe sizes of the ears or trunk won’t be needed for our model

Page 11: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

PseudocodePseudocodePseudo means false! Pseudocode literally means ‘false’ code or ‘fake’ code. Pseudo means false! Pseudocode literally means ‘false’ code or ‘fake’ code.

Pseudocode is not a programming language – it is just a way of writing code in simple statements that do not use programming language specific syntax. Pseudocode is not a programming language – it is just a way of writing code in simple statements that do not use programming language specific syntax.

Dim x as integer = 10Dim x as integer = 10

CodeCode PseudocodePseudocode

DECLARE x as an integerDECLARE x as an integer

GIVE x the value of 10GIVE x the value of 10Dim age as integerTextbox1.text = ageDim age as integerTextbox1.text = age

DECLARE age as integerINPUT age into textboxDECLARE age as integerINPUT age into textbox

Pseudocode should not be specific to any language. It’s a bit like writing steps of instructions in plain English (or other languages) without worrying about the syntaxPseudocode should not be specific to any language. It’s a bit like writing steps of instructions in plain English (or other languages) without worrying about the syntax

Page 12: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

FlowchartsFlowchartsA flowchart is a diagram that represents a set of instructions (step by step) – visual!A flowchart is a diagram that represents a set of instructions (step by step) – visual!

Flowcharts have a range of standard symbols to represent different instructions in useFlowcharts have a range of standard symbols to represent different instructions in use

Start/Stop

Process

Decision

Manual Input

*indicates a jump from onepoint in the sequence to another

*connects symbols.Shows direction of flowof the instructions

OutputOutput

Page 13: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Output “Access Denied”

Output “Access Denied”

Here’s a very simple flow chart!Here’s a very simple flow chart!

Start/Stop

If age >16

Enter age into textbox

PseudocodePseudocodeDECLARE age as integerDECLARE age as integer

INPUT age into textboxINPUT age into textbox

IF age > 16IF age > 16

OUTPUT “Welcome”OUTPUT “Welcome”

Output “Welcome”

Output “Welcome”

ELSEELSE

OUTPUT “Access denied”OUTPUT “Access denied”Yes No

Page 14: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

DecompositionDecompositionYou may have heard this word in Biology – in reference to decomposing food or garbage …You may have heard this word in Biology – in reference to decomposing food or garbage …

In computing, it refers to solving a problem by decomposing it into sub-problems (sub-modules)In computing, it refers to solving a problem by decomposing it into sub-problems (sub-modules)

You would then compose the solutions together to solve the original problem. You would then compose the solutions together to solve the original problem.

Consider this problem: MAKE BREAKFASTConsider this problem: MAKE BREAKFAST

In reality, this has lots of sub tasks…In reality, this has lots of sub tasks…

Make Tea

Make Tea

Make ToastMake Toast

Milk Cow Milk Cow

BoilEggBoilEgg

Page 15: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

DecompositionDecompositionThese tasks can be further decomposed …for instance boiling milk may involve a series of steps:

1.Milk Cow2.Transfer milk to boiling pan3.Put on the gas4.Boil Milk

These tasks can be further decomposed …for instance boiling milk may involve a series of steps:1.Milk Cow2.Transfer milk to boiling pan3.Put on the gas4.Boil Milk

BoilMilkBoilMilk

Milk cowMilk cow Transfer Milk

Transfer Milk

Put on the gasPut on the gas Boil Milk…Boil Milk…

The process is known as recursive as each sub task is probably capable of further decomposition and so on and so on until you arrive at the smallest possible sub task.

The process is known as recursive as each sub task is probably capable of further decomposition and so on and so on until you arrive at the smallest possible sub task.

Organisation of data can also be decomposed. E.g. data representing the population of a country can be decomposed into entities such as individuals, occupations, places of residence, etc.Organisation of data can also be decomposed. E.g. data representing the population of a country can be decomposed into entities such as individuals, occupations, places of residence, etc.

Page 16: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Final Notes on AbstractionFinal Notes on Abstraction

The process of abstraction takes many specific forms, such as modelling, decomposing (breaking down a big problem), and generalising. In each case, complexity is dealt with by hiding complicated details behind a simple abstraction, or model, of the situation.

The process of abstraction takes many specific forms, such as modelling, decomposing (breaking down a big problem), and generalising. In each case, complexity is dealt with by hiding complicated details behind a simple abstraction, or model, of the situation.

Example of a Model:

Have you ever seen a London Underground map? Well, that is a simple model of a complex reality — but it is a model that contains precisely the information necessary to plan a route from one station to another. *Remember that Computational thinking values elegance, simplicity and modularity over complexity

Example of a Model:

Have you ever seen a London Underground map? Well, that is a simple model of a complex reality — but it is a model that contains precisely the information necessary to plan a route from one station to another. *Remember that Computational thinking values elegance, simplicity and modularity over complexity

Page 17: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Final Notes on AbstractionFinal Notes on AbstractionAbstraction is the main mechanism used to deal with complexity and enabling computerisation. Abstraction is both presenting a simplified version through information hiding and making an analysis to identify the essence or essential features. Aspects of abstraction include:

Abstraction is the main mechanism used to deal with complexity and enabling computerisation. Abstraction is both presenting a simplified version through information hiding and making an analysis to identify the essence or essential features. Aspects of abstraction include:

Computer hardware consists of components (black boxes) interacting through interfaces (a network cable, a CPU socket, a SATA disk interface).

Computer software is built from layers of abstraction. For example, a procedure (or method, or library) implements a specification, but hides its implementation; an operating system provides facilities to programs but hides the complex implementation; a database implements SQL queries, but hides how the data is stored.

Scientists, industrialists, engineers, and business people all use computers to simulate and model the real world, by abstracting away unnecessary detail and using a computer program to simulate (what they hope is) the essence of the problem

Designing and hiding a complicated implementation (“how it works”) behind an interface (“what it does”). Designing and hiding a complicated implementation (“how it works”) behind an interface (“what it does”).

Representing or modelling through visualisations, metaphors or prose the essential features without the confusion of the detail. Representing or modelling through visualisations, metaphors or prose the essential features without the confusion of the detail.

The process of categorisation or classification that breaks down a complex system into a systematic analysis or representation.

Page 18: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Examples of ModellingExamples of Modelling

Modelling is the process of developing a representation of a real world issue, system, or situation, that captures the aspects of the situation that are important for a particular purpose, while omitting everything else

Modelling is the process of developing a representation of a real world issue, system, or situation, that captures the aspects of the situation that are important for a particular purpose, while omitting everything else

Further Examples:Further Examples:

Storyboards for animationsStoryboards for animations

Mass, velocity and position of planets orbiting one another

Mass, velocity and position of planets orbiting one another

Page 19: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Different purposes need different modelsDifferent purposes need different modelsExample: a geographical map of the Underground is more appropriate for computing travel times than the well-known topological Underground map; a network of nodes and edges can be represented as a picture, or as a table of numbers.

Example: a geographical map of the Underground is more appropriate for computing travel times than the well-known topological Underground map; a network of nodes and edges can be represented as a picture, or as a table of numbers.

A particular situation may need more than one model.

Example: a web page has a structural model (headings, lists, paragraphs), and a style model (how a heading is displayed, how lists are displayed). A browser combines information from both models as it renders the web page.

A particular situation may need more than one model.

Example: a web page has a structural model (headings, lists, paragraphs), and a style model (how a heading is displayed, how lists are displayed). A browser combines information from both models as it renders the web page.

Page 20: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

Questions on AbstractionQuestions on Abstraction

Page 21: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

QuestionQuestion

Page 22: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

AnswerAnswer

Page 23: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

QuestionQuestion

Page 24: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

AnswerAnswer

Page 25: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

QuestionQuestion

Page 26: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

AnswerAnswer

Page 27: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

QuestionQuestion

Page 28: Mastering Abstraction NATURE OF ABSTRACTION NEED FOR ABSTRACTION DIFFERENCES BETWEEN ABSTRACTION AND REALITY DEVISING ABSTRACT MODES FOR DIFFERENT SITUATIONS

AnswerAnswer