I Rewrote This Entire Main File // Code Review
156,641
Published 2024-04-20
Instagram ► instagram.com/thecherno
Twitter ► twitter.com/thecherno
Discord ► discord.gg/thecherno
Hazel ► hazelengine.com/
🕹️ Play the latest Hazel game FREE ► studiocherno.itch.io/portal-me-away
Code ► github.com/ural89/ConsoleCraftEngine
Send an email to [email protected] with your source code, a brief explanation, and what you need help with/want me to review and you could be in the next episode of my Code Review series! Also let me know if you would like to remain anonymous.
🌏 Need web hosting? ► hostinger.com/cherno
💰 Links to stuff I use:
⌨ Keyboard ► geni.us/T2J7
🐭 Mouse ► geni.us/BuY7
💻 Monitors ► geni.us/wZFSwSK
Thumbnail facepalm icon created by Freepik - Flat
All Comments (21)
-
Watch the rest of the Code Review for this project here: https://youtu.be/B6pM9KcIFE4
-
Merging the destructor and Clean makes sense, since a destructor is meant to clean up, and do whatever needs to be done before an object is deleted. However, I wouldn't expect a constructor to also start the game.
-
StartGame should not be part of the constructor. The constructor should bring the object into an initial valid state by allocating resources, setting default values, etc. and nothing more. A constructor should not be used to run "business logic" of an object.
-
The moment he put a function call in a constructor - I knew the shit's gonna go down in the comments 🤣
-
bro literally made a constructor that blocks for the entire duration of the program
-
I disagree with starting the game in a constructor. If you put StartGame() into the constructor, you may as well put the Clean() into the constructor too. But then, the whole point of an object is gone, and it can just be a static function. So, I would leave the initialization in the constructor (adding the scene to the game), and let the user of the object explicitly control when he wants to start the game with a separate instance method
-
The more logic there is in a constructor, the more ways it can fail. Constructors can't easily return a value, so you have to use exceptions to report a failure or store an error code that you can retrieve later or use a reference parameter to return an error code. Also, not too sure about it… but having an exception in a constructor might leave you with a partially initialized object
-
I think the heap allocation comes from the fact that they're a C# or Java programmer, since they do the whole shooterGame game = new shooterGame; And are just used to using new
-
"Everything in Java has to be inside a class" - I've made it my personal mission to do exactly the opposite, and have been quite successful in storing functions in enums, annotations, maps ... just for some extra spice.
-
Idk about the constructor starting the game, that feels really odd, especially when you then change it to be stack allocated. Maybe it's because I don't really do a lot of C++, but when I read: int main() { ShooterGame game; } I really so not expect anything to "run". It's fine that it pushes the ShooterScene on the engines vector, so that it is, in fact, a "ShooterGame". But actually running the game from a line of code that to me basically looks like a variable declaration seems really weird and unintuitive for me (and therefore hard to read). But personally I would probably just put it in directly in main anyway myself haha.
-
The constructor starting the game is not good very self explanatory
-
As a linux user I was today years old when i learned that windows has a distinction between "console" and "windows" apps lmao 🤡
-
Man, loved the video! Your code, style, approach and explanation are such a joy and truly evokes the most positive emotions. Thank you so much for what you do. I really miss working in a good company with good projects/codebase :)
-
That "I don't wanna talk about it" at the end sounded just right lol
-
This is such a typical code review it should go into a museum. Bike shedding a perfectly readable code, suggesting changes based on personal taste, never delving into the actual parts that define the functionality
-
Your code reviews are really fun to watch
-
I love seeing classes like these get crammed into a single function. It's just so satisfying!
-
I enjoyed this video much more than previous ones. This one is just straight forward, precise, no out of context talking and opinions.
-
Annoying when you spend 5 minutes writing a comment and the Youtube bot deletes it because of technical jargon, I'm assuming.
-
I love these videos, and I'm not a beginner, I''ve created my own game engines, other softwares, etc. But it's great to watch these videos and trying to predict what you're gonna say. It's kind of like a game trying to reach the end predicting everything you're gonna say, sometimes we forget something and we think "Oh God how could I've forgotten this?". Please continue to do these videos, they are great. :) And yeah, it's very irritating when someone uses classes and heap memory for everything, in C++ we're really free, my favorite language. PS: You should have the unofficial C++ mascot plush there, it would look great in the videos, as sometimes you review some pretty unhealthy code and the mascot would fit perfectly, and you could exchange that mascot by a healthy rat plush at the end to show how the code got healthier. :)