Skip to main content

Standard Practices and Conventions

Introduction: The Professional Developer's Playbook πŸ“–β€‹

Writing code is only half the battle. Professional developers follow industry-standard practices that make teams more productive, code more maintainable, and collaboration seamless.

Think of these as the "traffic rules" of programmingβ€”everyone follows them so we can all work together smoothly!

Git & GitHub Workflow Best Practices πŸŒ³β€‹

Branch Management​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ One Ticket = One Branch = One PR β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Golden Rules:

βœ… One branch per ticket/issue

  • Keep work isolated and organized
  • Easy to review and track changes

βœ… One PR (Pull Request) per ticket

  • Clear scope for reviewers
  • Simple to approve or reject

βœ… Delete merged branches

  • Keeps repository clean
  • Prevents confusion

Visual Workflow:

main ●────●────●────●
↓ β†—
feature ●───●───● (merge, then delete)

Pull Request (PR) Best Practices​

PracticeWhy It Matters
Create PRs earlyGet feedback sooner, reduce conflicts
Mark as draft if WIPShows work is in progress
Merge PRs quicklyReduces merge conflicts
Fix your own conflictsPR author knows the changes best
Discuss code in PRsKeeps all context in one place
PR Workflow Timeline
Day 1: Start work β†’ Create draft PR
Day 2: Continue work β†’ Update PR
Day 3: Finish work β†’ Mark PR ready
Day 4: Address feedback β†’ Get approval
Day 5: Merge PR β†’ Delete branch βœ…

Testing Before Submission πŸ§ͺ​

The Professional Standard:

❌ Untested code = Amateur work
βœ… Tested code = Professional work

Before creating a PR, always:

  1. βœ… Test your code locally
  2. βœ… Check for errors and edge cases
  3. βœ… Verify it works as expected
  4. βœ… Run automated tests (if available)
Never Do This
// Writing code
git add .
git commit -m "fix"
git push # ❌ Without testing!

Why it's bad:

  • Wastes reviewers' time
  • Shows lack of professionalism
  • May break production
  • Creates technical debt

Communication Best Practices πŸ’¬β€‹

Async communication is king! Use tools like Slack, Discord, or email instead of always demanding immediate responses.

Understanding Communication Types​

Two main types:

Synchronous Communication (Real-Time) ⏱️​

Real-time conversation where both parties are present.

Person A: "Hey, can you help me?" ──→ Person B
Person A: ←── "Sure, what's up?" Person B
(Immediate back-and-forth)

Examples:

  • πŸ“ž Phone calls
  • πŸŽ₯ Video meetings
  • πŸ’¬ Live chat (expecting instant reply)
  • 🀝 In-person conversations

Pros:

  • Quick decisions
  • Immediate clarification
  • Personal connection

Cons:

  • ⚠️ Interrupts work (breaks flow)
  • ⚠️ Both must be available
  • ⚠️ Can be inefficient

Asynchronous Communication (Delayed) ⏳​

Communication where responses come later, no real-time requirement.

Person A: "Can you review my code?"
↓ (sent)
[Time passes...]
↓ (when Person B is free)
Person B: "Reviewed! Looks good."

Examples:

  • πŸ“§ Email
  • πŸ’¬ Slack/Discord messages (no urgency)
  • πŸ› GitHub PR comments
  • πŸ“ Documentation

Pros:

  • βœ… Doesn't interrupt flow
  • βœ… Time to think through responses
  • βœ… Works across time zones
  • βœ… Creates written record

Cons:

  • Slower for urgent issues
  • May delay decisions

Why Async Is King πŸ‘‘β€‹

In modern development teams:

Sync Communication = Exception (emergencies only)
Async Communication = Default (99% of work)

Best practices:

  1. Default to async (Slack, email)
  2. Use sync only when truly needed (emergencies, complex discussions)
  3. Respect "Do Not Disturb" status
  4. Document decisions in writing
The "Default to Async" Rule

Before scheduling a meeting, ask:

  • Can this be a Slack message? βœ…
  • Can this be a PR comment? βœ…
  • Can this be an email? βœ…
  • Does this truly need real-time discussion? (Rarely!)

You'll save hours every week!

Naming Conventions: Code That Reads Like English πŸ“β€‹

Good names = Self-documenting code!

1. Use Descriptive Names​

Your code should explain itself without comments.

// ❌ BAD: What does this contain?
const data = [1, 3, 5, 7];
const my_list = [2, 4, 6, 8];

