I am kind of stumped with my code right now. Not the functionality, more so how I am writing it.
I am currently in the very early stages of development for my game right now; I have only just started to finally put my ideas down in studio. I’ve been writing a lot of code (a lot for me at least lol), and it feels a little bit messy.
Since I am a new-ish developer, I have never gone through a proper development process. Hence, I do not know if I am doing this the correct way.
tl;dr
My question: Is it normal for early-development code to be slightly unorganized (not to a fault) and un-optimized? Is this early code something that gets reworked and rewritten as development progresses?
I’ve practically rewritten all of my upcoming game’s code since I first started working on it. I’d say it’s totally normal to modify or rewrite your scripts, especially if it’s just a rough draft.
Yeah it’s normal alright, I remember my old code used to be really messy.
However, just including comments to tell yourself what sections of the Script do what can make all the difference - trust me on this one.
Yeah, I am sort of writing my own documentation for the script–within the script . I think it’s going to really help in the long run if I need to fix bugs or anything like that.
Often in game development it is more important to get something functional instead of being perfectly organised and styled. In the wider industry this is mainly because the game design tends to change during early development.
However, in Roblox this is less of a concern, so the main reason here I would say is speed. Often it’s really helpful to get your game up and running as soon as possible, so you can focus on other things (and eventually refactor everything to make it all organised once you know all the requirements).
Be careful with that, though. Make sure you don’t progress too far into your project without organising it, and definitely don’t release before you have refactored. It might require some discipline, but you don’t want to make maintaining your game hell.
It’s alright because my codes were really messy too when I started in development. Also, if you want to format your Lua scripts to make them look good then I suggest you to check this post out. I’ll link it down for you.
It is alright for your code to bit a bit messy. When I first started, I was super unorganized however and it led to the point where I couldn’t finish things, because I was unable to debug.
When you first start a game, try to keep it a bit organized. If you’re making a new function, comment above it so you know what it does. It will help you a lot.
Something else I learned a lot later, using premade formats help. I saw a format of folders someone I knew used (it organized replicatedstorage and various other game services) and when I started using it, it made all my things better, and more importantly cross compatible.
Writing a good program takes time, especially with the given complexities that can go into making a fully-fledged game. Even on minor standalone models, I rewrite or heavily modify my code several times before I am satisfied. This is especially the case when using an aspect of the engine you have never used before or have little coding experience with.
All in all, don’t worry about it, I am sure your code will turn out just fine.
Ever since I started putting heavy effort into what I work, I have rewritten the framework several times and components dozen of times, do what you gotta do.
As others have said, it’s fine to make spaghetti code. Or at least, making a project that grinds to a halt because it’s too unorganized is a great way to learn what can cause it to be that way, and what you’ll want from an organization system to fix that. Don’t worry about the small stuff yet, just get things to work. Again, it’s normal and not too bad to go back and refactor code or just rewrite it. You might feel that a bit of messy code slows you down, by try powering through it instead of letting it stop you
It’s much easier to write readable code than to over-complicate your idea which conforms into a codebase that’s hard to read. Personally, I divide everything into scopes.
print(“Scope 1”)
do
— code
end
print(“Scope 2”)
do
— code
end
If you can’t read your own code, you’re setting yourself up for failure. You can’t optimize or add features into a codebase that’s messy and otherwise unreadable.