VNUHCM
Bài trước Bài kế tiếp
  • Nội dung học
  • Trợ giúp
    Bạn có thắc mắc khi đang học?
    Hướng dẫn cách học Những câu hỏi thường gặp Email cho giáo vụ
    • Tiếng Việt
    • English
    • Thông tin Thành viên
    • Khoá học đăng ký
    • Đăng xuất
  • Cohota
  • HƯỚNG DẪN HỌC TẬP

  • Xem chi tiết >>
    Bạn đã hoàn thành 0% khoá học
  • 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
Tổng quan điểm khóa học
Đánh giá

Tiến độ
Tên tiêu chí Trọng số (%) Điểm Tiến độ (%)
Unit 3: Organizing Data

Testing Code

Unit 3: Organizing Data|Play

What you'll build

Documentation and tests for code.

What you'll learn

  • How built-in types are not perfect representations of the data they represent.
  • Why documentation and testing are important.
  • How to test a function.

Key vocabulary

  • Overflow
  • Testing

Introduction

Your code doesn't always work as you expect it to. Sometimes the fault is yours—you made a logical error while designing your algorithm, or you made a typo when writing your code. And sometimes the fault lies in the system—the way the computer represents basic data or the way an API works.

In either case, testing your code will help you detect these errors and make sure that your functions behave predictably. In this lesson, you'll discover more about the limitations of existing systems and the ways you can (and should) protect yourself against bugs.

Go Build

Open the Testing Code.playground file in your course resources and follow the instructions.

Screenshot of the Testing Code playground

Reflection Questions

Are there other types built into Swift and the Foundation framework that have limitations?

Are there types without limitations? How might you categorize them? (The Types lesson is one place to find other built-in types.)

Why is testing important? How can testing affect the development process as your code grows bigger and more complex?

How can you write good documentation for your code? How can you apply documentation beyond just describing how your functions work?

Summary

As you tackle more complex challenges in the rest of this course, think about the ways you can document and test your code. Documentation in particular might seem like wasted effort, but it's a surefire way to minimize confusion when you revisit your code later or when you want somebody else to look at it. Without going overboard, consider how you can write comments to document top-level things like structs and functions, as well as their inner workings.

Someday you'll thank yourself for taking that extra effort to document your code—and that day might come sooner than you think.

Báo lỗi