aizatto.com
  • aizatto.com
  • Table of Contents
  • Portfolio, Projects, Tools, Toys
  • Interview Guide
    • Choosing A Company
    • Job Boards
    • Practice
    • Technical Interview Cheatsheet
    • Interview Process
      • Questions to Ask
      • Coding
      • Soft Skills
      • Rejection
      • Negotiation / Deciding
      • Accepting, Joining
    • FAQ
  • Engineering Code
    • Communication
    • Different Types of Coding
    • Commit Messages
    • Reviewing Code
      • Requesting Changes
    • Writing Code
      • Consistency
      • Writing for a code base of 1,000,000+ Lines
      • Write Code Knowing It Will Be Refactored
      • Naming
        • Versioning
        • Create Searchable Names
      • Commenting
        • Don't commit commented code
      • Make It Easy To Reproduce
      • Scripts
      • 80 character limit
      • Exit Early
      • Be careful of enum in switch statements
      • Be careful about chaining conditions
      • Be careful of chaining ternary operators
      • Write Code Knowing You Will be Blamed
      • Hacks
      • Bad Practices
      • Logs
      • Time
      • Other rules
    • Engineering Code
    • Engineering Data
    • Pipelines
    • Configuration Files
    • Site Reliability Engineering (SRE)
    • Best Engineers
  • Engineering Management
    • Hiring
    • New Reports
    • 1:1s
      • Calibration
      • Expectations
      • Mentorship / Learning / Growing
      • Task Management
      • Teams
    • Interviewing Candidates
    • Messenger Groups
    • Resources
  • Why GitBook?
  • Getting into Tech
    • Terminology
  • Personal Goals
  • Daily Drivers
  • Contacting Me
  • Notes
    • JavaScript
      • Array
      • Async & Await / Promises
      • Booleans
      • Collections
      • Cons/Dislikes
      • fetch
      • Map
      • Modules
      • Object
      • Regex
      • Set
      • Style Guides
      • Versions
    • Node.js
      • Best Practices
      • DraftJS
      • eslint
      • GraphQL
      • Relay
      • Hapi
      • Knex
      • Koa
      • TypeScript
      • Webservers
    • Technical Due Diligence
    • Archive
      • Amazon Echo Dot (3rd Gen) with clock
      • Apple
        • AirPods Pro
        • Apple Notes
        • Apple Watch Series 4
        • iPad Pro 11" 2018
        • MacBook Pro 15" 2017
        • macOS
      • Audible
      • Balance
        • Growth vs Contentment
        • Leading vs Following
        • Mindful vs Mindless
        • New vs Old
      • Bags
      • Bandwidth Requirements
      • B2B/B2C
      • Blockchain
      • Board Games
        • Bang
      • Broadway
      • Cheap, Good, Fast
      • CLI
        • git
        • ufw
        • xargs
      • Cloud Providers
        • GCP
      • Communication
        • Asking Questions / Making Requests
        • Making Edits
        • Synchronous vs Asynchronous
        • Change Management
        • Problem Definition
      • Company
        • All Hands
        • The Problematic CTO
        • Organizational Structure
      • Content Creation
      • COVID 19/Corona Virus
      • Coworking Spaces
      • Daily Routine
      • Dating
      • Displays / Monitors
      • DNS
      • Domain Registrars
      • Driving
      • eCommerce
      • Empire Building
      • Facebook for Developers
      • Fever
      • Fiverr
      • Flights
      • Gaming Tablet
      • GitHub
      • GTD
      • Go Lang
      • Headsets
      • Hiking
        • Chamang Waterfalls
        • Kanching Waterfalls
        • Kota Damansara Community Forest Reserve
        • Sungai Chilling
      • Home Device Calling
      • iCalendar
      • Keyboards
        • Ergodox Ez
      • Malaysia Insurance
      • Mental Health Malaysia
      • Multiroom Wireless Speaker System
      • Musicals
      • Mouse
      • Movies
      • Password Managers
      • Phabricator
      • Physical Health
        • Cardio
      • Podcasts
      • Programming Bootcamps
      • Property
      • Productivity
        • Note Taking
      • Redang
      • Relationships
      • Referral Codes
      • Remote Calls
      • Remote Work
        • Comparison
      • Road Trips
      • Ruby / Ruby on Rails
      • Scraping
      • Slack
      • Stripe
      • Singapore
      • UX
      • Venture Builder
      • Video Games
      • Virtual Personal Assistant
      • VPN
      • WebDAV / CalDAV
      • WebSocket
      • Withings
      • Xiaomi Roborock Mijia
      • Old Hardware
        • Netgear R7000P
      • Web Development
        • React
        • SSO Providers
      • Software Engineering
        • Software Architectures
          • Monolithic
          • Non-Monolithic
            • Microservice
            • FaaS (Functions as a Service) or Serverless
        • Repository Management
  • More on Notion
