85 karma · joined November 28, 2012
https://github.com/wallstop
eli@theambiguous.co
There's the key phrase
> I haven’t updated that app in years
Arguably, the most important place for clean code is everywhere, but the largest use-case for it is in projects that are expected to live, or in places that the code is seen / used by people who are not the original developer(s).
If your goal is to "ship it and forget it", great. Do whatever you need. Outsource it to some other country if it's cheaper, who cares? You're not going to be maintaining it anyway. Does this make something good? No. Is it excusable? Maybe.
While I am not a C++ day-developer nor guru, from what I have seen and written of modern C++, the "move member variables" is not "good", in any sense of the word, stemming from the reasons put forth by many a comment.
If you ever want to move a member variable, I would highly recommend that you re-think your design. Ask questions such as "why do I want this?" and "is it really more efficient?". In some cases, where perf is really that important, then yea, go for it. However, just because something can be done, does not mean that it should be done.
While I still disagree with your const & return of the original string, I threw together an example showing the same exact API you proposed, but without moving member variables:
https://gist.github.com/wallstop/4d80fba9b1d15da64488
Depending on method usage, this may or may not invoke the cost of an extra string creation (+ extra on move method, - for continual access of cached string)
I can understand the urge to want to have the speed and power of move, but it feels like you're destructively working around the standard. The proposed API in SetStringer seems very dangerous; you're passing back a const ref to a string that isn't really const at all (successive calls after the set has been updated will mutate it's state, users may be unaware of this).
Move, copy, and (const) references each have their place and should be used accordingly. Move when you want a transfer of ownership, copy when you want duplication (at this instance) of ownership to another owner, ref when you want shared ownership. The intent of the article seems to actively go against these intents; stinos' comment sums up the rest of my feelings perfectly.
This is not an example of that.
Going into college, some of my friends started playing LoL. At first casually. Then more, then more, until there were three of us playing 8-12 hours a day. We got very good, stopped playing with our other friends, joined a pro team (what is now Fear). Those 8-12 hours a day became almost mandatory to "keep your edge".
I did this for two years. I spent an incredibly small percent of my time on schoolwork (Perhaps an hour a week), failed a class in my minor that I had a natural talent for (Calc II), skipped classes, and was generally lazy. All because I knew I could just forget whatever pressing problem was there and hop on LoL and get sucked up in it and have fun with my friends.
A year and a couple months ago, after coming back from a paid tourney, I stopped and thought about my life, after one of the many comments my parents made to me about spending all of my time playing video games. I had made a couple thousand dollars (re: in an entire year, probably $2k), but all of my creativity, my interests? I hadn't spent any time on a personal project in years. How long could I sustain this? What would happen when I moved out and started working full time? I didn't like how my current lifestyle answered these questions.
So I quit. Played catchup on the things that didn't stick in school, started writing a lot of software, cooking, exercising, just doing things. Going out. One of my other friends quit too because he was failing school and was forced to by his parents. All of this was difficult: I knew I wasn't going to be hanging out with them 2-3 times a week, playing games. It was very hard. If I wasn't a "creatively-motivated" individual, so to speak, I wouldn't have been able to do it. And even though I was, I still wasted 2 years of my life on video games.
What did we all have in common? Parents who gave us free rent, paid for our school, gave us free food, paid for our insurance, phone bills, etc.
My other friend ended up playing again and is on a different pro team now. "Pro" being word for "top 8, known team", not "pro" as in "making any kind of livable money".
It's way too easy to end up getting sucked into the instant-gratification that video games offer you if you have an addictive personality. Slightly less easy if you don't. The instant gratification is there regardless.
I have a great girlfriend that I can see myself marrying and having kids with in a few years. I'm stumped as to how to handle video games with my kid. And it's a problem that needs answering.
Once again, great post.