Nội dung

DaiPhan

DaiPhan

Full-Stack Developer

Full-stack developer passionate about modern web technologies, best practices, and sharing knowledge with the community.

Skills & Expertise

JavaScript TypeScript React Node.js DevOps
150+
Articles
50k+
Readers
4.9
Rating

Agile Development: Hướng dẫn thực hành cho developer

Tìm hiểu Agile development methodology, Scrum framework, và cách áp dụng trong thực tế cho developer

Agile Development: Hướng dẫn thực hành cho developer

Agile không chỉ là methodology, mà là mindset. Bài viết này giúp developer hiểu và áp dụng Agile một cách hiệu quả trong công việc hàng ngày.

1. Agile Manifesto và Core Values

4 Giá trị cốt lõi của Agile

1. Individuals and interactions over processes and tools
2. Working software over comprehensive documentation  
3. Customer collaboration over contract negotiation
4. Responding to change over following a plan

12 Principles của Agile

1. Customer satisfaction through early and continuous delivery
2. Welcome changing requirements, even late in development
3. Deliver working software frequently
4. Business people and developers work together daily
5. Build projects around motivated individuals
6. Face-to-face conversation is most effective
7. Working software is the primary measure of progress
8. Maintain sustainable development pace
9. Continuous attention to technical excellence
10. Simplicity is essential
11. Self-organizing teams produce best results
12. Regular reflection and adjustment

2. Scrum Framework cho Developer

Scrum Roles

// Product Owner
const productOwner = {
  responsibilities: [
    'Define product vision',
    'Manage product backlog',
    'Prioritize features',
    'Accept/reject work'
  ]
};

// Scrum Master
const scrumMaster = {
  responsibilities: [
    'Facilitate scrum events',
    'Remove impediments',
    'Coach team on agile',
    'Shield team from distractions'
  ]
};

// Development Team
const developmentTeam = {
  characteristics: [
    'Self-organizing',
    'Cross-functional',
    '3-9 members',
    'Owns the how'
  ]
};

Scrum Events Timeline

Sprint (2-4 weeks)
├── Sprint Planning (4-8 hours)
├── Daily Standup (15 minutes daily)
├── Sprint Review (2-4 hours)
└── Sprint Retrospective (1.5-3 hours)

3. Sprint Planning cho Developer

Story Points Estimation

// Fibonacci sequence for story points
const storyPoints = [1, 2, 3, 5, 8, 13, 21];

// Relative sizing
function estimateStoryPoints(task, referenceTask) {
  const factors = {
    complexity: compareComplexity(task, referenceTask),
    effort: compareEffort(task, referenceTask),
    uncertainty: assessUncertainty(task),
    risk: assessRisk(task)
  };
  
  return calculatePoints(factors);
}

// Planning Poker example
class PlanningPoker {
  estimateTask(task) {
    const estimates = this.teamEstimate(task);
    
    if (this.hasConsensus(estimates)) {
      return this.average(estimates);
    } else {
      this.discussDifferences(estimates);
      return this.reEstimate(task);
    }
  }
}

Sprint Capacity Planning

// Tính toán team capacity
function calculateSprintCapacity(team, sprintDuration) {
  const workingDays = sprintDuration * 5; // 5 working days per week
  const holidays = getHolidays(sprintDuration);
  const ptoDays = getTeamPTO(team, sprintDuration);
  
  const availableDays = workingDays - holidays - ptoDays;
  const focusFactor = 0.7; // 70% focus time
  
  return {
    totalHours: availableDays * 8 * team.length,
    focusHours: availableDays * 8 * team.length * focusFactor,
    storyPoints: availableDays * team.velocity
  };
}

// Velocity tracking
class VelocityTracker {
  constructor() {
    this.sprintHistory = [];
  }
  
  addSprint(sprintData) {
    this.sprintHistory.push({
      planned: sprintData.plannedPoints,
      completed: sprintData.completedPoints,
      duration: sprintData.duration
    });
  }
  
  getAverageVelocity() {
    const recentSprints = this.sprintHistory.slice(-3);
    const total = recentSprints.reduce((sum, sprint) => 
      sum + sprint.completed, 0
    );
    return Math.round(total / recentSprints.length);
  }
}

4. Daily Standup hiệu quả

Standup Template

// What I did yesterday
const yesterday = [
  "Completed user authentication API",
  "Fixed bug in payment processing",
  "Reviewed PR #234"
];

