Please, give some advice

Hi there, I am working on some C++ project (2D OpenGL Game Engine), and I am still learning C++ as I go, I `really don`t know what the best practices are, or how to best make/format code structure.

I would like to ask you, if somebody would be willing to take a small look at the code(if you have time), and advice me what bad coding practices I am using, If I better structure my code (e.g. I should use const and pass by reference more ofter when making in my methods).

This would really help me in a long run, since its better to take up on good coding practices early on than get used to them and write really bad code.

https://github.com/wrymn/Andromeda-Engine

Really thanks in advance If somebody tries to help me and give me some advice.
Last edited on
Did you write the Andromeda-Engine? If so, you're coding is already pretty good! :O I would recommend the usage of 'const methods' - simply by placing the const qualifier at the end of a method signature. This will ensure that a method only looks at the object's data without modifying it.

Other than that, your code is already really good!

Joe
Hi Joe!

I wrote it from scratch, but ofc, since there is A LOT of OpenGL stuff, and I`m just learning OpenGL, I watched tutorials on opengl, or component based architecture, then I was tweaking it to my liking.
(Like SpriteBatch class, which I think is pretty complicated, is from youtube tutorial)

I will surely use const methods much more! :D But also, is it better to use const methods for methds which will be "users" using, or as well as for me, so I know what function I use, will not modify the data in the object.

Thanks.
Last edited on
For both. Follow the "Principle of Least Privilege". Give a method only as much freedom as it needs to perform its job. No more. This will ensure strict code integrity and will, in the long run, reduce errors.

P.S. Sorry for the late reply :p
Topic archived. No new replies allowed.