I just noticed that I'm at a count of 98 posts for 2017, so this is just a post to give me 99.... The next might be more interesting... But not by much.
What is an ignored qualifier? Well, in a class, lets have a student class: #include <string> class Student { public: const std::string Name; private: bool m_Present; public: Student(const std::string& p_Name) : Name(p_Name), m_Present { } void SetPresent() { m_Present = true; } void SetAbsent() { m_Present = false; } }; Now, we may want to access the present flag, therefore provide a function to do so: bool Present() const { return m_Present } This function is telling the user of our class quite a bit, it tells them that the return type is boolean and that the calling of this function makes no changes to the class contents (const trailing the parameter list). However, for me, this isn't quite right, I believe that we want to inform any user that the boolean returned is also constant, it does not change unless you alter the internal value with the "Set
I think life mocks me at times, today I've taken delivery of a couple of things to review... The Victor Electronic Rat Killer Trap and a bunch of bait... And, I literally went to groom the guinea pigs and since this morning, I stepped into the shed and there was an immediate god awful smell. The smell of rat. But this isn't life mocking me... No, the mocking comes from the fact that the bloody test model rat trap doesn't work, and then I put the blocks of bait (which only come in a plastic bag) on top of the cage for an hour whilst I cooked tea... And when I returned the blocks and bag were gone, replaced with a set of six fat shiny fresh rat shits! So tomorrow it's WAR! The guinea pigs and rabbit are being taken out of the shed, all the storage bins (which are large plastic and covered with heavy lids) will come out, everything will be swept and the whole shed will be torn down and chopped up. All the paving slabs are coming out and being stacked... and I'm diggi
Whilst cutting code I employ a coding style, which I enforce, whereby I output the scope of the variable being used with a prefix. "l_" for Local "m_" for Member "c_" for constant "e_" for enum And so forth, for static, parameter and a couple of others. I also allow compounds of these, so a static constant would be: "sc_" This is useful in many languages, and imperative in those which are not type strict, such as Python. Some confuse this with "Hungarian Notation", it's not. Hungarian notation is the practice of prefixing a type notification to the variable name, for example "an integer called count" might be "iCount". I have several problems with anyone using Hungarian Notation, and argue against it thus. With modern code completion and IDE lookup tools this is really not needed, with useful and meaningful naming of your variables the type is not needed and finally there are multiple types with the s
Comments
Post a Comment