The Great Refactor
64 Days Until I Can Walk
As planned, today marks the beginning of what I’m calling, “The Great Refactor”. Because I’ve been learning as I’ve been going along, my code has grown incredibly messy. In fact, I hadn’t realised how bad it was until I sat down today and really started picking through it.
Ultimately I do want this thing to be an engine that other people can use for fun little projects, so I have started by trying to break some of my code into more logical modules, and grouping functions into structs with names that actually make sense. For example, I had the raycast method implemented the map struct. This made no sense!!! I have two enums for handling tile information which overlap eachother significantly, and their names are not sufficient to indicate their true purpose—Tile and TextureCode.
Ideally if my refactoring goes well, I will not only have a more readable, maintainable codebase, but it will also be considerably more configurable. For example, I would like to give the user some control over how ceiling and floor rendering is done. I think I should be able to do this using traits, or possibly enums.
That brings me to another reason why I feel this refactor will be a good idea at this stage—I’m going to have to try and write some better, more idiomatic Rust. While today was a little slow, I have already found myself really trying to look at how I have leveraged the features that Rust provides. More and more I am asking myself if there is a more “Rust” way to do things. So I feel encouraged that this exercise will help me to improve the quality of my Rust code going forward.
So it’s a quiet update today folks, but I feel that the codebase has benefitted from it. I plan to continue with this exercise until Friday.