4.1 General Principles

4.1.1 – Identify the procedure appropriate to solving a problem

This area focusses on looking at a problem and figuring out the best way to solve it.

Consider breaking down a large project into smaller projects.

  • What tools are available such as
  • Loops
  • Arrays
  • Pre built libraries and functions
  • Custom function

Think about how many different tasks you do for “Getting up in the morning and getting ready”

This is an example of one big task with many little tasks involved

4.1.2 – Evaluate whether the order in which activities are undertaken will result in the required outcome

Consider this as a very simple explanation

4+8*5 could be 60 or 44

(4+8)*5 =60

5*8+4 =44

Consider another example where if you got out of bed, then went to work, then got dressed…… this could have interesting results!

The best way to learn this is to practice your coding skills

4.1.3 – Explain the role of sub-procedures in solving a problem

“A good approach for confronting a complex problem is to develop a method of breaking up the problem into smaller sub-problems. This method is very effective and efficient because it is much easier to attack a number of sub-problems instead of a big complex problem. The resulting sub-problems can be further divided to smaller and smaller sub-problems until finally they can be dealt individually. This strategy is often called top—down design

The very same approach could be used when developing complex computer programs. Using top-down program design, the complex problem is decomposed and for each sub-problem, an appropriate sub-procedure is developed. A sub—procedure contains a series of commands that perform a task. When a sub»procedure is called all statements included in the particular sub-procedure are executed. “

Computer Science – Kostas Dimtriou and Markos Hatzitaskos – Express 2015

4.1.4 – Identify when decision-making is required in a specified situation

This area involves thinking essentially about using CASE statements and If/Else statements to control decisions.

Image result for flowchart funny

Again the best way to learn these is to practice with code

4.1.5 – Identify the decisions required for the solution to a specified problem

Not every problem is going to be as simple as the image above and sometimes need to go into Nested If/Else statements or need multiple decisions using Elif or CASE statements

Image result for flowchart nested if

Best way to learn this…….practice code!

4.1.6 – Identify the condition associated with a given decision in a specified problem

4.1.7 – Explain the relationship between the decisions and conditions of a system

Depending on the condition that the input goes through determines the systems decision

4.1.8 – Deduce logical rules for real-world situations

We make many different decisions every day without even really thinking about it.

  • If I have not boiled the kettle then I will not pour the water into the cup for my tea.
  • Actually you would not pour the water in unless the tea has first been put in the cup!

4.1.9 – Identify the inputs and outputs required in a solution

This basically asks two questions.

  • What does the system need to output?.
  • What information does it require?
Image result for input process output

4.1.10 – Identify pre-planning in a suggested problem and solution

Imagine if we tried to complete everything we do without pre – planning.

Some of this you may not have even considered such as :

  • Cooking a meal without planning what ingredients you would need
  • Going on a long journey and not thinking about the fuel in your car
  • Just building a house without any plans

This has a whole host of problems from the product not being fit for purpose to a lot of wasted time and money.

It is therefore essential that we pre plan tasks

This could be in the form of GANNT charts, diagrams, sketches etc

Two keywords to remember here are:

  • Sequential – Doing one thing after another
  • Concurrent – Doing things at the same time

4.1.11 – Explain the need for pre-conditions when executing an algorithm

Preconditions are the things that must be true before a method is called

Postconditions are the things that must be true after the method is complete

4.1.12 – Outline the pre- and post-conditions to a specified problem

Withdrawing money from a debit account in ATM  

  • Preconditions: the sum being withdrawn should be smaller than or equal to the sum remaining on the account and smaller than the sum remaining in the ATM
  • Postconditions: the reminders of money in both ATM and on the account should equal their original values minus the sum being withdrawn

Programming example

int getSum(int a, int b)
{
int sum = a + b;
return sum;
}

  • Preconditions: The two given values are two valid integers.
  • Postcondition: is that the sum of those integers is returned and is in fact, an integer.

4.1.13 – Identify exceptions that need to be considered in a specified problem solution

“An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions.”

https://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html

An exception happens when something goes wrong. Tried to open a file but it doesn’t exist? You’ve got an exception.

Exceptions are bad things that weren’t supposed to happen. But since they do happen we need to deal with them. And that “dealing” is what we call exception handling.

Exception handling is an error-handling mechanism. When something goes wrong, an exception is thrown. If you do nothing, the exception causes your application to crash.

OR

you can choose to handle the exception. That is, you acknowledge that the problem happened, prevent the application from crashing, and take the steps necessaries in order to either recover from the error or fail gracefully.

4.1.14 -Identify the parts of a solution that could be implemented concurrently

concurrent is defined as “at the same time; simultaneously.”

Sequential is defined as “forming or following in a logical order or sequence”

https://www.vocabulary.com/dictionary/

When we do things often we can do more than one thing at a time. This increases our efficiency. On large scale tasks we can often work concurrently.

An example would be that on a web design project. 1 Team could be working on the Backend Database, Another team working on the structure/layout of the site and the third team working on the Design details (Such as CSS etc)

4.1.15 – Describe how concurrent processing can be used to solve a problem

This is pretty simple. Imagine only being able to one thing at a time.

  • Imagine eating your dinner before being able to have a conversation at the dinner table
  • Imagine a building project where only one thing can happen at a time
  • Imagine driving a car and not being able to listen to music

4.1.16 -Evaluate the decision to use concurrent processing in solving a problem

I guess a lot of this comes down to common sense. Dependent on what task we are doing if we use concurrency will it:

  • Save money / Cost more money
  • Save time / take more time
  • Increase/ decrease security

The main thing though to bear in mind though is that Concurrent processing requires well thought out planning and coordination. If this is not done correctly it can lead to serious problems.

Image result for joker walking away from hospital meme

4.1.17 – Identify examples of abstraction

You have probably had one of those conversations. It started with you asking a simple question. “Where is the party?”

The next minute the person gives you a 15 minute answer containing. Who is going, what food is there, who has had an argument with who, where the new twins who are going to the party are from and what their parents do for a living and finally…….the address of the party

Abstraction is to remove or ignore all unnecessary information and just act upon the details that are needed.

Imagine someone asking “When do you to want meet for a coffee today?”

An abstract thinker would typically say “I just need to get ready and ill be there”

A non abstract think would say “I need to get out of bed, I need to eat some Weetabix with a spoon, I need to brush my teeth with my new toothbrush etc……

Image result for stop talking meme

Take one more real-life example of abstraction which can be a TV remote. You know that when you press any button in remote, some function is applied on television e.g. change the channel, change the volume level etc. You are not required to know how internally remote works, to use it properly. It is an abstraction example.

4.1.18 – Explain why abstraction is required in the derivation of computational solutions for a specified situation

4.1.19 – Construct an abstraction from a specified situation

When you think of methods in Java. We can create a method called DoSomethingCool()

Providing we trust this method we can just simply call that method when we need it without having to worry about all the complex items that are within it.

Another example in Java, a HashMap stores key-value pairs. It provides you two methods get() and put() methods to store and retrieve key-value pairs from map. It is, in fact, the only information you will need if you want to use the map in your application. How it works inside, you are not required to know it to use it. This is very much example of abstraction in Java.

4.1.20 – Distinguish between a real-world entity and its abstraction

Abstraction is a design technique that focuses on the essential aspects of an entity and ignores or conceals less important or non-essential aspects.