πŸ§‘πŸΎβ€πŸ’» prep

πŸ“ Blog

Imagine that two people are writing a blog. Ahmed and Naima are writing a blog together about their struggles learning coding.

The published blog is live here πŸ‘‰ Educational blog

exercise

Explore the Educational blog. Click on the link on the site and check to see if it is working.

🧰 Development process

Ahmed and Naima are using the following development process for writing their blog:

  • writing the blog in a single file on a single computer
  • saving multiple versions of the file on the same computer
  • taking turns to use the computer during the day

At the moment, the computer has a folder with the blog that looks like this:

different-blog-versions

exercise

Describe some of the challenges that Ahmed and Naima face when trying to write a blog together in this way.

Create or join a thread 🧡 on Slack to share your answers. Did your cohort colleagues think of similar things?

βŒ› Version control software

Learning Objectives

To improve their way of working, Ahmed and Naima realise they need the following:

  • a way to both know what the most recent version is
  • a way to know what the old versions were, and in what order (i.e. how they got to the current version, and what content they may have deleted that they may want to get back)

To manage the different versions of the blog project, they decide to use Git.

definition

Git is version control software that allows developers to create and manage different versions of a project.

In Git, we create different versions of a project over time by creating commits.

A commit is a snapshot of our project at a particular point in time. You can also think of a commit as a particular version of a project.

Commits store the following information:

  • what changed in this commit
  • who created the change
  • what time the change happened
  • what the previous commit was

A typical timeline of commits might look like this:

commit-history

πŸ“ note

Commits also have a hash associated with them. A hash is a long string of characters used to identify a particular commit.

A typical hash will look like this: fec6909d6de23c75e77960986a9b6a7aee7feec7 but you will often see them abbreviated to the first 7 characters like this: fec6909

πŸ—„οΈ 🌐 Sharing history

Learning Objectives

Earlier on, Ahmed and Naima realised they also need the following:

a way to share the history of the project between different users and different computers

To share a project and its history, we can use an online platform called GitHub

GitHub is a platform where teams can store projects along with a history of their different versions.

By storing projects on GitHub, multiple users can gain access to the history of a project.

definition

On GitHub we call our project and its history a repository.

exercise

Explore πŸ”

In this exercise, you’ll need to explore a GitHub repository.

You’ll need to look around and figure out where to find different files and find out information about them.

⚠️ You won’t be expected to know what the files do at this stage.

Go to the following link: https://github.com/CodeYourFuture/education-blog

It will take you to a GitHub repository called education-blog.

Answer the following questions using the page linked to above:

a) View the README.md file. What do the instructions tell you? b) How many files are there inside the blogs folder? c) How many lines are there in the package.json file? d) Find the file with the blog content you can see on the live site here blog 1

You’ll learn more about these type of files throughout the course.

We can use the Github interface to explore the different commits (versions) of a project too.

exercise

Explore πŸ”

Go to the following link: https://github.com/CodeYourFuture/education-blog/commits/main

Try answering the following questions:

Go to the commit that says “add test p element to index page”

Questions

  • How many files were changed in this commit?
  • Who created the change?
  • What time did the change take place?

exercise

Explore πŸ”

Go to the following link: https://github.com/CodeYourFuture/education-blog/commits/main and locate commit that says “remove \ and # from start of paragraph”

Questions

  • How many files were changed in this commit?
  • What change was made in this commit?

πŸ” Check out a commit

Learning Objectives

Recall that a commit is a snapshot of our project at some point in time.

Therefore, we should be able to check out a previous version of our project and look at the files and folders there. We can use the Github interface to check out the files and folders at a previous commit.

exercise

Go back to this page https://github.com/CodeYourFuture/education-blog/commits/main

Locate the the commit with hash 4e78b32 and then look for the icon that that says “Browse the repository at this point in the history”. Explore the code at this point in the history. What differences do you notice?

Do the same but for the commit cd981a0.

πŸ“ Previous versions

We can view the different commits of a project on Github. This means we can see what the website looked like before, in previous versions.

exercise

Here are some different versions of the same educational backlog.

Deployed version A educational blog

Deployed version B educational blog

Deployed version C educational blog

Questions

  1. What is the difference between Version A and Version B on the index page (the page you first land on after clicking on the link)
  2. What is the difference between Version C and the main version of the site.
  3. Which commit from the education-blog repo correspond to Version C? Remember to check the git history.
  4. Which commit from the education-blog repo correspond to Version A?

🍴 Forking a repository

Learning Objectives

Often we want to take an existing project and start working on it independently. In other words: we start making our own versions of the project separate from the original project.

