VNUHCM
Previous lesson Next lesson
  • Learning content
  • Help
    Do you have any questions while learning?
    Learning instructions Frequently asked questions Email for support
    • Tiếng Việt
    • English
    • Member's information
    • Registered courses
    • Log out
  • Cohota
  • HƯỚNG DẪN HỌC TẬP

  • View detail >>
    You have completed 0% of the course
  • HƯỚNG DẪN SINH VIÊN ĐĂNG NHẬP HỆ THỐNG
    • Hướng dẫn đăng nhập
    • Hướng dẫn vào khóa học
  • Introduction
    • Welcome
  • Unit 1: Values
    • Introduction - Unit 1: Values
    • Get Started With Values
    • Play with Values
    • Playground Basics
    • Naming and Identifiers
    • Simulation
    • Strings
    • Constants and Variables
    • Word Games
    • Build a PhotoFrame App
    • Design for People
  • Episode 1: The TV Club
    • Introduction - Episode 1: The TV Club
    • Searching for Content
    • Sharing Personal Information
    • Ordering Online
    • Reflection: Episode 1
  • Unit 2: Algorithms
    • Introduction - Unit 2: Algorithms
    • Get Started with Algorithms
    • Play with Programs
    • Functions
    • Types
    • Parameters and Results
    • Making Decisions
    • BoogieBot
    • Data Visualization
    • Build a QuestionBot App
    • Design an Experience
  • Episode 2: The Viewing Party
    • Introduction - Episode 2: The Viewing Party
    • Accessing the Show
    • Streaming on the Network
    • Reflection: Episode 2
  • Unit 3: Organizing Data
    • Introduction - Unit 3: Organizing Data
    • Get Started with Organizing Data
    • Play with Complex Data
    • Instances, Methods, and Properties
    • Arrays and Loops
    • Structures
    • Enums and Switch
    • Testing Code
    • Processing Data
    • Pixel Art
    • Password Security
    • Visualization Revisited
    • Build a BouncyBall App
    • Design a Prototype
  • Episode 3: Sharing Photos
    • Introduction - Episode 3: Sharing Photos
    • Capturing Images
    • Posting on Social Media
    • Reflection: Episode 3
  • Unit 4: Building Apps
    • Introduction - Unit 4: Building Apps
    • Get Started with App Development
    • Play with App Components
    • Color Picker
    • ChatBot
    • Rock, Paper, Scissors
    • MemeMaker
    • Build an ElementQuiz App
    • Design for Impact
  • Appendix
    • Episode Technical Concepts
    • Glossary
Course overview
Assessment

Progress
Criteria name Weighting (%) Score Progress (%)
Unit 1: Values

Naming and Identifiers

Unit 1: Values|Play

What you'll build

  • A program to count animals.
  • A program to figure out whether your friend’s concert will make or lose money.
  • A program to decide how you can use your time to have a better morning.

What you'll learn

  • Why writing code to solve a problem is preferable to writing things down and figuring out solutions on your own.

Key vocabulary

  • Assignment
  • Constant
  • Declaration
  • Identifier
  • Keyword

Introduction

People who are new to programming often think that coding is mostly about numbers. In fact, programmers actually spend much more time thinking about names. A programmer who sees an expression like 4 + 5 is usually more interested in what the 4 and 5 mean (are they minutes? marbles? grapefruits?) than that they add up to 9. Becoming skilled at naming will make you a much better programmer.

Go Build

Open the Naming and Identifiers.playground file in your course resources and follow the instructions.

Screenshot of the Naming playground

Reflection Questions

What might this code be calculating?

// Option 1

let total = 4 + (7 * 3)

Without good names for these values, ​a programmer—especially one who's unfamiliar with this code—has no idea what they represent. This code could be calculating anything from the distance of a sidewalk to the area of a rug plus a remnant.

What might this code be calculating?

// Option 2

let totalVideoDuration = introDuration + (clipDuration * numberOfClips)

Because the code above uses clear names for its values, anybody who reads it will know it calculates the duration of a video.

Why is it important to use clear names when writing code?

Summary

You might think programming is difficult because you have to keep track of different parts of a program in your head. Seasoned programmers struggle with this, too, but they make life easier by combining calculations into groups, giving names to those groups, and then combining group names into other groups. You’ve just experienced this in this lesson's playground exercises. You gave names to some ideas, such as calculated costs for concert tickets, and then used those names to do other things, like finding out whether your musical event was a financial success.

You also took a peek at some programming terminology, like expression and declaration, which you'll be seeing again as you continue to build your knowledge. These terms might seem a bit foreign at first, but don't worry—by the end of the course, you'll be using them to describe your code without even thinking about it.

Many programmers will tell you that naming is one of the hardest problems they face. Creating clear, descriptive names reveals the intent of your code. As a result, other programmers will be able to work with your code and collaborate with you more effectively. It'll also be easier to find the errors in your code. And when you return to code you wrote months earlier, you'll be able to recall your thought process. (Remember to include your future self when you think about those "other programmers.") It's always worth the time to think carefully about names when you code your projects.

Report error