// What I'm doing today  
const today = [
  "Implement password reset feature",
  "Write unit tests for auth module",
  "Update API documentation"
];

// Blockers/Impediments
const blockers = [
  "Waiting for design approval on reset password UI",
  "Need clarification on API rate limiting requirements"
];

// Anti-patterns to avoid
const standupAntiPatterns = [
  "Status report to manager",
  "Detailed technical discussion",
  "Problem solving in standup",
  "I'm blocked but don't know why"
];

Developer Standup Checklist

- [ ] Did I complete what I committed to?
- [ ] What's my plan for today?
- [ ] Do I have any blockers?
- [ ] Can I help any team member?
- [ ] Are we on track for sprint goals?

5. User Stories và Acceptance Criteria

User Story Format

As a [type of user]
I want [some goal] 
So that [some reason]

Ví dụ User Stories

const userStories = [
  {
    story: "As a user, I want to reset my password so that I can access my account",
    acceptanceCriteria: [
      "User can request password reset via email",
      "Reset link expires after 24 hours", 
      "User can set new password using valid reset link",
      "System validates new password meets security requirements"
    ],
    definitionOfDone: [
      "Code implemented and tested",
      "Code reviewed and approved",
      "Documentation updated",
      "Deployed to staging environment"
    ]
  }
];

INVEST Criteria for Good Stories

const INVEST = {
  Independent: "Can be developed independently",
  Negotiable: "Details can be negotiated",
  Valuable: "Delivers business value", 
  Estimable: "Can be estimated",
  Small: "Can be completed in one sprint",
  Testable: "Has clear acceptance criteria"
};

6. Definition of Done (DoD)

Sample DoD cho Developer

const definitionOfDone = {
  code: [
    "Code follows team standards",
    "Unit tests written and passing",
    "Integration tests passing",
    "Code reviewed by peer",
    "No critical bugs identified"
  ],
  
  documentation: [
    "API documentation updated",
    "User documentation updated",
    "README updated if needed",
    "Code comments added where necessary"
  ],
  
  deployment: [
    "Feature deployed to staging",
    "Smoke tests passing on staging",
    "Performance impact assessed",
    "Security review completed if needed"
  ]
};

7. Technical Practices trong Agile

Test-Driven Development (TDD)

// Red-Green-Refactor cycle
class TDDProcess {
  redPhase() {
    // Write failing test
    test('should calculate total price with tax', () => {
      expect(calculateTotal(100, 0.1)).toBe(110);
    });
    // Run test -> FAIL (Red)
  }
  
  greenPhase() {
    // Write minimal code to pass
    function calculateTotal(price, taxRate) {
      return price + (price * taxRate);
    }
    // Run test -> PASS (Green)
  }
  
  refactorPhase() {
    // Improve code while keeping tests green
    const calculateTotal = (price, taxRate) => 
      price * (1 + taxRate);
  }
}

Continuous Integration

# .github/workflows/ci.yml
name: CI/CD Pipeline

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    
    - name: Setup Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '16'
    
    - name: Install dependencies
      run: npm ci
    
    - name: Run linter
      run: npm run lint
    
    - name: Run tests
      run: npm test
    
    - name: Build application
      run: npm run build

Pair Programming

// Driver-Navigator pattern
class PairProgramming {
  constructor(driver, navigator) {
    this.driver = driver; // Writes code
    this.navigator = navigator; // Reviews and strategizes
  }
  
  switchRoles() {
    [this.driver, this.navigator] = [this.navigator, this.driver];
  }
  
  session(duration = 25) { // Pomodoro style
    setInterval(() => this.switchRoles(), duration * 60 * 1000);
  }
}

// Benefits
const pairProgrammingBenefits = [
  "Higher code quality",
  "Knowledge sharing",
  "Continuous code review",
  "Reduced bugs",
  "Faster onboarding"
];

8. Handling Change trong Agile

Change Management

// Responding to change vs following plan
class AgileChangeManagement {
  handleNewRequirement(requirement) {
    const impact = this.assessImpact(requirement);
    
    if (impact.isMinor) {
      this.addToCurrentSprint(requirement);
    } else if (impact.isMajor) {
      this.scheduleForNextSprint(requirement);
    }
    
    this.updateStakeholders(impact);
  }
  