We may have a repo with the following url:

lesson1-github-url-anatomy

We might want to start creating our version of this project in isolation from the original project.

So we can create a fork 🧢 🧢 fork A fork is a copy of a repository that exists on Github .

When we create a fork on Github, the new forked repository gets a new url:

lesson1-forked-url-anatomy

exercise

🍴 Forking a repo

  1. Go to https://github.com/CodeYourFuture/education-blog.
  2. Find the Fork button on this page.
  3. Click on the Fork button to create a new fork of the repository and set yourself as the owner of the fork.

πŸ“‹ How can you check you successfully forked the original repository?

Hint: Check the URL of your forked repository

πŸ’» Working locally

Learning Objectives

We can also use Git on our local machine to perform similar tasks as we do on GitHub. So we need to address the following question:

question

How can we get a copy of an existing GitHub repository on our local machine?

In other words, we need to get a local copy of the repository which is on GitHub.

πŸ“ note

We call a local copy of a GitHub repository a clone.

The process of copying a remote repository on to a local machine is known as cloning.

A repository on GitHub is said to be remote.

A repository on our own computer is said to be local.

exercise

🎯 Goal: Clone a remote repository to your local machine

You’ll need to clone your fork of the education blog repo.

Follow through the steps in this video πŸ‘‰ https://www.youtube.com/watch?v=ILJ4dfOL7zs

πŸŽ—οΈ Reminder:
  • use the url for your fork of the education-blog repo when you are cloning
  • when selecting the location to clone your files, choose the CYF folder you created in the module prep

πŸ“˜ Viewing the files

Once you’ve got a local copy of a codebase on your local machine you can start to view the files and folders in that codebase. You can use a code editor like VSCode.

VSCode is an application that enables developers to view and edit files on their local machine.

exercise

Explore VSCode

  1. Figure out how to open the cloned repository on your local machine in VSCode.

  2. Explore the repository in VSCode and use the code editor to look at the various files and folders.

  3. Try opening the Integrated Terminal in your VSCode window

πŸ€” If you get stuck on any of these exercises, it’s a good idea to search online. For example, you could Google “opening terminal in vscode”

Here is a diagram representing how the repositories interact after forking and cloning:

fork-and-clone-diagram

🌳 Branching

Learning Objectives

We can check the commits on the remote repository as before:

commit-history

On the left page of the page, we see additional information:

main-branch-highlighted

So what is main?

main is a branch.

Commits form a sequence that look like this:

gitGraph commit commit commit

A branch represents a particular history of development in a project - the different versions there have been.

definition

A branch is a sequence of commits in a project.

There can be different branches with different names, which may have different versions.

For example, if we were testing out some different visual styles, maybe we would have one branch with some extra changes which make the website more blue, and a different branch with some extra changes which make the website more purple. These branches may share some commits in history, but have some extra different commits separately.

gitGraph commit commit branch "try-purple" commit commit checkout main branch "try-blue" commit

The main branch is often treated as a special branch - it’s where we put commits which people working on the project have agreed on. Other branches (e.g. the experimental purple branch) may have extra changes, and if people working on the project agree the changes are good, we’ll add those changes to the main branch.

When we’re working on something new, we haven’t agreed with other people that our new thing is good yet, so we often don’t add our changes to the main branch straight away. Instead we make our own branch to experiment on.

We can start to create independent branches like this:

gitGraph commit commit branch "week-1-coursework" commit commit commit

In the diagram above, we can continue to commit on the “week-1-coursework” branch without altering the history of the main branch.

exercise

Creating a local branch

  1. Open the education-blog repository in VSCode.

  2. Using this clip, create a new branch called update-blog-1 in your local repository πŸ‘‰ https://youtube.com/clip/UgkxvXsnm_98Rx0NUZq25apQWA6POccRoQzw

πŸ“‹ How can you check that you’ve successfully created a branch?

🎁 Wrapping up Git

Learning Objectives

activity

πŸ“‹ Double check the learning objectives from this section. Make a note of those objectives that you’re still struggling with.

Now you’ll need to create a commit.

You can use this video πŸ‘‰ https://www.youtube.com/watch?v=B8RSMBSzFuA to figure out how to create a commit.

We’ll cover this topic often in workshops. Come to a CYF center to work on this with a mentor.

  1. Try opening your clone of education-blog in VSCode
  2. Try fixing a typo in the README.md file
  3. Try using the video to create a commit of your work.

Recap HTML and CSS

Learning Objectives

Spaced Repetition

What are we doing now?

You’re going to use this prep time to answer some questions and schedule in times to review your understanding. In your planner or calendar, schedule a short (10 minute) review of your answers:

