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β
| Practice | Why It Matters |
|---|---|
| Create PRs early | Get feedback sooner, reduce conflicts |
| Mark as draft if WIP | Shows work is in progress |
| Merge PRs quickly | Reduces merge conflicts |
| Fix your own conflicts | PR author knows the changes best |
| Discuss code in PRs | Keeps all context in one place |
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:
- β Test your code locally
- β Check for errors and edge cases
- β Verify it works as expected
- β Run automated tests (if available)
// 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:
- Default to async (Slack, email)
- Use sync only when truly needed (emergencies, complex discussions)
- Respect "Do Not Disturb" status
- Document decisions in writing
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 |
|---|---|---|
getData | data | Variable is the data itself |
getCount | count | Variable holds the count |
calculatePrice | price | Variable 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β
| Type | Pattern | Examples |
|---|---|---|
| Variable | Noun | user, count, orderList, isActive |
| Function | Verb + Noun | getUser(), createOrder(), updateCart() |
| Class | Noun (capitalized) | User, ShoppingCart, DatabaseConnection |
| Constant | UPPERCASE_NOUN | MAX_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:
- Improve readability
// β
GOOD: Complex calculation explained
const taxRate = 0.08;
const subtotal = 100;
const taxAmount = subtotal * taxRate;
const total = subtotal + taxAmount;
- Are reused multiple times
// β
GOOD: Used 3 times
const currentUser = getUserFromDatabase();
logActivity(currentUser);
updateSession(currentUser);
sendWelcomeEmail(currentUser);
- 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! π