Code Like Bro
A Guide for Standard and Better Coding
WordCamp Nepal 2026
Madan Panthi
️
🕶️No Cap, Just Clean Code.
The Bro Manifesto
Coding isn't just for you; it's for the next bro who inherits
your mess.
"Bro Code" = Readability, Maintainability, and Respect.
"If your code is a mystery, you're not a bro, you're a riddle."
The "Bruh" Moments
Vague Naming
$a = get_option('set');
$user_theme = get_option('user_theme');
Use Case: Self-documenting code saves hours of "What is $a?"
Spaghetti Logic
if(c1){ if(c2){ if(c3){ ... } } }
if(!c1) return; if(!c2) return; ...
Use Case: Early exits keep your logic flat and readable.
Global Pollution
Mistake: Using globals like a public park. Leads to conflicts in
WordPress plugins.
Bro Way: Use Classes, Namespaces, or Dependency Injection.
Hardcoding
Mistake: Magic numbers and strings. "It works on my
machine" is the ultimate L.
Bro Way: Use Constants or Config files for API keys
and paths.
"I'll fix it later" is the biggest lie in tech.
The Approach
Coding Standards
Follow PSR guidelines for
consistent, readable code. It's the
universal language of pros.
Example: PSR-12 ensures your PHP is
readable by any bro globally.
DRY Principle
Don't Repeat Yourself. Abstract
common logic into reusable
functions or classes.
Use Case: Extract email validation
into a single helper function.
Modularity
Break complex problems into
small, focused functions. One
function, one job.
Use Case: Separate form validation
from database insertion.
Clean code is the ultimate flex.
The "Wingman" Strategy
OOP vs Functional
OOP
Best for complex systems with state
(e.g., Large WP Plugins).
Functional
Best for predictable data
transformations.
Use Case: Use OOP for CPT
management; Functional for data
migration scripts.
Monolith vs Micro
Monolith
Start simple. Don't over-engineer early.
Microservices
Scale when complexity demands it.
Use Case: Start e-commerce as a
monolith; extract payments later.
Library vs Custom
Library
Leverage battle-tested code (e.g.,
Carbon).
Custom
Build only if unique or broken.
Use Case: Use PHP's DateTime instead of
writing a custom formatter.
"Using a sledgehammer to crack a nut isn't Bro, it's just inefficient."
Gains & Performance
Caching
Implement object and page caching to reduce DB load.
Example: Use Redis for DB results and Caching Plugins for pages.
Optimized Queries
Avoid SELECT *. Use specific columns and indexes.
Example: SELECT id, name FROM users instead of SELECT *.
Lazy Loading
Defer non-critical assets until needed.
Use Case: Native lazy loading for images improves initial load.
Response Time (ms) - Caching Impact
"If your site takes 5s to load, your users are ghosting you."
Don't Hog the Gym
Memory Leaks
Unset large variables when no longer needed.
Example: unset($big_data) after processing a large CSV.
Efficient Loops
Avoid DB queries inside loops. Pre-fetch data.
Use Case: Fetch all user meta once instead of inside a foreach.
Data Structures
Choose structures that fit the problem.
Example: Use associative arrays for O(1) key lookups.
Memory Usage Efficiency
"Your server's RAM isn't an all-you-can-eat buffet unlike WordCamp’s Lunch.”
The Bro Check
Unit Testing
Write tests to verify individual
components. It's your safety net.
Example: Assert add(1,2) returns 3. Catches
refactor Ls.
Debugging Tools
Step through code with Xdebug. Stop
relying on var_dump().
Use Case: Trace variable values in complex
WP hooks.
CI/CD
Automate testing and deployment.
Catch Ls before production.
Example: Run PHPUnit on every GitHub
merge.
"It compiled" is not a test. No cap.
Protect the Squad
Input Sanitization
Always clean user input. Never trust external data.
sanitize_text_field( $_POST['user_input'] );
Input Validation
Verify data conforms to expected formats.
if ( ! is_email( $email ) ) return;
Nonces (WordPress)
Protect against CSRF attacks with secret handshakes.
wp_nonce_field( 'my_action', 'my_nonce' );
"SQL Injection is the ultimate betrayal."
The Legacy: Meaningful Comments
Bad: Obvious Comments
// Increment counter
$counter++;
Why: The code already says what it does. This is just noise.
Good: Explaining "Why"
// Increment counter only for premium users to avoid rate
limits.
if($is_premium) $counter++;
Why: Explains the business logic that isn't obvious from the
code.
"Explain the 'Why', not the 'What'."
The Legacy: Comprehensive READMEs
Installation Guide
Configuration Steps
Usage Examples
Contribution Guidelines
Use Case: WP Plugin README
Include dashboard installation, shortcode examples,
filter/action hooks, and how developers can contribute.
Make it bussin for new team members.
"A good README is a love letter to your future self."
You are irreplaceable, if only your
company can't afford a better developer.
Bro’s take on job security and the need for continuous growth.
ACTIONABLE: Always strive to be better, so you ARE the better developer.
Your last code is your reference point for
the new job.
Every line you write reflects your professionalism and skill.
ACTIONABLE: Treat every project as a portfolio piece. Write code you're proud to show.
The Bro Conclusion
Embrace Standards & Best Practices Optimize for Performance & Memory
Prioritize Security & Testing Continuously Learn & Improve
"Stay humble, keep learning, and be a Bro to your fellow devs."
Any Questions, Bros?
️
🕶️No Cap, Just Conversation.
Thank You Bros!
https://manjul.me
codemadan@gmail.com

