last day (15 days later) » 

10:25 PM
3
A: Clean Code attempt of HOLES problem on codechef.com

JamalLetterEvaluator Since this is a C++11 solution, you no longer need something like createMap(): std::map<char,int> createMap() const { std::map<char,int> initializedMap; initializedMap['A'] = 1; initializedMap['B'] = 2; initializedMap['D'] = 1; initializ...

 
M K
Is the constexpr required? I had tried that without and couldn't get it to work. I'm using visual studio 2012 express and it errors out stating data member initializer not allowed.
 
@MK: I've just realized that constexpr doesn't work here. Sorry about that. I'll correct this.
@MK: Also, constexpr isn't supported by VS2012. Either way, it's not essential here (even if it worked), as long as you still use const.
 
M K
That part about implicit return types would've been nice to know before I spent about 30-45 minutes trying to return a const iterator before I realized it was called const_iterator. Oh well I know now. Thanks.
 
@MK: I've added some new things, though I haven't looked at every bit of the solution. I haven't tested my implementation of retrievedLetter, so let me know if it doesn't work.
@MK: I've just learned that auto as a return type only works in C++14. I'll update that on here, while keeping the general advice.
 
M K
I'm aware of the duplicate calls to retrieveValueOfLetter() I originally had a temp but decided this was premature optimization. The books I'm currently reading Clean Code and Refactoring recommend against this type of early optimization but I would like your opinion on it. What do you think?
 
10:27 PM
It may not be needed if the optimizing compiler detects this and optimizes it out. But this is also good for removing redundancies. If you're needing to get one set value from a function, and if you need this value more than once, then you don't need to call the function that many times.
 
M K
10:52 PM
Good to know. I feel there are so many little nuances to learn it's really hard as a beginner to determine which advice is inexperience and which is just a different way because of a, b, and c reasons.
 
It may help to hear from other users as well. I'm only a student, so I can't give very thorough advice on everything.
 
M K
11:08 PM
In this comment "It looks like readWord() should be a free function (non-member function). However, if you're trying to read in a word, then you can just overload operator>> for this class." What did you mean by free function?
Heh well you seem to know alot more than I do and you are always one of the first to respond to my questions. What year are you?
 
I'm a senior. I have actually not learned that much about C++ from school, and they don't really teach you a whole lot. Many also teach C++ like C, which is not very good. I've learned most of this stuff on SE.
 
M K
I graduated a while ago took several programming classes but didn't end up going that route professionally. Now I'm bored so I'm digging back into it and wish I had never given it up in the first place.
Trying to make up for lost time now.
 
I'm hoping to get into software, but there's still much more I can learn. I shouldn't even hope to "master" C++ since it's not a very easy language to learn thoroughly.
 
M K
11:47 PM
C++ what you are best in?
 
Mostly C++. I also know C (from C++).
 

last day (15 days later) »