↓ Skip to main content

Writing code

LLM-assisted flow
#

  • Use the task background + acceptance criteria as plan prompt (manual)
  • Use the planning feature of the agent and let it generate a plan (LLM)
  • Review the plan and adjust as necessary (manual)
    • Ensure the presence of tests
  • Let the agent implement the code based on the plan (LLM)
  • Review the code implemented by the agent (manual)
    • Ensure it meets the acceptance criteria
    • Ensure code quality and standards
  • Manually verify that functionality is working as expected (manual)
  • Commit code on a branch (manual)
  • Push to the central repository (manual)
  • Verify that CI passes
  • Create pull request (manual + LLM generated description)

Pre-LLMs flow
#

  • Make sure you understand what you have to implement
  • Make it work
  • Write a test for what you implemented
  • Refactor the code for reusability/code standard
  • Verify that your code passes linting and tests
  • Commit your code on a branch
  • Push to the central repository
  • Verify that CI passes
  • Create pull request
  • Annotate code to explain intent of changes

Writing commits

Nowadays I do not write useful commit messages anymore. The main reason is that most repositories I work in professionally use squash merges, meaning that all commits done in a branch are squashed into a single commit when merging the branch into the main branch. The commit message of the squash commit is usually the title of the pull request, meaning that the individual commit messages are not very useful anymore. The commit message ends up containing the PR description, which gives the what and why of the changes, which is generally enough.

With the rise of LLMs I have never found myself looking at the commit history and the commit messages to understand why things changed. If something isn’t working, I simply get the LLM to help me fix the problem.

Pre-LLMs era
#

  • One liner describing what changed (not period terminated)
  • A few lines describing in more details why things changed
  • GPG signed commit

How to Write a Git Commit Message
#

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body at 72 characters
  • Use the body to explain what and why vs. how

References
#


Writing tests

When joining a new project without tests, here is the value you need to provide through the addition of tests:

  1. the application works and doesn’t crash
  2. the application works and supports a few input cases
  3. the application works and supports a variety of input cases
  4. the application works and is robust to most input cases
  • Write a test that tests the common case usage of your function
  • Write tests that cover edge cases of your function
  • Write tests to cover all statements, branches, paths

Diablo

A table of probabilities is built The ratio 1/drop chance is used to compute a total drop chance A number is generated in the range 0-total drop chance A table lookup is done to find the associated item Item properties are randomly rolled Different table lookup may be built depending on the difficulty setting as well as the current act The rarity of an enemy pack may either change the random generator distribution or some other mean to modify the probability of higher quality items from dropping The pseudo random number generator is initialized each game and does not depend on the current time (to avoid issue with reading some timer which may have the same value over many iterations or may be slow to read) When an enemy is killed, we want to determine how many items will drop


Factorio

An initial seed is computed and stored in the game save file Based on this seed, the world is pseudo randomly computed, using a certain chunk/block/tile size (e.g., 32x32, 128x128) The world map is only generated on-demand, that is, as far as the player can see When a new chunk is discovered, its blocks are computed and persisted in the save file If there are no active components in a chunk that is not visible, the game will obviously not render it, it will only simulate it (position, item, velocity, etc) Certain thing, for instance alien types and alien base size, may only be computed once they are observed. At first, maybe only a location anchor will exist to indicate where they should spawn, but the rest will be generated only when needed.


League of legends

Client/server Per region servers Login/authentication server Lobby server Store server

  • buy champion/runes Transfer player from lobby to game server
  • champion selection
  • spectators Per game server
  • Coordinates all 10 players within the game
  • controls game events dragon/baron/npc/player gold
  • compute damage
  • end game lobby Game client
  • Display animations
  • play game state according to server

Minecraft

An initial seed is computed and stored in the game save file Based on this seed, the world is pseudo randomly computed, using a certain chunk/block/tile size (e.g., 32x32, 128x128) The world map is only generated on-demand, that is, as far as the player can see When a new chunk is discovered, its blocks are computed and persisted in the save file If there are no active components in a chunk that is not visible, the game will obviously not render it, it will only simulate it (position, item, velocity, etc)


Starcraft

Authentication/Login server Per game server

  • compute damage simulation
  • in game chat
  • decide game victory
  • returns end game stats for ui (or done client side?) Game client
  • display game ui
  • play animations
  • send commands to game server Local backend
  • record game
  • compute game simulation
  • communicate game state to game client

Task overload

It’s highly common when working that priorities shift and that sometimes you have way more on your plate than you can handle.

No need to panic!

  • Ignore your task list
  • Use your brain and create a fresh list of what you think is the most important
  • Prioritize using the importance/urgency matrix

Checklists

Context
#

Checklists are a highly effective way to make sure that critical elements of a routine are done. As such, I want to explore and make checklists for different things that are important in my life.

Life
#

  • Did I eat 3 meals today?
  • Are time-based events scheduled in the calendar?
  • Are repetitive events scheduled in the calendar?

Software development
#

  • Is the feature implementing all the desired use cases?
  • Are tests written to cover the common case and some edge cases?
  • Are tests passing?

Machine learning
#

  • Is there a row of data even when the value is 0?

See also
#

References
#