Code Like Bro -A guide for better Coding

  • 1.
    Code Like Bro AGuide for Standard and Better Coding WordCamp Nepal 2026 Madan Panthi ️ 🕶️No Cap, Just Clean Code.
  • 2.
    The Bro Manifesto Codingisn't just for you; it's for the next bro who inherits your mess. "Bro Code" = Readability, Maintainability, and Respect. "If your code is a mystery, you're not a bro, you're a riddle."
  • 3.
    The "Bruh" Moments VagueNaming $a = get_option('set'); $user_theme = get_option('user_theme'); Use Case: Self-documenting code saves hours of "What is $a?" Spaghetti Logic if(c1){ if(c2){ if(c3){ ... } } } if(!c1) return; if(!c2) return; ... Use Case: Early exits keep your logic flat and readable. Global Pollution Mistake: Using globals like a public park. Leads to conflicts in WordPress plugins. Bro Way: Use Classes, Namespaces, or Dependency Injection. Hardcoding Mistake: Magic numbers and strings. "It works on my machine" is the ultimate L. Bro Way: Use Constants or Config files for API keys and paths. "I'll fix it later" is the biggest lie in tech.
  • 4.
    The Approach Coding Standards FollowPSR guidelines for consistent, readable code. It's the universal language of pros. Example: PSR-12 ensures your PHP is readable by any bro globally. DRY Principle Don't Repeat Yourself. Abstract common logic into reusable functions or classes. Use Case: Extract email validation into a single helper function. Modularity Break complex problems into small, focused functions. One function, one job. Use Case: Separate form validation from database insertion. Clean code is the ultimate flex.
  • 5.
    The "Wingman" Strategy OOPvs Functional OOP Best for complex systems with state (e.g., Large WP Plugins). Functional Best for predictable data transformations. Use Case: Use OOP for CPT management; Functional for data migration scripts. Monolith vs Micro Monolith Start simple. Don't over-engineer early. Microservices Scale when complexity demands it. Use Case: Start e-commerce as a monolith; extract payments later. Library vs Custom Library Leverage battle-tested code (e.g., Carbon). Custom Build only if unique or broken. Use Case: Use PHP's DateTime instead of writing a custom formatter. "Using a sledgehammer to crack a nut isn't Bro, it's just inefficient."
  • 6.
    Gains & Performance Caching Implementobject and page caching to reduce DB load. Example: Use Redis for DB results and Caching Plugins for pages. Optimized Queries Avoid SELECT *. Use specific columns and indexes. Example: SELECT id, name FROM users instead of SELECT *. Lazy Loading Defer non-critical assets until needed. Use Case: Native lazy loading for images improves initial load. Response Time (ms) - Caching Impact "If your site takes 5s to load, your users are ghosting you."
  • 7.
    Don't Hog theGym Memory Leaks Unset large variables when no longer needed. Example: unset($big_data) after processing a large CSV. Efficient Loops Avoid DB queries inside loops. Pre-fetch data. Use Case: Fetch all user meta once instead of inside a foreach. Data Structures Choose structures that fit the problem. Example: Use associative arrays for O(1) key lookups. Memory Usage Efficiency "Your server's RAM isn't an all-you-can-eat buffet unlike WordCamp’s Lunch.”
  • 8.
    The Bro Check UnitTesting Write tests to verify individual components. It's your safety net. Example: Assert add(1,2) returns 3. Catches refactor Ls. Debugging Tools Step through code with Xdebug. Stop relying on var_dump(). Use Case: Trace variable values in complex WP hooks. CI/CD Automate testing and deployment. Catch Ls before production. Example: Run PHPUnit on every GitHub merge. "It compiled" is not a test. No cap.
  • 9.
    Protect the Squad InputSanitization Always clean user input. Never trust external data. sanitize_text_field( $_POST['user_input'] ); Input Validation Verify data conforms to expected formats. if ( ! is_email( $email ) ) return; Nonces (WordPress) Protect against CSRF attacks with secret handshakes. wp_nonce_field( 'my_action', 'my_nonce' ); "SQL Injection is the ultimate betrayal."
  • 10.
    The Legacy: MeaningfulComments Bad: Obvious Comments // Increment counter $counter++; Why: The code already says what it does. This is just noise. Good: Explaining "Why" // Increment counter only for premium users to avoid rate limits. if($is_premium) $counter++; Why: Explains the business logic that isn't obvious from the code. "Explain the 'Why', not the 'What'."
  • 11.
    The Legacy: ComprehensiveREADMEs Installation Guide Configuration Steps Usage Examples Contribution Guidelines Use Case: WP Plugin README Include dashboard installation, shortcode examples, filter/action hooks, and how developers can contribute. Make it bussin for new team members. "A good README is a love letter to your future self."
  • 12.
    You are irreplaceable,if only your company can't afford a better developer. Bro’s take on job security and the need for continuous growth. ACTIONABLE: Always strive to be better, so you ARE the better developer.
  • 13.
    Your last codeis your reference point for the new job. Every line you write reflects your professionalism and skill. ACTIONABLE: Treat every project as a portfolio piece. Write code you're proud to show.
  • 14.
    The Bro Conclusion EmbraceStandards & Best Practices Optimize for Performance & Memory Prioritize Security & Testing Continuously Learn & Improve "Stay humble, keep learning, and be a Bro to your fellow devs."
  • 15.
    Any Questions, Bros? ️ 🕶️NoCap, Just Conversation. Thank You Bros! https://manjul.me [email protected]