Thanks again for your considerable effort in trying to get me on track, it is most helpful and appreciated. You are a good teacher Sorry I write and ask so much, but I just enjoy discussing these topics so much
About your other remarks:
I discovered their existence by accident I believe, and have no experience with them really. Something I must dive into I guess. One of manyPrefer using the STL algorithms over raw loops when possible.
They look nice, however I often find myself halfway changing them back to range based loops because I need the index anyway. I shall try to use them where ever I can.Prefer range based for loops ...
I thought pointer arithmetic would be faster, but maybe I underestimate the compiler. I remember a talk about optimization where the speaker went something like "Don't try to help the compiler!". So maybe I should stop doing that.Prefer index based loops over pointer or even iterator arithmetic...
I read somewhere that variable names should be shorter when less important (more local, less global) and longer if otherwise. Maybe I took this one too farPrefer more descriptive names for variables...
You are right, it is just that I like to get as much code on the screen as possible so I don't have to scroll all the time. Maybe I need a bigger monitor Jokes aside, what really needs to be done is breaking functions up into smaller ones.Space out your code every few lines...
Aha, I was wondering why there were two of'm Thanks for clearing that upThe UpdateModel() function should be used to update all your objects, and the ComposeFrame() function is used to draw them...
You are right, however, when developing, I found that sometimes I start to declare functions in a class as const, only to discover at the very end it is not going to be possible, and I have to undo all of it. It is the kind of thing I postpone till last and then forget about. But shouldn'tConst functions
I know, right? When you see an init() function, it usually means I couldn't find a way to properly initialize it in the constructor. Doesn't mean it can't be done, only that I didn't see how.Prefer using constructors over Init() functions
I started doing that more recently. I shall try to do it more systematicallylocal variables can quite often be declared const
I don't understand safe pointers yet. The syntax looks quit intimidating. Another thing to dive into...Prefer std::unique_ptr over new/delete...
Another thing I started doing more lately. Initially, I wanted to only use my own code, no STL, to keep full control over the codebase. But I changed my mind, as I will never be able to make a class as good as the STL, and the STL is part of the C++ standard anyway.Prefer std::string over const char* in most cases
Another advanced topic I'm a bit intimidated by. I feel like I could try to use it, but would have no way to test it, causing some unfixable bug two months later.Use move semantics ...
Maybe there was a reason to use a pointer, I don't remember. I'll have to look into it.It would probably be better to just pass a Font const& to functions needing the font
About the code duplication between sprite & Graphics classes: this has bothered me indeed, but I had yet to come up with a decent solution. One would be to always use the Sprite class functions, and create a special class that is actually the video memory instead of some sprite floating around in heap memory. While I think I kind-of understand your template code example, I could never come up with such a solution, it is way too advanced for my current level. Thanks for the suggestion though! Maybe I can try to implement it.
I don't think I use macro's, since I don't know how these work Same goes for constexpr(). I use only basic "#define" statements for constants. Should I avoid these entirely?prefer constexpr over macros...
Oh man, you nailed it there. When I installed VS2019 yesterday it gave an error on exactly that function, and thanks to your "preemptive strike" I could fix it right away. You saved me there!! For which I am very grateful indeed.Functions in the standard library that begin with an underscore should never be used
When you corrected my notes you wrote:
Did you mean to say this?- As arguments to a function, pass the underlying object by reference or const reference
- As arguments to a functor or function pointer supplied to the standard algorithms,
- pass unique_ptr by reference or const reference
- If you are transferring ownership, then transfer by value
- As arguments to a function, pass the underlying object by reference or const reference
- As arguments to a functor or function pointer supplied to the standard algorithms, pass unique_ptr by reference or const reference
- If you are transferring ownership, then transfer by value
All right, should be an easy fix (I hope)Consider using the C++ random library instead
I believe Chili made a video about it. Using the framerate counter as clock (as I did so far) is questionable to say the least, indeed you are right. Another subject I must delve intoConsider using the C++ chrono library
About the XMLParser:
Your criticism about the poor choice of variable names is absolutely fair, not petty I would have used the erase function if I knew it existed . I'll update the code, thanks for the suggestion.
Thanks for explaining the use of the auto keyword, I understand now why you did it this way. While I knew about auto, I shall refrain from using it for the time being, as I want to force myself to "properly" declare variables so I understand what I'm doing. When I have more experience, I can switch to auto. The appeal is obvious, but I feel I have not earned the right to use them yet, if that makes sense.
Thanks for re-explaining the in/out function parameter thing. I'm sorry I made you repeat yourself, but coming back to a subject and slightly rephrasing it did help me understand it better.