Learning Swift — Day 164

Moving on after Hacking with Swift

AP Computer Science Principles with Swift

The learning part of this new journey starts here with this just released book by Apple. I will start it and, if it proves to be bad I will just drop it but I am too curious to let it slip and, most of all, I lack Computer Science training, I need it to learn how to think!

Hacking with Swift was really great but it was not really explaining the core of things. Paul said we didn’t need them at that time and we all believe him, due to his immense experience, but in my articles I have always tried to browse the Documentation and help people out on what was missing there.


This course will be about planning, testing and designing algorithms to get the logic of our program do what we want it to do! We will learn about the app design cycle and about the debugging process, which in turn gives way to the practicing of fundamental skills in the fields of communication, analysis and collaboration.

One thing that is normally left out in CS courses is the acquisition of a deep understanding of how tech innovations impact our society, in both a beneficial and harmful way.

About This Course


During this course we will learn to become good critical thinkers and good problem solvers, which — if you have ever read a job posting — are among the first requirements for many, too many jobs! This will also be a good life lesson for me as I have never been taught in the Italian school about how to think creatively or to think critically. We all had to perform for a final mark, whether or not that knowledge stuck or not, it was not their problem! This course will propose big problems and teach us how to break them down into smaller ones.

Problem solving is how this skill is mainly defined in the wild. If we think about life, we get stuck every day in something and we either stop there and die or, if we reached the following day, we learned how to solve a problem or work around it. So, problem solving is the art of learning how to get unstuck. Frustration will be a fundamental part of this journey. Without getting stuck, without failing, there will be no learning, no success at all!

Even if I will be following this course alone as I have no classmates around me, collaboration with others will be another crucial skill. Whatever we will be doing, it will be better if we share it with the world and look for their opinion. This is why I will create a GitHub repository of the working folder for this course so you will be able to follow along with me and even collaborate on the projects.


This is the first ever course in Computer Science written in Swift and it is such a great addition to the available material.

One of the main things a programmer has to do while learning or doing his/her job is to abstract. An abstraction groups things together, allowing us to think of the group as one easier-to-remember thing instead of trying to reason about all the elements separately. The way programmers use this concept is to make decisions and to think out loud about code without letting it overwhelm them with its complexity.

The next concept to grasp will be the meaning of the word algorithm, which often scares us but that, in the end, is just everything we ask the computer to do! In short, an algorithm is a series of steps that performs a task. Beside algorithms we will learn how to write pseudocode, which is a way to describe code patterns without worrying about whether it follows the exact rules of the programming language we are using or not. It is a way of describing what we want to achieve and how before translating that into “machine code”.

When algorithm will fail us we will proceed through a technique known as heuristic which, in normal plain language means to enable a person to discover or learn something for themselves but, in computer science, it means to proceed towards a solution of a problem by trial and error or by rules that are only loosely defined.

Practicing algorithms will mean practicing their building blocks, which are sequencing (the order of things), selection (execution under certain conditions) and iteration (repetition under certain conditions).


We will be using the Swift programming language inside of the Xcode Integrated Development Environment. I will start using version 10.3 until version 11 exits the crazy period of beta which is undergoing, with changes to the core of the language almost every week.

Unit 1: Introduction to Coding

In this unit we will get a grasp at using Xcode and the Playground (but I will skip all of the things I already know and feel sure about).

The main concepts will be how to express a value and manipulate it, using the proper naming and identifiers (which will be a nice review for me)

1.1 : Topic in Focus: How Computers Work

In this unit we will learn how binary values behave like tiny switches within a computer to store and process data, what the key components of a computer are and how they work together and which devices work together to form computing systems.

So, what is a computer? As Steve Jobs once said it is simple a bicycle for the mind. It doesn’t do anything we couldn’t do on our own, it just makes it easier and faster. At the very base, a computer is simply a collection of on/off switches but, the most important thing to understand is, computers are organised so that some switches can control others.

Computers represent data in binary, which is a way of counting that uses just zeros and ones. Each of those digits is called a bit, a short-term expression for “binary digit”.

Logic Gates are combinations of transistors that, properly configured, allow us to perform Boolean logic, that is, true/false logic. By combining multiple logic gates together we can create a binary adder, a circuit that performs addition and subtraction of binary numbers. Other operations are performed by combining gates in different ways.

The circuit used to store a single bit is called a flip-flop, and a group of those is called a register. Modern registers can store 64 bits of binary data.

Circuits are then brought together to form functional units, objects that perform a set of related tasks, such as the ALU (arithmetic-logic unit) which is there to perform mathematical and logical operations.

The heart of the computer is the central processing unit or CPU; it controls everything else by taking in data and processing instructions, executing them and producing output. Some other units inside the CPU are the one which decode and execute instructions, the one which stores data internally as its being processed and the one the is responsible for taking such data into and out of the CPU.

The CPU resided on a physical piece of silicon called the microchip. All its components are brought together during manufacturing in the fabrication process.

Another fundamental component is the RAM (Random Access Memory), also known as working memory, where the computer stores the data it’s currently processing. RAM memory is volatile (i.e., when the computer is turned off it is erased), while internal storage is nonvolatile. Saving a file writes it to storage, while opening it reads it from storage into RAM.

All these elements are mounted on the logic board.

1.2 Explore Task Practice 1

This chapter speaks about how technology impacts people differently depending on their identity, abilities, culture and more.

I am not sure what this AP® exam is, but from what I read this book is aimed toward a class of students in their first semester of college at a CS faculty or in the high school. I will not report here about the written assignments as my goal is simply about learning these principles and, most of all, my time is severely limited!

1.3 Create Task Practice 1

In this course we will get two Create practice tasks which will make us cover the role of a lead designer for an app. These are the key priorities for this role:

  • consider who the audience is and what’s important for them
  • know how to put oneself in someone else’s shoes
  • think about how the user will understand and interact with the content
  • be able to assess and improve on one’s own work

Inside the folder of content that we downloaded there is a Keynote file called “App Design Journal”. Open it now and go through the first two sections, Brainstorm and Plan.

These were two very interesting chapter and helped me refine some of the ideas I had. One thing I will need to do tomorrow when I come back to this will be reviewing the Human Interface Guidelines. I have always wanted to read them thoroughly, but never had the chance to really stop by and do that!

So, see you tomorrow for the continuation of this journey!

If you like what I’m doing here please consider liking this article and sharing it with some of your peers. If you are feeling like being really awesome, please consider making a small donation to support my studies and my writing (please appreciate that I am not using advertisement on my articles).

If you are interested in my music engraving and my publications don’t forget visit my Facebook page and the pages where I publish my scores (Gumroad, SheetMusicPlus, ScoreExchange and on Apple Books).

You can also support me by buying Paul Hudson’s books from this Affiliate Link.

Anyways, thank you so much for reading!

Till the next one!

Published by Michele Galvagno

Professional Musical Scores Designer and Engraver Graduated Classical Musician (cello) and Teacher Tech Enthusiast and Apprentice iOS / macOS Developer Grafico di Partiture Musicali Professionista Musicista classico diplomato (violoncello) ed insegnante Appassionato di tecnologia ed apprendista Sviluppatore iOS / macOS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: