Game
Hensen Hopper
5 hours ago

Something people often seem not to consider when programming is that the way you write your code creates implication mechanics.


"Implication mechanics" is a term coined by the indie game developer Tim Ruswick to refer to a general phenomenon that seems to occur in not only game design but engineering and design as a whole. Personally, I would summarize the idea he talks about in his video, which I've linked here if you're interested, like this: aspects of how a product or tool is designed always serve to imply a way in which they're intended to be used. This obviously applies to game design, as Tim mentions in his video, but what I want to talk about in this article is how, from my personal experience, this seems to apply to just about every scenario in which you are creating something for others (or your future self) to use, including how you write your code, specifically, the names you choose to give to objects, methods, etc.

This is something that I find very important to consider because one of the most frequent trip-ups I experience and see programmers vent about is using something and discovering that it doesn't function quite how they expected it to. I believe this happens when programmer do not consider what situations the name they've chosen for their method, object, etc. implies it is intended to be used under.

A good example in Hensen Hopper is how, just a bit ago, I renamed a public static method under the Enemy class in Hensen Hopper's codebase that is presently named SetCountToZero() twice due to both ambiguity in what it could represent and ambiguity as to what circumstances it's designed to be used under. I wrote this method, originally, to fix a bug I discovered in the new procedurally generated enemy waves algorithm where, if you died and pressed "retry", enemies would not spawn because the enemy count was still greater than zero as the enemy that kills you neither dies nor despawns. It was an easy fix, really, I just wrote a method to reset the enemy count back to zero and call it on Awake in the EnemySpawnerManager script where this algorithm runs. After I confirmed it was working, I renamed that method twice because I felt the name ResetCount() could potentially be ambiguous for future me if I were to, say, misinterpret that for being a method that returns the number of times the enemies have been reset or something. I changed the name to ResetEnemyCount() first which is no better in that regard and then to SetCountToZero() which I'm satisfied with because that clearly expresses what that method does and implies that whenever you need to make sure your code internally believes there are zero enemies in the scene, call this method.

All of this is to say that the names you choose do not only imply what something is or does but also imply their use cases and when you don't take this aspect of it into account you can and likely will create confusing situations for your teammates or for future you further down the road. I believe a good habit to get into is choosing names for your objects, methods, etc. that not only clearly express what it is/does but also imply what situations they're designed to be used under to help minimize confusing situations where you think something will do something but it turns out it does something else you weren't expecting.

That's all for this infodump. Thanks for taking the time to read this if you did!



0 comments

Loading...

Next up

AAH! SPIDERS!

Well, that didn't take long HAHA!

Why did nobody ever tell me you could simply export to GIF from DaVinci Resolve?

The spider is more or less complete functionally AND artistically! I might try to update the enemy spawning algorithm before I release any new alpha builds with the spider, though. I'm on my whiteboard trying to think through that problem.

Doki Doki Literature Club is celebrating Monika's birthday and the 8th anniversary of DDLC with exclusive stickers, avatar frames and backgrounds on Game Jolt! 

Head over to the shop to collect yours 👉 https://gamejolt.com/#shop

The gang's all here!

Mae Borowski is the main character of Night in the Woods! It's an adventure game that tells the story of her return to her hometown of Possum Springs. She was confirmed as canonically pan in a social media post by the game's creator Scott Benson.

He has hands now!

You see I was GONNA get to work on the procedural enemy wave generation algorithm but then I remembered I still haven't drawn a defeat animation for the spider so now I'm working on that instead. 🤣

Doing it in layers starting with the web as usual.

The Knightling launches on August 28! Wishlist it now so you don't miss out: https://bit.ly/KnightlingSteam

To celebrate the game's impending release, we've added The Knightling Pack and The Knightling Community Pack back to the Shop!

Been working on the artwork for the spider enemy!!! This is a preview of what it'll look like in-game. I am gonna remove all of these drop shadows as I usually apply those to the spritesheets themselves once I've drawn the animations.