ToDo App
This tutorial will guide you through creating a basic ToDo app. The app will add tasks, mark them as done, and filter them by status. We will build it three times: once with structured programming, once with functional programming, and once with object-oriented programming.
Structured programming uses loops and conditional statements to organize code. Procedural programming, an extension of structured programming, organizes code around functions. We will start with structured and procedural programming, focusing on writing clean code.
Next, we will use functional programming, which promotes a declarative style of coding and treats functions as first-class citizens. We will apply functional programming concepts like higher-order functions and closures to recreate the ToDo app. The ToDo app does not need functional programming, but rewriting it this way shows how functional programming works in JavaScript.
Lastly, we will use object-oriented programming, which organizes code around objects that contain data and behavior. We will create classes and use object-oriented programming concepts to rewrite the code. The ToDo app does not need object-oriented programming either, but rewriting it this way shows how object-oriented programming works in JavaScript.
Getting Started
Go to the basic-todo-app repository and click “Use this template” → “Create a new repository” to create your own copy. Name your repository basic-todo-app (or any name you prefer).
Clone your repository to your computer:
git clone <your-repo-url> basic-todo-app
cd basic-todo-app
code .
The template is a minimal starting point. It has a README, a .gitignore file, and a favicon image. In the first few sections, you will learn how to set up a complete development environment from scratch using Vite, Tailwind CSS, and Prettier.
If you get stuck at any point, you can view the complete solutions on the original repository:
master-spbranch — Structured Programming solution (sections 01-09)master-fpbranch — Functional Programming solution (sections 01-14)master-oopbranch — Object-Oriented Programming solution (sections 01-06, 15-19)
Learning Outcomes
- Set up, configure, and deploy a front-end project with Vite, Tailwind CSS, and Prettier
- Build a semantic, accessible, and styled HTML layout for a web app
- Implement application state and DOM rendering using structured and procedural programming
- Refactor a codebase into a functional programming style using higher-order functions, closures, and immutable data
- Refactor a codebase into an object-oriented programming style using classes, encapsulation, and modules
- Compare structured, functional, and object-oriented approaches to building the same application
Sections
- Setting Up the Project
- Configuring the Development Environment
- Deploying the Application
- Creating the Layout and Styling
- Building the Main Components
- Completing the Layout
- Structured Programming
- Filtering Todos
- Completing Todos
- Functional Programming
- Filtering and Immutability
- State Management Patterns
- Completing the Functional Implementation
- Adding More Features
- Object-Oriented Programming
- Encapsulation and Private Fields
- Static Members and Modules
- Building the TodoList Class
- Building the TodoApp Class
- Practice Questions