  assessImpact(requirement) {
    return {
      effort: this.estimateEffort(requirement),
      risk: this.assessRisk(requirement),
      dependencies: this.identifyDependencies(requirement),
      timeline: this.assessTimeline(requirement)
    };
  }
}

Sprint Backlog Changes

### When to allow changes:
- ✅ Bug fixes for production issues
- ✅ Minor adjustments to current work
- ✅ Critical business requirement
- ✅ Regulatory compliance requirement

### When to defer changes:
- ❌ New features (add to product backlog)
- ❌ Major changes (plan for next sprint)
- ❌ Nice-to-have improvements
- ❌ Technical debt (unless critical)

9. Metrics và Performance Tracking

Team Metrics

const agileMetrics = {
  velocity: {
    description: "Story points completed per sprint",
    purpose: "Predict future capacity",
    warning: "Don't compare across teams"
  },
  
  burndown: {
    description: "Work remaining over time",
    purpose: "Track sprint progress",
    action: "Adjust scope if needed"
  },
  
  leadTime: {
    description: "Time from idea to deployment",
    purpose: "Measure delivery speed",
    optimization: "Reduce wait times"
  },
  
  cycleTime: {
    description: "Time to complete one item",
    purpose: "Identify bottlenecks",
    improvement: "Streamline process"
  }
};

Developer Productivity Metrics

// Focus on outcomes, not output
const developerMetrics = {
  codeQuality: {
    testCoverage: 85,
    codeReviewFeedback: 'constructive',
    bugRate: 'low'
  },
  
  collaboration: {
    prReviewTime: '< 4 hours',
    knowledgeSharing: 'active',
    teamSupport: 'high'
  },
  
  learning: {
    newSkills: 'monthly',
    processImprovement: 'quarterly',
    mentoring: 'ongoing'
  }
};

10. Common Agile Anti-Patterns

Developer Anti-Patterns

const antiPatterns = {
  heroDeveloper: {
    description: "One person does all critical work",
    impact: "Bus factor, burnout, bottlenecks",
    solution: "Knowledge sharing, pair programming"
  },
  
  goldPlating: {
    description: "Over-engineering beyond requirements",
    impact: "Wasted effort, complexity",
    solution: "YAGNI principle, MVP mindset"
  },
  
  analysisParalysis: {
    description: "Over-analyzing before starting",
    impact: "Delayed delivery, missed opportunities",
    solution: "Time-boxed analysis, iterative approach"
  }
};

Sprint Anti-Patterns

### ❌ Common mistakes:
- Death march sprints
- No retrospectives
- Ignoring technical debt
- Scope creep during sprint
- No customer feedback
- Overcommitting capacity
- Skipping testing
- Working in silos

11. Tools cho Agile Development

Project Management Tools

const agileTools = [
  {
    name: 'Jira',
    features: ['Scrum boards', 'Backlog management', 'Reporting'],
    bestFor: 'Enterprise teams'
  },
  {
    name: 'Azure DevOps',
    features: ['Boards', 'Repos', 'Pipelines', 'Test plans'],
    bestFor: 'Microsoft ecosystem'
  },
  {
    name: 'Trello',
    features: ['Simple boards', 'Cards', 'Checklists'],
    bestFor: 'Small teams'
  },
  {
    name: 'GitHub Projects',
    features: ['Issue tracking', 'Project boards', 'Automation'],
    bestFor: 'Open source projects'
  }
];

Development Tools

# VS Code extensions for Agile
extensions:
  - "github.vscode-pull-request-github"
  - "ms-vscode.vscode-json"
  - "eamodio.gitlens"
  - "ms-azure-devops.azure-pipelines"
  
# Slack integrations
integrations:
  - github: "PR notifications"
  - jira: "Issue updates"
  - calendar: "Sprint events"
  - standup-bot: "Daily updates"

Kết luận

Agile development là journey chứ không phải destination. Key takeaways:

  1. Embrace change - Thay đổi là cơ hội, không phải threat
  2. Deliver value early - Working software over comprehensive documentation
  3. Collaborate constantly - Communication is key
  4. Reflect and improve - Retrospectives are crucial
  5. Keep it simple - Simplicity is essential

💡 Remember: Agile không có one-size-fits-all approach. Hãy experiment, measure, và adjust theo context của team bạn!


Bài viết này là phần đầu trong series về Agile development. Trong các bài tiếp theo, chúng ta sẽ explore specific frameworks như Scrum, Kanban, và scaling Agile cho large organizations.