Powered by GitBook
On this page
  • 2 biggest problems in programming
  • Naming Good Names (files, directories, classes, methods)
  • Leave It Better Than You Left It
  • Small Functions
  • Input > Process > Output
  • Output can be an Input for another step
  • Measure Input > Process > Output
  • Funnels
  • Break down a Proces
  • Handling Errors
  • Silent Errors vs Fataling
  • Always print IDs
  • Write code knowing you will be blamed
  • Tuples
  • Deep inheritance trees are bad
  • Be careful of parameter bags
  • Single Responsibility Principle (SRP)
  • Use intention revealing names
  • 2 hardest parts of programming
  • Write code that is meant to be read, and not meant to solve a problem
  • Duplicating calls is ok.
  • Monitoring/Alerts
  • For user input: consider using Regexes instead of String comparisons

Was this helpful?

  1. Engineering Code
  2. Writing Code

Other rules

Rules I haven't formatted properly

2 biggest problems in programming

  • Naming

  • Caching

  • Off By One Errors

Naming Good Names (files, directories, classes, methods)

Avoid Single Letter Variable Names

Leave It Better Than You Left It

Small Functions

Input > Process > Output

Output can be an Input for another step

Measure Input > Process > Output

What to Measure:

Input/Output:

  • Number of Units

  • Before/After state of the process

Process:

  • How long did it take

  • How much processing time is used

  • How much memory did it use

  • How much bandwidth was used

Output:

  • How many were successful

  • How many failed

  • Why did they fail

  • Which failed

Funnels

When there are many Input > Process > Output, then you have a funnel.

Break down a Proces

Handling Errors

Silent Errors vs Fataling

Always print IDs

if ($ent === null) {
  printf("Unable to load ent %d", $ent_id);
  exit(1);
}

Write code knowing you will be blamed

Tuples

Sometimes we need to pair two variables together to represent a single datatype. For example tuple(MetricID, Partner) which tells us that this represents the MetricID for a given Partner.

You may want to consider 2 data structures for this:

  • Metric(MetricID)

  • MetricPartner(Metric/MetricID, Partner)

It is easier moving from a data structure that manages one data type, to a data structure that manages 2.

Consider having a function in Metric which takes in a Partner and returns a MetricPartner. For example:

  $metric = new Metric($metric_id);
  $metric_partner = $metric->withPartner($partner);

Deep inheritance trees are bad

Be careful of parameter bags

Single Responsibility Principle (SRP)

Use intention revealing names

2 hardest parts of programming

Write code that is meant to be read, and not meant to solve a problem

Duplicating calls is ok.

Monitoring/Alerts

  • How many lines of code are being added?

  • Are there alerts on highly sensitive parts of the codebase?

For user input: consider using Regexes instead of String comparisons

Pros:

  • More flexibility in matching strings

  • Regexes don't require precise string matching

  • Can easily match more than one string, for example to match all branches where node8 work is done: /\.*node8/

Cons:

  • Regexes are slightly more time consuming

For example:

regex.matches(input)

vs

inputs.split(',').some((input) => input === expected);

PreviousTimeNextEngineering Code

Last updated 5 years ago

Was this helpful?