// βœ… GOOD: Clear purpose!
const oddNumbers = [1, 3, 5, 7];
const evenNumbers = [2, 4, 6, 8];

Functions too:

// ❌ BAD: Get what? From where?
function get() {
return { name: "John Doe" };
}

// βœ… GOOD: Instantly clear!
function getUserFromDatabase() {
return { name: "John Doe" };
}

2. Nouns for Variables (Things) πŸ·οΈβ€‹

Variables are data/things, so use nouns.

Variables = Things (nouns)

Examples:

// ❌ WRONG: Verbs as variables
const getCount = 42; // Sounds like a function!
const calculateTotal = 100; // Confusing!

// βœ… RIGHT: Nouns for data
const count = 42;
const total = 100;
const userProfile = { name: "Alice" };
const shoppingCart = [];

More examples:

Bad ❌Good βœ…Why
getDatadataVariable is the data itself
getCountcountVariable holds the count
calculatePricepriceVariable is the price value

3. Verbs for Functions (Actions) βš‘β€‹

Functions do things, so use verbs.

Functions = Actions (verbs)

Common verb patterns:

// βœ… GOOD: Action verbs
function getUser() { } // Retrieves
function createOrder() { } // Creates
function updateProfile() { } // Updates
function deleteComment() { } // Deletes
function validateEmail() { } // Validates
function calculateTotal() { } // Calculates
function formatDate() { } // Formats

Bad vs Good:

// ❌ WRONG: Noun as function name
function user() {
return { name: "John" };
}

// βœ… RIGHT: Verb shows action
function getUser() {
return { name: "John" };
}

Visual Pattern:

Variables: user, count, price, items
(nouns - things)

Functions: getUser(), addItem(), calculatePrice()
(verbs - actions)

Quick Reference Table​

TypePatternExamples
VariableNounuser, count, orderList, isActive
FunctionVerb + NoungetUser(), createOrder(), updateCart()
ClassNoun (capitalized)User, ShoppingCart, DatabaseConnection
ConstantUPPERCASE_NOUNMAX_USERS, API_KEY, DEFAULT_TIMEOUT

Minimize Variables: Less is More πŸŽ―β€‹

Every variable adds complexity. If a variable is used only once, skip it!

Why Fewer Variables Matter​

More variables = More state = More complexity = More bugs

Each variable you create:

  • ❌ Adds mental overhead
  • ❌ Increases state to track
  • ❌ Creates potential for bugs
  • ❌ Makes code harder to refactor

Example: Unnecessary Variable​

// ❌ BAD: Temporary variable used once
const persons = ["John", "Jane", "Bob"];
const firstPerson = persons[0]; // Only used once!
console.log(firstPerson);

// βœ… GOOD: Use directly
const persons = ["John", "Jane", "Bob"];
console.log(persons[0]);

When It's OK to Create Variables​

Create variables when they:

  1. Improve readability
// βœ… GOOD: Complex calculation explained
const taxRate = 0.08;
const subtotal = 100;
const taxAmount = subtotal * taxRate;
const total = subtotal + taxAmount;
  1. Are reused multiple times
// βœ… GOOD: Used 3 times
const currentUser = getUserFromDatabase();
logActivity(currentUser);
updateSession(currentUser);
sendWelcomeEmail(currentUser);
  1. Make debugging easier
// βœ… GOOD: Can inspect intermediate value
const rawData = fetchFromAPI();
const processedData = transformData(rawData); // Can log this
return processedData;

More Examples​

// ❌ BAD: Unnecessary intermediate variables
function calculatePrice(item) {
const basePrice = item.price;
const tax = basePrice * 0.1;
const shipping = 5;
const total = basePrice + tax + shipping;
return total;
}

// βœ… GOOD: Direct calculation (still clear)
function calculatePrice(item) {
const tax = item.price * 0.1;
return item.price + tax + 5;
}

Key Takeaways πŸŽ―β€‹

Remember:

βœ… Git Workflow

  • One branch per ticket
  • Test before submitting PR
  • Merge quickly, delete branches

βœ… Communication

  • Default to async (Slack, email)
  • Use sync only when necessary
  • Document decisions

βœ… Naming

  • Descriptive names always
  • Variables = Nouns (things)
  • Functions = Verbs (actions)

βœ… Code Quality

  • Minimize variables
  • Test your code
  • Keep it simple

Following these practices makes you a professional developer! πŸš€