πŸ’‘ tip

  • One week from today
  • One month from today
  • Three months from today
  • Six months from today
  • One year from today

Do this now. Then move forward to working through as many of these questions as you can. (You may not complete them all, and that is ok.)

Write down your answers first and then update them after looking at the sample answers, if it’s useful to do so. Use all available tools to help you answer, and remember:

the point is not to complete the exercises the point is for you to secure your own understanding

Examples of tools you might use

What is HTML?

Learning Objectives

question

What is HTML?

HTML stands for Hypertext Markup Language. Markup means tags that go around content like text, pictures, videos, to “mark up” or describe what they are.

HTML tags look like this: <p>This is a paragraph.</p>. They typically surround a piece of content, like a block of text, and describe it as such. In this case, the <p> tag describes the content as a paragraph.

What are some examples of HTML tags?

Examples of HTML tags include <mark>, <section>, <header>, and <button>.

What does it mean to nest HTML tags?

Nesting is like Russian dolls - or tupperware - a box in a box in a box. We nest tags inside each other. That’s how we write HTML. For example:

<article>
  <header>
    <h1>Title</h1>
  </header>
</article>

Here the <header> tag is nested inside the <article> tag, and the <h1> tag is inside the <header> tag.

Not all tags are nested, in this example:

<article>
  <header>
    <h1>Title</h1>
  </header>
  <p>Some content</p>
</article>

Both the <header> and <p> tags are nested inside the <article> tag, but the <header> and <p> tags are not nested inside each other - they are siblings.

What are some examples of web browsers?

Chrome, Firefox, Safari, Lynx, JAWS, Brave, Edge, Vivaldi, Opera…

Here’s an interesting question: what does HTML produce in the browser?

It produces what we see - it produces a visual representation of the document. But in a little more detail: the browser parses the HTML we write, executes the linked Javascript, loads the CSS, media, and other resources, and produces a model of our document, called the document object model. It produces an API called the DOM.

It uses all of this information to decide what to show us.

What is parsing?

Make sense of. Analyse syntactically.

What is syntax?

The rules that structure language, so it can be understood by someone else. I put words in an order, according to rules, I structure meaning and you can get that meaning back out if you know the same rules. Programming languages are the same - they each have a set of rules, they each have a syntax.

Think about HTML and CSS. They use different syntaxes.

For instance, when grouping together the information about an HTML tag, you may write: <h1 class="main-title">This is a title</h1> - there are several pieces of syntax here, and one is that the tag is opened by <h1> and its contents are done when you see </h1>.

In CSS, on the other hand, you may have a rule like h1 { color: red; } - we group together declarations applying to the selector between {}s.

HTML and CSS use different syntaxes, even though some of the concepts are similar.

What is an API?

API stands for Application Programming Interface.

Imagine you want to know what the weather is going to be tomorrow. You may have an app in your phone which can tell the weather, but it doesn’t know the weather everywhere - it will ask some service on the internet.

That service on the internet is an API. The service on the internet can be asked specific questions. Maybe it can be asked “What will the temperature be tomorrow in London?” or “Tell me the next week’s temperatures for every city in the UK?” or “When will it next rain in Glasgow?”.

And when you ask a question, you need to know how to interpret the answer. If you ask “When will it next rain in Glasgow”, and get back an answer of “5”, what does that mean? In 5 minutes? In 5 hours? It’s been raining for the last 5 days?

The service may have a lot of knowledge, but it can only be asked specific questions. And the app on your phone needs to know how to interact with it. “What can I ask/tell the API?”, “How do I ask/tell it those things?”, and “How should I interpret the answers I get back?” are all good things to think about when thinking about an API.

The DOM is an API. From our code, we can tell it things (like “All h1 tags should be blue”), and it will take action as a result. One of the ways we can interact with the DOM API is by giving it a CSS file - it will apply the CSS file when it’s working out how to display a page. The CSS specification helps us understand how we can interact with the API - what we can tell it, and how we tell it those things.

What is semantic HTML? What does semantic mean?

Semantics means meaning. Semantic HTML is meaningful code: each piece of data marked up with correct, that is to say, descriptive tags. A heading has an h1 tag. A button has a button tag. There are only two html tags that deliberately have no meaning (div and span).

These tags are then interpreted by APIs to give functionality to the page. A button tag is interpreted by the browser as a button, and so it can be clicked, or triggered in many ways. A heading tag is interpreted by the browser as a heading, and so provides a traversible page outline to a screen reader.

HTML tags are powerful because they are meaningful. They are meaningful because they are semantic. Semantic HTML is powerful HTML.

