Categories
Uncategorized

Blog #4

To start of the winter semester we’ve been asked to created a blog regarding clean code and code smells. This is honestly a perfect time to do this as we have all come back from winter break and have take time away from the project thus having clean and readable code is important for getting back into the project. The prompt we were given was what would we like to do more and less often based on the articles. I thought the best way to delve into this would to review our own project code, the positives and the negatives.

One thing that I’m a big fan of is consistent naming conventions. Personally I believe it makes easier to read and to write. Take for example camel case, my most used naming convention, for camel case you are to keep the first word lowercase and every word after capitalized. Take an example from our code;

public float initialSpeed = 5f;

as we can see the variable name is set to initialSpeed which follows camel case. One issue among our whole code base though is in unity, the program follows a camel case convention but the first letter capitalized so our previous variable would become InitialSpeed. This switching of conventions and even sometimes switching to different conventions is seen all over:

private bool TopWallCollsion = false;

AudioSource[] audio_options = GetComponents<AudioSource>();

public bool IsTrainingMode = false;

These issues can be seen all over our code and are one of many code smells in our code but going forward it was something i would like to change and as Robert C Martin had acknowledged in his book clean code, “leave the campground better than we found it” or to clean up the code little by little as we go. I hope to do this more often and make that a goal of mine. Thus if we are to reference the boy scout thought, the thing that I would like to do less often is “leave trash lying around” or more accurately break the habit of writing in my natural case and write in the case fitting to the project.

Leave a Reply

Your email address will not be published. Required fields are marked *