Clean Code: Analysing game code using agile programming practices
Loading...
URL
Journal Title
Journal ISSN
Volume Title
Perustieteiden korkeakoulu |
Master's thesis
Unless otherwise stated, all rights belong to the author. You may download, display and print this publication for Your own personal use. Commercial use is prohibited.
Authors
Date
2020-05-19
Department
Major/Subject
Game Design and Production
Mcode
SCI3046
Degree programme
Master’s Programme in Computer, Communication and Information Sciences
Language
en
Pages
51
Series
Abstract
Agility in software development means being able to adapt to ever-changing requirements. A major factor in agility is keeping the codebase easy to read and to extend. This kind of code is commonly called "clean code". Clean code is simple, elegant, and does not repeat itself. Writing clean code means that the cost of adding, changing, and removing features is kept to a minimum. It front-loads more of the work into the design stages of development, where it is cheaper both financially as well as mentally. This thesis describes some of the main principles of clean code and shows how they can be used in analyzing game code. The game under scrutiny is The Last Cube, a large-scale puzzle game project in which the author is the lead programmer. The game has been in development in the Unity game engine over 3 years. Parts of the code of The Last Cube are described and then analyzed using various methods and tools. The analysis of the code revealed hundreds of major violations of the clean code principles listed in the thesis, including problems with coupling, complexity, and duplication. The problems are analyzed and discussed. One instance of coupling is taken under closer scrutiny and analyzed further. The section is then refactored, improving the section’s maintainability and reducing coupling.Ohjelmistokehityksessä termi "ketteryys" viittaa kykyyn sopeutua alati muuttuviin vaatimuksiin. Yksi suurimmista tekijöistä ketteryydessä on koodin luettavuus ja laajennettavuus. Tällaista koodia kutsutaan usein termillä "clean code"eli "puhdas koodi". Puhdas koodi on yksinkertaista ja eleganttia, eikä se toista itseään turhaan. Puhtaan koodin kirjoittaminen auttaa pitämään toiminnallisuuksien lisäämisen, muuttamisen ja poistamisen kulut minimissä. Käyttämällä enemmän aikaa työn suunnitteluvaiheissa, ohjelmointi on helpompaa sekä taloudellisesti että henkisesti. Tämä työ kuvaa puhtaan koodin pääperiaatteita ja esittelee niiden käyttöä pelikoodin analysoinnissa. Tutkittava peli on The Last Cube, suuren mittakaavan pulmapeliprojekti, jossa työn kirjoittaja on pääohjelmoijana. Peliä on kehitetty Unity-pelimoottoriin pohjautuen yli kolmen vuoden ajan. Osia The Last Cube -pelin koodista esitellään ja analysoidaan käyttäen erilaisia metodeja ja työkaluja. Koodin analysointi paljasti satoja kohtia, joissa työssä esiteltyjä puhtaan koodin periaatteita oli rikottu. Löytyneitä ongelmakohtia esitellään ja analysoidaan, ja erästä funktiota tarkastellaan lähemmin ja lopulta muutetaan puhtaammaksi. Muutoksen jälkeen tehdyn analyysin mukaan funktio on lyhyempi sekä huomattavasti parempi ylläpidettävyyden kannalta.Description
Supervisor
Hämäläinen, PerttuThesis advisor
Hämäläinen, PerttuKeywords
game, programming, clean code, agile, object-oriented programming, analysis