Hi,
I have seen many others experienced and inexperienced developers fall into the same trap as me.
Once the project starts things are usually easy (unless you are working on a Plugin first to compliment your project) and tasks are done in matter of days if not hours but just like every other software things start to get a bit complicated as the project matures.
A small and easy to digest example might be lets say If a developer is working on an Aim Down Sights function for his/her FPS game its pretty simple at first but as the requirements and constraints become more and more clear during the development cycle we end up using a lot of cheap tricks such as using bools and tons of flags to check if the Character can aim down sights this usually ends up in an if Statement with a lot of && operators. as there might be a thousand cases you don’t want the character to ADS.
I want to know How Someone from a professional Industry handles this?
I have experimented with some other ways through which I was able to “beautify” my code but sadly I haven’t found a silver bullet yet.
Those included:
- Creating separate In line methods that did all the dirty work, let’s say you wanna check if you can ADS you will simply call that method and based on its result code will proceed or return.
- Other technique was to use Enums and think of everything as a State Machine, at one time the Player can be in One State, this can be easily modified and upscaled as well you can make states for a feature set like One Enum type for Movement and Other for Combat. this way you can easily check that you can only ADS if your Combat States is in Idle State (aka not busy reloading etc).
that being said I still think there might be an even better Solution/Design pattern for this type of problems.