10 Development Tips Mọi Developer Cần Biết

Sau 3 năm học IT và làm các dự án thực tế, mình nhận ra có nhiều thứ trường không dạy nhưng cực kỳ quan trọng. Bài này tổng hợp 10 tips giúp bạn code tốt hơn, làm việc hiệu quả hơn! 💪

1. 🔍 Google-fu Là Kỹ Năng Quan Trọng Nhất

90% công việc của developer là... Google 😂 Nhưng phải Google đúng cách!

❌ Google Kiểu Newbie:

  • "node js error"
  • "code không chạy"
  • "fix lỗi javascript"

✅ Google Kiểu Pro:

  • "TypeError: Cannot read property 'map' of undefined" (Full error message)
  • "discord.js v14 event handler not working" (Specific version + issue)
  • "mongodb connection refused ECONNREFUSED site:stackoverflow.com" (Search specific site)

Pro Tip: Thêm "site:stackoverflow.com" hoặc "site:github.com" để search targeted hơn!

2. 📝 README.md Là Người Bạn Tốt Nhất

Mỗi project phải có README tốt! Sau 6 tháng bạn sẽ quên cách setup project của mình 😅

README Chuẩn Phải Có:

# Project Name

## 📖 Mô Tả
Giải thích ngắn gọn project làm gì

## 🚀 Cài Đặt
```bash
npm install
npm run dev
```

## ⚙️ Cấu Hình
Copy `.env.example` thành `.env` và điền thông tin:
- BOT_TOKEN=...
- DATABASE_URL=...

## 📂 Cấu Trúc
```
src/
  ├── commands/
  ├── events/
  └── utils/
```

## 🐛 Known Issues
- Issue #1: ...
- Workaround: ...

## 📝 License
MIT

3. 🎨 Git Commit Messages Phải Có Ý Nghĩa

❌ Commit Messages Tệ:

git commit -m "update"
git commit -m "fix bug"
git commit -m "asdasd"
git commit -m "done"

✅ Commit Messages Tốt:

git commit -m "feat: add user authentication"
git commit -m "fix: resolve memory leak in event handler"
git commit -m "refactor: optimize database queries"
git commit -m "docs: update API documentation"

🎯 Convention:

  • feat: - Feature mới
  • fix: - Fix bug
  • refactor: - Refactor code
  • docs: - Documentation
  • style: - Format code
  • test: - Tests

4. 🚫 .gitignore Ngay Từ Đầu

Đừng commit những thứ không cần thiết! Mình từng push file .env lên GitHub và phải regenerate tất cả tokens 😭

Node.js .gitignore Template:

# Dependencies
node_modules/

# Environment
.env
.env.local

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# IDE
.vscode/
.idea/

# Build
dist/
build/

5. 🔧 VS Code Extensions Phải Có

Những extensions này giúp mình code nhanh hơn 3x:

ESLint

Bắt lỗi code realtime

Prettier

Auto format code đẹp

GitLens

Git history trong editor

Live Server

Preview HTML realtime

Error Lens

Hiển thị error inline

GitHub Copilot

AI code assistant

6. 💻 Terminal Shortcuts

Ngừng dùng chuột cho mọi thứ! Shortcuts giúp bạn nhanh hơn:

Windows/Linux:

  • Ctrl + C - Stop process
  • Ctrl + L - Clear terminal
  • Tab - Auto-complete
  • ↑/↓ - Previous/next command
  • Ctrl + R - Search command history

Useful Commands:

# Clear terminal
clear

# View file content
cat filename.txt

# Find process by port
netstat -ano | findstr :3000

# Kill process
taskkill /PID [pid] /F

# Git shortcuts
git status  →  git st (alias)
git commit  →  git ci
git branch  →  git br

7. 🐛 Debug Đúng Cách

❌ Console.log Everywhere:

console.log('here 1');
console.log('here 2');
console.log('data:', data);
console.log('user:', user);
console.log('asdasd');

✅ Dùng Debugger:

// VS Code debugger
// 1. Đặt breakpoint (click vào line number)
// 2. F5 để start debug
// 3. F10 step over, F11 step into

// Chrome DevTools
debugger; // Code sẽ pause ở đây

// Console tips
console.table(arrayOfObjects); // Hiển thị dạng table
console.time('loop'); 
// ... code ...
console.timeEnd('loop'); // Đo thời gian execution

8. 📚 Đọc Docs Trước Khi Hỏi

Mình biết docs đôi khi khô khan, nhưng nó luôn chính xác nhất! 📖

Quy trình giải quyết lỗi:

  1. Đọc error message kỹ
  2. Google full error message
  3. Check official docs
  4. Search GitHub issues
  5. Hỏi trên Stack Overflow (với context đầy đủ)
  6. Hỏi trong Discord community

"Đừng hỏi 'code này sao không chạy' mà không show code. Không ai có năng lực ngoại cảm cả!" 😅

9. 🔄 Refactor Thường Xuyên

Code working không có nghĩa là code tốt! Refactor để code dễ đọc, dễ maintain hơn.

Ví dụ Refactoring:

Before (Messy):

function calc(a, b, c) {
    if (c == 1) {
        return a + b;
    } else if (c == 2) {
        return a - b;
    } else if (c == 3) {
        return a * b;
    } else {
        return a / b;
    }
}

After (Clean):

const operations = {
    add: (a, b) => a + b,
    subtract: (a, b) => a - b,
    multiply: (a, b) => a * b,
    divide: (a, b) => a / b
};

function calculate(a, b, operation) {
    return operations[operation]?.(a, b) ?? null;
}

// Usage
calculate(10, 5, 'add');      // 15
calculate(10, 5, 'multiply'); // 50

10. 🎯 Learn By Doing

Đọc tutorial cả ngày mà không code = vô dụng! Học bằng cách làm project thực tế.

Roadmap Học Hiệu Quả:

Tháng 1-2: Basics

  • HTML, CSS, JavaScript fundamentals
  • Project: Portfolio website (như của mình đây!)

Tháng 3-4: Backend

  • Node.js, Express, MongoDB
  • Project: Simple REST API (Todo app, Notes app)

Tháng 5-6: Integration

  • Discord Bot, Telegram Bot
  • Project: Bot với database (như Ma Đạo Bot của mình)

Tháng 7+: Specialize

  • Chọn direction: Frontend (React), Backend (APIs), DevOps, Mobile...
  • Project: Cái gì bạn passionate nhất!

💡 Bonus Tips

11. Backup Code Thường Xuyên

  • Push lên GitHub mỗi ngày
  • 3-2-1 rule: 3 copies, 2 media types, 1 offsite

12. Học Từ Code Của Người Khác

  • Read source code của open-source projects
  • Xem cách họ structure, handle errors, comment...

13. Join Communities

  • Discord servers (như Ma Đạo Community 😊)
  • GitHub discussions
  • Stack Overflow
  • Dev.to, Reddit r/programming

14. Take Breaks!

Debug 3 tiếng không ra → Nghỉ 30 phút → Quay lại fix được trong 5 phút! 🤯

"Sometimes the best debugging tool is a good night's sleep." - Anonymous

15. Don't Compare Yourself

Thấy người khác code giỏi hơn → Motivation. Không phải → Depression. Focus vào journey của bản thân! 🌱

🎓 Kết Luận

Những tips này mình học được sau nhiều đêm debug đến 4-5 giờ sáng, sau vô số lần "code chạy được rồi nhưng không biết tại sao", sau khi refactor lại code cũ và nghĩ "mình đã viết cái quái gì vậy?" 😂

Development không chỉ là code. Nó là:

  • ✅ Problem solving
  • ✅ Research skills
  • ✅ Communication
  • ✅ Continuous learning
  • ✅ Patience (rất nhiều patience!)

Keep coding, keep learning, keep building! 🚀

Chia sẻ bài viết