Prep

Do the Prep

You should have completed the prep listed in Welcome to CodeYourFuture. If you haven’t done that yet, go back and complete it now.

🧠 You must always do the prep.

If you have worked through the Welcome prep, begin the prep for the first Onboarding sprint (which starts here!).

πŸ€” Where do you start with a new module?

Inspecting 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 - Explore a Commit

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.

Inspecting previous versions

Learning Objectives

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

✍️Exercise - Comparing Previous Versions

Here are some different versions of the educational blog we introduced in the previous module.

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 corresponds to Version C? Remember to check the git history.
  4. Which commit from the education-blog repo corresponds 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 can create a fork. A fork is a copy of a repository that exists on Github.

A GitHub repository’s url looks like this:

https://github.com/CodeYourFuture/cyf-demo-repo

Like any url it is made up of different parts.

flowchart LR subgraph "πŸ“ domain" B end subgraph "πŸ‘€ username" C end subgraph "πŸ“ repo" D end A[πŸ”— https://] --> B[github.com] B--> C[CodeYourFuture] C --> D[cyf-demo-repo]

When the user EagerLearner forks this repo, the path changes from CodeYourFuture to EagerLearner.

flowchart LR subgraph "πŸ“ domain" B end subgraph "πŸ‘€ username" C end subgraph "πŸ“ repo" D end A[πŸ”— https://] --> B[github.com] B--> C[EagerLearner] C --> D[cyf-demo-repo]

✍️Exercise - Fork 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

Before we can work on it we need to get a local copy of the education blog repo. A repository on GitHub is said to be remote and a repository on our own computer is said to be local.

We call a local copy of a GitHub repository a clone. The process of copying a remote repository on to a local machine is called cloning.

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

flowchart TD subgraph Remote["Remote (GitHub)"] A["CodeYourFuture/education-blog"] -->|fork| B["EagerLearner/education-blog"] end B -->|clone| C subgraph Local["Local (your computer)"] C["YOUR_CYF_FOLDER/education-blog"] end %% Style definitions classDef container stroke-dasharray:5 5,fill:#f8f9fa,stroke:#495057 classDef rounded rx:10,ry:10,fill:#e9ecef,stroke:#495057 classDef arrow color:#0d6efd,stroke-width:2px %% Apply styles class Remote,Local container class A,B,C rounded linkStyle 0,1 stroke:#0d6efd,stroke-width:2px

Sketch this diagram in your notebook. If you get confused about where your changes are you can refer back to this diagram to help you understand what’s happening.

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

✍️Exercise - Cloning a Repository

You’ll need to clone your fork of the education blog repo. Follow through the steps in the video “How to clone a repository from GitHub to Visual Studio Code”.

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 files from a git clone

Learning Objectives

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 using VSCode.

✍️Exercise - Explore a repo using 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”

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: Branch

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" checkout "try-purple" commit commit checkout main branch "try-blue" commit checkout main commit 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 try-purple branch) may have extra changes that have not been agreed on. If people working on the project agree the changes from the purple branch 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.

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

Merging

Learning Objectives

TODO:

  • Define “merging”
  • Show GitHub UI for a branch compared to main
  • Show PR UI
  • Show merging

πŸ”— Set up Planner

Welcome to your coursework planner

This is how you will plan and manage your coursework at CYF. You will add all your work as issues to your fork of this repository, and then use a project board to manage your work. This is broadly how all technical projects are managed, so you will need lots of practice. Get started today.

1. How to get set up

Forking the My-Coursework-Planner repo

  1. Fork this repo to your own GitHub
    image
  2. You should see your own GitHub username under Owner
    image
  3. Turn on issues in the Settings of your forked version of the repo
    image

You must fork to your personal Github account. Forks created in the CYF org will be deleted by a bot.

Creating your project board

  1. Go to the example project board
  2. Click the three-dot menu on the Coursework Planner Board then select Make a copy
    image
  3. Make sure your own GitHub username is under Owner and change the name to “Coursework Planner”. These steps are very important! If either value is incorrect the issues will not be cloned correctly.
    image
  4. If you make a mistake naming your project you can go back and change it later. Hover your cursor over the board’s name then click the pen icon which appears.
    image

On the next screen you can rename your board to “Coursework Planner” and save your changes.

image

  1. Make your project board public so your mentors can see your progress - open the project board settings
    image
  2. Scroll to the bottom to find the setting to make your board public
    image

Linking the My-Coursework-Planner repo to your project board

  1. Go back to your forked version of the My-Coursework-Planner repo
  2. Under Projects, click Link a project and select your project board
    image
  3. That’s it! You’re ready to start adding issues to your board!

2. In every module, you will add your work as issues

Each sprint in each module has a Backlog page which lists the work you’re expected to do for that module. Every item in the list is actually a GitHub issue.

There is a “Clone” button next to each issue. When you’re starting a sprint, clone each of its issues into your coursework planner.

Copy issues for each week or at most for each module. The coursework content is updated frequently, you will not have the most up to date tasks on your board if you copy all modules at once.

If the Clone button isn’t working you can send a message in Slack asking for help, or speak to a volunteer in class on Saturday.

3. Manage and adapt your project board as you learn

There are example project boards attached to each module, showing you ways you can use boards to manage your time, prioritise, scope, and track your work. You should use the same project board all the way through the course, and add to it as you go. Learn as you go, and adapt your board as you learn.

You can, and should, also add your own tickets to the board. Just remember it’s a public board, so don’t add anything you don’t want to share with your mentors.

You can watch this video about how to create your coursework-planner board.

What are forms?

Learning Objectives

These questions and answers are compiled from recorded sessions on HTML forms, and are the collective contribution of several mentors and students. This time we’ve included a trainee answer and a mentor answer, per question.

10 Things About Forms

So let's go deep on forms. What is a form? What does form mean?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: What does form mean? It’s like a set of options for a user to choose from on a website.

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Yes, that is true, that is a correct answer. A deeper answer might be form means shape. It’s how we define the shape of data. So, imagine a shape sorter. You put a square thing in the square hole; you put a round thing in the round hole. Each form field is a different shape in the shape sorter lid. That’s what we’re doing when we write forms. We are forming data with fields.

Why do we do that? Why do we bother grouping and shaping data in that way?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: Of course because it makes it easier to sort it out.

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Yeah, absolutely! Because you know we’re going to post that data to a database. Our database doesn’t know what all these strings mean. We have to define the data. We have to label the data. We have to group it, and we have to do something with it: to post it to a database or in some cases, get it from a database.

So that’s the point of all this.

What does field mean?

πŸ‘©β€πŸ’»πŸ’¬ Trainee: Field? It means like the window is completed with some information. A piece of data.

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Right! You put a piece into a form field; you just put one thing in there. A form has many fields, and a field is a single piece of data. It is the smallest piece.

So we structure data with forms. And we do that by defining form fields with semantic HTML.

πŸ“Now practise with

Now practise with How to structure a web form
What else do we structure, when we write an HTML form?

πŸ§‘πŸ»β€πŸ’»πŸ’¬ Trainee: Gathering data you mean? I’d be doing a search…

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: Can I say? We can structure… an action, a connection.

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Ooh, that’s a great answer. We can structure interaction. We tell the user, what to put in the form field, and how to put that data in. We structure a really specific kind of interaction. We guide them and tell them what to do. And the way that we structure those interactions is, again, using form fields. Using HTML form elements, attributes, and values.

That’s really important to think about, because when you’re deciding what to write in a form, you need to start with ‘what data do I need.’ It’s better to do that than to try and memorise all the different types of form fields. If you think:

flowchart LR 1[What data do I need] --> 2[What interaction am I building] --> 3[What element do I need to achieve 1 and 2]

Then look up that last part. That’s more effective than trying to memorise all the different types of form fields.

But saying that, let's name some form fields now -- some elements in HTML that we can use to structure data. I'm going to say, input of type text. Name a bunch more.

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: Yeah, maybe checkbox?

πŸ‘©πŸΌβ€πŸ’»πŸ’¬ Trainee: radio button.

πŸ‘¨πŸΏβ€πŸ’»πŸ’¬ Trainee: submit input type, could be submit or button itself.

πŸ‘©πŸ½β€πŸ’»πŸ’¬ Trainee: autocomplete?

πŸ‘¨πŸ»β€πŸ’»πŸ’¬ Trainee: I think autocomplete is an attribute, but it’s not itself an element or element type? How about textarea ?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: select and option

πŸ‘¨β€πŸ’»πŸ’¬ Trainee: The input of type password

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: The point being that there are absolutely loads of different form elements!

What you need to focus on is what you’re actually doing. We’re structuring data: you are defining, naming and then grouping data. Keep that goal front and center, then your forms will work well.

πŸ“Now practise with

Oh and... what does input mean?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: Input means to put something in. In this case the data we put in the form.

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Bang on.

What happens when things don't work well. What happens when the user puts the wrong thing in a field?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: Do you mean validation? Don’t we need JavaScript for that?

πŸ§‘πŸΎβ€πŸ’»πŸ’¬ Mentor: We’ll learn about validation with JavaScript later on, but there’s actually a lot of validation built in to HTML. For example, if you put a required attribute on a field, the browser will not let you submit the form until you fill in that field. That’s validation: it checks against rules and rejects the data if it doesn’t meet the rules.

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: But then aren't all form elements validation?

πŸ§‘πŸ½β€πŸ’»πŸ’¬ Mentor: You could say that all the rules you make about what the user can put in a field are also validation. Every type we just named - input type checkbox, input type email, number, date… are rules about data.

I think the difference is that there’s no way to type into a checkbox: there’s no error message, you just can’t do it. If you type your birthday into an email field, the browser will tell you that’s not a valid email address. So one is just impossible to do and the other gives you an error message, and that’s normally what we mean by validation.

Why is it important to validate data?

πŸ‘¨πŸ»β€πŸ’»πŸ’¬ Trainee: Because if you don’t validate it, you might not be able to use it?

πŸ§‘πŸΎβ€πŸ’»πŸ’¬ Mentor: Right. Forms go wrong when you are vague. You must enforce input with validation, because if users can get it wrong, they will.

What will happen if you put a type of text on an input you label with email?

πŸ‘¨πŸΎβ€πŸ’»πŸ’¬ Trainee: Oh well then people will write in things that aren’t email addresses?

πŸ§‘πŸΏβ€πŸ’»πŸ’¬ Trainee: And you won’t know until you try to send them an email…

πŸ‘©πŸ»β€πŸ’»πŸ’¬ Mentor: Yeah they will. You can be absolutely guaranteed that users will do that. You have to save them from themselves, and save your database from your users!

Little Bobby Tables

πŸ“Now practise with

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.

In this course, the backlog is a set of work designed to build understanding beyond the concepts introduced in the course prep. For your course, we have prepared a backlog of mandatory work for each sprint. You will copy these tasks into your own backlog. You can also add any other tickets you want to work on to your backlog, and schedule all of the tasks according to your own goals and capacity. Use your planning board to do this.

You will find the 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. Here’s a flowchart showing the stages a ticket goes through:

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

πŸ•ΉοΈBacklog (30 minutes)

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