my-notes

System_Design_and_Code_Reviews

1 min read

System Design and Code Reviews

Git in system design and review best practices.


πŸ—οΈ Git in System Design

Distributed Version Control

graph TD
    A[GitHub] --> B[Developer 1]
    A --> C[Developer 2]
    A --> D[Developer 3]
    B --> A
    C --> A
    D --> A

All developers have full repository copy.


Data Integrity

Git uses SHA-1 hashes to ensure data integrity.

git cat-file -t abc1234

Every object is content-addressed.


πŸ“‹ Interview Topics

Git Internal Structure

Object Purpose
blob File contents
tree Directory structure
commit Snapshot + metadata
tag Named pointer

Common Interview Questions

  1. How does Git store data?

    • Content-addressable filesystem
    • SHA-1 hashes
    • Objects: blob, tree, commit, tag
  2. Merge vs Rebase?

    • Merge preserves history
    • Rebase creates linear history
  3. How to find a bug in history?

    • Use git bisect

πŸ” Code Review Best Practices

Review Size

git diff --stat main...HEAD

Check PR size before review.

Keep PRs under 400 lines.


Review Checklist


Review Commands

gh pr checkout 123

Checkout PR locally.

gh pr diff 123

View PR diff.

gh pr review 123 --approve

Approve PR.


πŸ’¬ Effective Review Comments

Good Examples

Consider using a map here for O(1) lookup instead of array.find()
This could cause N+1 queries. Consider eager loading.
Nice refactor! This is much more maintainable.

Avoid

This is wrong.
Why?

Be constructive and specific.


🏒 Enterprise Patterns

Branch Protection

  • Require PR reviews
  • Require CI passing
  • Require signed commits

CODEOWNERS

# .github/CODEOWNERS
* @team-lead
/src/api/ @backend-team
/src/ui/ @frontend-team

Auto-assign reviewers.


πŸ’‘ Tips

For Interviews

Understand Git internals: objects, refs, index.

Review Etiquette

Be kind, specific, and educational.



#git #systemdesign #codereview #interview

Built with mdgarden