Why is semantic HTML important?

HTML tags are powerful because they are meaningful. They are meaningful because they are semantic. Semantic HTML is powerful HTML.

The better structured your document, the more meaning you can pack into it, the more powerful your code is, the better it will work in more contexts, and more things will be able to interface with it. The more meaning you put in, the more meaning other readers can get out.

What Is CSS

Learning Objectives

question

What is CSS?

Cascading Style Sheets are a language of style - a visualisation of the DOM - using selectors, properties, and values in rulesets.

A ruleset is made up of a selector and a declaration. A declaration is made up of at least one property and value pair. This is the syntax of CSS.

What is a selector, property, and value?
selector {
  property: value;
}

Selectors look like this: p { background: red }. The selector is the p in this case. This p selects all elements of the DOM tree called p and sets a rule about how to show them. Selectors always come first in a ruleset.

A property is a quality, a characteristic. A value is the amount.

For a person, you might say their ‘age’ property has the value of 40. For an element, you might set the width property to the value of 100%.

How do you know what properties and values there are?

You learn them by using them. You look it up here: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference. And the other thing you can do is look at the autocomplete in Devtools.

Why is CSS a 'cascading' style sheet? What does cascade mean?

via GIPHY

A cascade is a stream or sequence of a things where each thing affects the next. You might imagine pouring champagne into a tower of glasses. The champagne flows into the top container; it then cascades into the next container; etc. In CSS we’re actually pouring from many bottles into one tower.

So in CSS ’the cascade’ means the order or sequence of the rules as they flow into the DOM tree according to CSS precedence.

What does precedence mean?

It means hierarchy. One hierarchy in CSS is inheritance: children inherit from parents. If a parent node has red text, all its children will inherit that red text color. But when another rule comes after, and overrules, it takes precedence. Everything in CSS is determined by order.

Order is so important in CSS because CSS is a declarative programming language that programs the layout of boxes.

CSS renders the nodes in our DOM tree as nested boxes, and we program their appearance using fonts, colours, and spacing.

What does declarative mean?

It means, broadly speaking, that the entire code is processed and then applied, from top to bottom in one go. You don’t write for loops or if/else statements; there are no functions as such; you just declare the outcome.

In CSS you do the ‘what’, and the browser does the ‘how’.

What is specificity?

Specificity is a weighting system for CSS rules. The more specific your selector, the more power it has. For example: IDs can only ever mean one node. IDs are unique, so they are more specific than classes, which could mean many nodes.

Classes added to html element are more specific than just a plain element selector, as a class of p is more specific than just all p. If you get two elements with the same specificity then the one that comes last in the order wins.

The browser sorts all your rulesets, or declarations, into a defined order according to the power, or weight, of the declaration and applies the result, like a game of cards where higher value cards beat lower value cards.

Stronger rules override weaker rules. Everything is sorted and sorted until eventually a final value wins out and the view is rendered. The browser sorts like this:

  1. Match the media
  2. Sort by origin
  3. Sort by specificity
  4. Sort by document order
What do we mean by order?

Order means ‘what comes first?’.

Another way to think of β€˜earlier and later’ is β€˜farther and nearer’. The closer the declaration is to the node in the DOM, the β€˜later’ it is in the CSS. So an inline style overrides a style set in a style block, which overrides a stylesheet linked in the head, which overrides any stylesheet linked higher up in the head, which all ultimately overrides the user agent style that comes in the browser.

What does specify mean?

Identify clearly. Name explicitly.

What does render mean in context of a browser?

Render means to hand over, actually - to give back. In the browser, it means to show the result of all these computations we have talked about. It turns the code into pixels and paints them on your screen. So it’s the end result - the final face.

Backlog

Learning Objectives

In software development, we break down complex projects into smaller, manageable parts, which we work on for a week or two. These periods are called “sprints.”

A sprint backlog is like a to-do list. It lists what the team has decided to work on this sprint. It’s chosen from a larger list, usually called the “product backlog,” which holds the entire project to-do list.

For your course, the mandatory work has been scheduled already. You will add any other tickets you want to work on to your backlog and schedule them according to your own goals and capacity. Use your planning board to do this.

You will find your backlog in the Backlog view on every sprint.

Copy the tickets you are working on to your own backlog. Organise your tickets on your board and move them to the right column as you work through them. It’s a flowchart:

flowchart LR Backlog --> Ready Ready --> in_progress in_progress[In Progress] --> in_review in_review[In Review] --> Done

activity

  1. Find the sprint backlog
  2. Copy your tickets to your own backlog
  3. Organise your tickets on your board