I'm trying to lead a software team that is falling behind. One of the main problems is that whenever something is mildly difficult, I end up having to assign it to myself. I had one other developer with moderate skills and half an intern. Unfortunately, the other developer's skills do not include design.
So I begged my boss for one of the guys on one of the other teams, he's been working here longer than I have (5 years). He can't compete with me on design OR the language we use, but I thought he was the most competent besides myself.
Today he gave me a piece of code that did something not in the least bit dissimilar to:
object const& my_class::get_object() const
{
return *std::unique_ptr<object>(new object());
}
He asked me if that was a problem! I said the only thing I could think of, "Yes. That's a problem." Then he comes over to my desk asking me how to fix it!! I said, "Use an object that survives the call of the function." Then he starts freaking out, "Yeah, but how, the only thing I can think of is to make a member variable."
I was a bit busy at this time because I was already trying to stuff in extra work I had to take over for the other guy on the team because he couldn't figure it out...I told the guy to go away because I was busy and to go figure it out himself. Then he leaves in a huff talking about how it's not his fault if he screws things up. He's been freaking out since he came on the team and I don't think it's getting better.
I feel like I'm drowning here. WTH can I do? What was the right way to deal with that? Would it have been more reasonable to go help this guy who's been writing C++ for 7 years figure out how to correctly return a reference to an object that isn't destroyed the moment it's returned? I feel like that's just ridiculous to have to do and wonder how the hell I'd get anything done that way.
Sometimes I think they're doing it on purpose but that seems to me to just be whack...but then again, so does the question I was just asked today. This isn't some kid sitting at home trying to figure out his first program, having his brain blown by pointers.
new object
seems to be exactly what you want to do, since it will survive the return. Thestd::unique_ptr
won't, but that's not what's being passed back. Either your programmer wrote something significantly different or you messed up. – David Thornley Jan 19 '11 at 16:40