Linked by Thom Holwerda on Mon 24th Sep 2012 15:07 UTC, submitted by MOS6510
General Development "I've been programming professionally for about 3 years at this point, and I've noticed some interesting patterns in other programmers I've worked with. One of the key differentiators among programmers is motivation. I'm not referring to an individual's passion to simply be successful in their career, but rather the type of work they want to pursue. The thing they want to do with computers every day, the types of problems they are interested in solving."
Order by: Score:
Excellent article, matches my experience
by theosib on Mon 24th Sep 2012 16:02 UTC
theosib
Member since:
2006-03-02

As he says in the original article, these are points on a spectrum (or maybe in a space), but I definitely see people falling into these categories, and when they respect eachother's talents, they make good teams. I myself, I think, have fallen cleanly at various times into the Engineer and Scientist roles, but not Developer, because I reinvent too many of my own solutions. When I worked as an engineer (over 15 years now), people have called me a scientist, but if you go by this guy's definition, I've been more of an engineer. While working on my doctorate, I found my engineering skills to be immensely useful, but I would struggle from time to time with some of the more esoteric theory. I like theory, and I've done plenty of my own science, but I spend more time using my implementation skills than developing new theory. Even in teaching class, I put a lot of emphasis on the ways that the various theoretical concepts have been implemented in the past.

Reply Score: 3

Comment by ephracis
by ephracis on Mon 24th Sep 2012 16:12 UTC
ephracis
Member since:
2007-09-23

Interesting way to look at it.

I guess I would fall somewhere between engineer and computer scientist. I love to build reusable, well structured and documented projects which preferably solve interesting problems with elegant algorithms.

I really do agree that many computer scientists write very messy code. Especially the ones coming from the fields of mathematics where they are used to naming variables a, b, c... and x, y, z... Most of us coming from the "other end" (self learned, developer way) are not very used to reading stuff like that.

I prefer descriptive names for my variables in code. The one-letter names are reserved for pure mathematics during modeling. ;)

Reply Score: 3

Possible link with personality types?
by Yamin on Mon 24th Sep 2012 16:13 UTC
Yamin
Member since:
2006-01-10

Engineers - INTJ/ENTJ
Scientists - INTP/ENTP
Developers - ISTP

Just a guess. But I wonder if you could test for these to get a better understanding of the team.

http://www.personalitypage.com/high-level.html

Reply Score: 2

earksiinni Member since:
2009-03-27

Personality typing makes me sad.

Reply Score: 2

M.Onty Member since:
2009-10-23

Aye. What if you're the type of person who reacts badly to being asked by an employer to take an intrusive personality test so they can better manage you? How does that person fit into their system? I've seen people take test that and thereafter act up the role they were assigned, much as what happens with horoscopes.

Reply Score: 4

Yamin Member since:
2006-01-10

They make me happy ;)

I'm sure I just dismissed them when I went to high school. Apparently everyone knew about it. I only began understanding it recently when my manager brought it up.

It's very useful actually.
Being an INTJ I am always so insanely focused on does this work. It used to bug me why other people weren't so focused on does it work. I understand a little bit now... and the downsides of my own thinking.

Reply Score: 1

theosib Member since:
2006-03-02

[quote]
Engineers - INTJ/ENTJ
Scientists - INTP/ENTP
Developers - ISTP
[/quote]

I dunno about that. It's always interesting to me how people focus on the positives of types and ignore the negatives. If you are classified as A, then that means you're not classified as B, meaning you lack some talent. Well, that's not true, because people are always multiple cooperating types (but not some of ALL types!), but let's be stupid and ignore that.

All of the NTs make good scientists because they all like to pick apart the logical structure of things. BUT: INTJs tend to develop intricate grand theories of everything and then assume anyone who contradicts their theory is stupid. INTPs get caught up in deductive logic, losing sight of the big picture. ENTJs will get stuck on some grand plan they want to implement and will have trouble letting go if it turns out to be a bad idea. And ENTPs want to spend more time debating than getting things done.

And let's not forget that ISTJs are good at this stuff because they're massive stores of facts, and facts are crucial for science.

ISTPs are gadget freaks, and this leads to too much playing and not enough working.

I can point out the negative side of any MBTI type, actually. ;)

BTW, as for me, I'm an experienced and successful engineer, and I have a doctorate and am a professor of computer science. I mentioned in another comment that according to this guy's model, I'm really mode of an engineer than scientist. My personality type? Well, I get different results. Through a lot of reflection and analysis, it appears that I'm distinctly an INTP, but I've often tested out as ENTJ. As I've gotten older and more socially aware, I've started to test as an ENFJ, but with strong T leanings. Upon more careful analysis, I detect INFP and ISFJ characteristics as well to a minor degree.

BTW, I have performed what you might call "differential diagnosis" (look it up) regarding personality type, and I believe I can determine presence and absence of particular types. So for instance, although ENFJ and INFJ have a lot in common (same dominant and auxiliary functions, just in a different order), there are characteristics that distinguish them. So I can work out if you have ENFJ or INFJ as discrete elements in your personality, or both, or neither. To give you another example, I competely lack ESTJ in my personality in any form.

I should make an aside here and point out that this doesn't really qualify as science. I guess it's a set of falsifiable conjectures, but it would be totally impractical to test it. So it must be relegated to "fun guesses about brain stuff."

Someone is probably going to come along and point out that MBTI is "just preferences." True. MBTI is. But if you break it down to Jungian functions, it's not. It makes more sense to describe a personality in terms of multiple sets of connected talents, and MBTI attempts (poorly) to pigeon-hole you into just one of those categories.

And lastly, personality type doesn't mean as much as you think it does. It doesn't tell you what you can or cannot do intellectually. It tells you what is intellectually OBVIOUS to you. But intelligent people think about non-obvious stuff all the time. So just because you're not an INFJ doesn't mean you can't read people's emotions -- it just means you have to work harder at it.

Reply Score: 2

mistersoft Member since:
2011-01-05

+10 for that ;-)

...and for those of us with quite fractured personalities...... we tick many of the different boxes on that list depending on the day of the week.

similarly, i'm rarely if ever ESTJ either.

in myself i can probably see lots of INFJ, INFP, INTJ, INTP, probably INTJ foremostly ..but chunks of ESTP, ESFP, even bits of ENFP, ENFJ...even ESTP a little. ESTJ and ESTP v little...but not zero. touches of ENFJ, ENTP and even a bit of ENTJ i reckon - however I'm conversely quite tolerant of the occasion benefits of disorganization..as in a healthily chaotic mind/reality. Inefficiency a lot less so. I wouldn't be at all surprised if I have a mildy schizotypal personality tbh -alternatively it's been suggested I might have mild aspbergers too (but various siblings and friends who are doctors with psychiatric experience have said that's 'boll*x' to coin a phrase). I'm a professional scientist by the way. And am alternatively highly organised, disciplined and driven, and lazy, chaotic, and crazy ;-) .I rate Bertrand Russell's In Praise of Idleness amongst other gem's. apparently was a bit of a misogynist in his old age tho ;)

Reply Score: 1

kwan_e Member since:
2007-02-18

Personality type theory is just modern astrology - which is no surprise since Carl Jung studied astrology.

Reply Score: 3

all true
by l3v1 on Mon 24th Sep 2012 17:06 UTC
l3v1
Member since:
2005-07-06

The programmer with a good mix of science and engineering is a true phenom and an invaluable asset.


+1 to that. Fortunately, I can say that I have 1 colleague who's like that, myself leaning a bit more towards Eng than CS. However, we're scientists first, and in these circles eventually you and up with people like that - if all goes well, that is. With sw company contacts I had (taking all of them under one hat for this purpse), my experience was they were 90% programmers, 9% eng.s, and maybe 1% scientists.

Another experince I have is that a lot of researchers who don't code for coding's sake, but code to create software as tools to advance or evaluate their research, so these people generally produce more reliable and stable code than programmers from the above category. Sometimes faster abd more efficient too - you can go a good long way to prove your idea and its implementation is fast and efficient and for that is nice to know that slowness is not because you roduced inefficent code. Plus, most good researchers can do nice SMP code, and they could do that much earlier than the how-hard-it-is-to-switch-to-parallel-coding craziness popped up.

Anyway, original post is +1.

Reply Score: 3

RE: all true
by smilie on Mon 24th Sep 2012 18:52 UTC in reply to "all true"
smilie Member since:
2006-07-19

I've had the luck to work 2 domains at a time at 2 very different companies. Lockheed Missiles and Space Company and IBM in the AS/400 division.

Lockheed was programmer mixed with engineer, I was able to write the programs that controlled, collected, and analyzed data from servo positioning systems. I also got to determine the requirements for that software and overcome the realities of the data integrity in a high noise environment where you wanted to apply statistical analysis to ensure you collected enough data to reduce the random noise effects. We had lots of electrical & electronics engineers with 1 or more decades of experience in this area and it could be great fun working closely with them to create solutions to their proposals.

The environment for IBM was engineer mixed with scientist. Half the people in our group had PhDs, one third were MS degrees, and the rest were BA/BS degrees. The group focused on the O/S kernel performance: algorithms, data structures, testing methodology, regression testing, simulation, and detective work. This was carried out in coordination with kernel development and compiler groups. One of the most important tools we ended up using, while I was there, was customer written applications. For some reason the customers didn't write code that used our system the same was IBM did and software upgrades that looked good in our tests would cause enormous heartburn for us. For my group it indicated the test cases we had created were not testing the correct parts of the system and we needed to rewrite the tests. You can imagine the meeting where it was explained that the test run wasn't really 5% better than the previous released version, it was 20% slower, caused the compiler group some irritation. It threw our schedule back 3 to 6 months and resulted in both compiler and O/S structure changes that, I think, improved the product. It certainly improved the testing methodology.

Both environments were intellectually stimulating, at Lockheed you were working real-world real impact national and international projects that have been known to last 30 and 40 years. At IBM the projects were much faster and yet allowed you to interact with people with in-depth knowledge of the computer and mathematical basis of what we were doing (we had one simulations expert leave to be a professor of mathematics at the University of Wisconsin and several people that I knew that had been professors.)

Reply Score: 2

Simple & Clear
by fadingdust on Mon 24th Sep 2012 18:49 UTC
fadingdust
Member since:
2009-11-05

Being a self-taught dev, I've lately noticed these tendencies, though I never noticed when I was younger & thought I could do it all.

I kinda get upset that I'm supposed to be doing dev-stuff all day long, but hey, I get paid for it. Whenever a project changes, I turn into engineer-fixit-mode. And lately I've been taking a data-scientist approach to some of my side-projects (and SEO stuff).. It's all loads of fun.

Reply Score: 2

Sad Truth
by JeeperMate on Mon 24th Sep 2012 19:26 UTC
JeeperMate
Member since:
2010-06-12

From my experience interviewing hundreds of Computer Engineering/Computer Science graduates all these years, I can say most of them fulfill the following condition:

if ( !(developer) && !(engineer) && !(scientist) ) {}

For example, I interviewed a semi fresh grad with one year work experience last Friday. I asked him to write a piece of code (in C++, because that's the language he claimed to be most comfortable with) that returns the absolute value of some 32-bit signed integer, just for warmup. He wrote a function that converts the input integer into a string and checks whether it has a negative sign, then... You know the rest.

It got even worse when I asked him to write a function that returns the value of a user-specified octet in any valid IPv4 address. This means the function should take an IPv4 address and the octet number the user wants returned. He did it in an extremely convoluted way that he even had a hard time explaining how the code works.

Needless to say, he had to write an entirely different code for IPv6. *

I passed all his code around to my coworkers after he left my office, and everyone was laughing so hard. One of them even accidentally swallowed her chewing gum.

In case anyone is curious, this one liner function gives you the absolute value of some 32-bit integer 'num':

int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }

There is another way: multiply the number by itself and return the square root of the multiplication (which will make it work with real numbers if you replace all instances of 'int' with 'double'). But the above code should suffice, given the requirement explicitly states 'some 32-bit signed integer'.

Computer Engineering/Computer Science graduates who don't understand why or how the above code works have wasted years of life studying a subject they're not even interested in.

Based on my own professional experience, more than half of 'programmers' that have formal education background in relevant fields (Computer Engineering/Computer Science) barely know how to program these days, which is sad.

This is just my observation. YMMV.

[*] OT: Have they come up with an official name to call IPv6 address parts, yet?

Reply Score: 2

RE: Sad Truth
by feydun on Tue 25th Sep 2012 00:43 UTC in reply to "Sad Truth"
feydun Member since:
2012-02-27

I don't really use C++ but that seems a bit low-level - why assume 32-bit signed with a two's complement representation - or rounding errors from roots - when you could just multiply by -1 if <0 which would also work with doubles or (unexpected) unsigned and wouldn't tie you to a particular (albeit standard) low-level representation? Then when the program evolves some time later, with different developers, they don't have to chase obscure assumptions. I guess that doesn't apply here though else the code would just be an abs function :-)
I do know that the point you're making is totally true. I think it's because you can't learn programming by applying it to toy problems, no matter how much computer science you know. You have to go through the bitter experience of getting real projects to work.

Reply Score: 2

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 10:15 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

The point of these types of questions is to see whether an applicant can think of an efficient solution to a problem using a language he/she is most familiar with. I could've asked him to write a code for something more serious, but really if one couldn't come up with a simple solution to a simple problem, I doubt he/she could tackle more complicated problems. I've seen this pattern repeatedly.

Reply Score: 2

RE: Sad Truth
by ssokolow on Tue 25th Sep 2012 04:45 UTC in reply to "Sad Truth"
ssokolow Member since:
2010-01-21


"int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }

There is another way: multiply the number by itself and return the square root of the multiplication (which will make it work with real numbers if you replace all instances of 'int' with 'double'). But the above code should suffice, given the requirement explicitly states 'some 32-bit signed integer'.

Computer Engineering/Computer Science graduates who don't understand why or how the above code works have wasted years of life studying a subject they're not even interested in.
"

Thank you for reminding me to re-teach myself two's complement. Last time I learned it, I was sleepy, rushed, and hadn't discovered Taskwarrior.

(Because I don't remember the relationship between one's complement and two's complement enough to use it from memory, I'd have multiplied by -1 to convert instead... or just used abs() in a practical situation. 95% of the code I've had to write has been in Python lately and the rest in bash script.)

Reply Score: 2

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 10:24 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Yes, sure... There's abs(). There are a gazillion other functions offered by various 3rd-party libraries for various purposes. Heck, one could even Google for solutions to basic programming problems. But a) we cannot always depend on 3rd-party solutions in real projects (most of the times we have to implement our own libraries or at least fork something that's closest to our requirements), and b) we need a programmer who can come up with good solutions without depending on Google Search.

If one doesn't remember such a basic thing he/she learned at school, what else has he/she forgotten?

Reply Score: 1

RE[3]: Sad Truth
by phreck on Tue 25th Sep 2012 12:01 UTC in reply to "RE[2]: Sad Truth"
phreck Member since:
2009-08-13

Now you are showing ridiculous behaviour.

You show to your working comrades a young boys code for teh lulz (which is a form of sadism), and then don't even now that abs() is a standard function?

Fellows and Me: "What."


Seriously: If you want a simple and elegant solution:

#include <algorithm>
...
std::abs(...)
...

Edited 2012-09-25 12:09 UTC

Reply Score: 1

RE[4]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 12:45 UTC in reply to "RE[3]: Sad Truth"
JeeperMate Member since:
2010-06-12

Phreck, again, the question is essentially "do you have an idea how abs()" is implemented? If you answered "just use abs()," you're screwed.

The point of the question is to test basic programming knowledge and skill (i.e. to answer the question: "can this young man think like a programmer?")

If you don't like that kind of question, you can either avoid programming job interviews, or don't ask them to interviewees.

Edit: when I was in the interviewee's position (a long time ago) I was even asked to write a FizzBuzz code. Now that's ridiculous.

Edited 2012-09-25 12:49 UTC

Reply Score: 1

RE[5]: Sad Truth
by phreck on Tue 25th Sep 2012 12:52 UTC in reply to "RE[4]: Sad Truth"
phreck Member since:
2009-08-13

By your original question, this would be correct:


#include <cstdint>
#include <algorithm>

int32_t myAbs(int32_t val) {
return std::abs(val);
}

This is even more correct than my other solution, because you explicitly mention 32 bit signed integers. The datatype "int" can also be 64 bit, so your solution is not even portable.

And if you would tell me not to use "3rd-party libs" for standard-C++ functions like std::abs(), I would immediately quit the interview under the assumption that your dev-department heavily suffers the NIH-syndrome and missed the last 20 years of C++ standardization.

Reply Score: 2

RE[6]: Sad Truth
by rr7.num7 on Tue 25th Sep 2012 19:10 UTC in reply to "RE[5]: Sad Truth"
rr7.num7 Member since:
2010-04-30

And if you would tell me not to use "3rd-party libs" for standard-C++ functions like std::abs(), I would immediately quit the interview under the assumption that your dev-department heavily suffers the NIH-syndrome and missed the last 20 years of C++ standardization.


+1

Also, as others already said, there are simpler ways (even as simple as using unary minus operator) to solve this than using bitwise operations. I think anyone who choses the latter is nothing but a show-off. It might be acceptable in a student, but not in a professional.

Reply Score: 1

RE: Sad Truth
by Neolander on Tue 25th Sep 2012 06:07 UTC in reply to "Sad Truth"
Neolander Member since:
2010-03-08

In case anyone is curious, this one liner function gives you the absolute value of some 32-bit integer 'num':

"int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }"

There is another way: multiply the number by itself and return the square root of the multiplication (which will make it work with real numbers if you replace all instances of 'int' with 'double'). But the above code should suffice, given the requirement explicitly states 'some 32-bit signed integer'.

Computer Engineering/Computer Science graduates who don't understand why or how the above code works have wasted years of life studying a subject they're not even interested in.

Just out of curiosity, would this have been a valid option in your opinion ?

int absolute(const int num) { return (num>=0)?num:-num; }

That would pretty much have been my spontaneous answer to your problem (except with an if ... else structure instead of the trigraph).

Reply Score: 1

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 10:30 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Yes, that is an adequate answer.

There are often lots of solutions to every problem, we just have to avoid bad ones. That's what I always want to see from an applicant and team members (i.e. whether he/she can avoid bad solutions).

Reply Score: 1

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 11:36 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Addendum:

And btw, both your solution and the solution I wrote in my original post have a bug, which I would've asked about, if he would've come up with something similar to mine or yours. But this follow-up question is only meant to test his mastery, which is not compulsory for the position he was being interviewed for. We don't want to assign maintenance works to someone who really masters his/her field -- such person deserves more challenging tasks.

Reply Score: 1

RE[3]: Sad Truth
by peejay on Tue 25th Sep 2012 18:38 UTC in reply to "RE[2]: Sad Truth"
peejay Member since:
2005-06-29

Addendum: And btw, both your solution and the solution I wrote in my original post have a bug...

The bug is that none of the code is commented. ;)

I'm basing this especially on "Computer Engineering/Computer Science graduates who don't understand why or how the above code works have wasted years of life studying a subject they're not even interested in" which implies that no one else is going to understand even this simple function.

Edited 2012-09-25 18:41 UTC

Reply Score: 2

RE: Sad Truth
by Loreia on Tue 25th Sep 2012 08:28 UTC in reply to "Sad Truth"
Loreia Member since:
2012-01-17


In case anyone is curious, this one liner function gives you the absolute value of some 32-bit integer 'num':

"int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }

There is another way: multiply the number by itself and return the square root of the multiplication (which will make it work with real numbers if you replace all instances of 'int' with 'double'). But the above code should suffice, given the requirement explicitly states 'some 32-bit signed integer'.

"

I actually have few issues with your code.
1. Why do you use trigraph here? It only makes code it harder to read. Not by much, but still, I need to stop for few seconds to decipher that line. If ... else block would be much nicer.

2. I try to use trigraphs only in combination with boolean values:
return isPositive ? num : (-1)*num;
This form makes it much easier to read the code. Boolean expressions fit much nicely in if ... else block.

These two points might be a personal preference, but I believe that code readability is the most important thing in coding (I did work in design maintenance for years, so my views are a bit distorted though)

3. Why not use abs function? Why do you need an implementation of your own? My response during the interview would be: There is already a function that does just that, in C/C++ I would use abs. One downside is the ugliness of using abs labs, cabs, llabs, fabs for different number types, but your example was about ints, so abs would be a natural choice.

4. And finally, the implementation itself.
Why would you use two's complement for such trivial thing? Two's complement is something they teach you at the university, and 99% of people forget about it before they graduate. That means more likely that not, other programmers will not be able to figure out your code at first glance.
What would be the reason for this kind of complexity? Speed of execution? Why don't we let compiler worry about that, and just write num*(-1)?

I work in a company where programmers regularly write functions that wrap assembler code. You see, our in house compiler is not very smart with optimizations, but for regular C/C++ I'd recommend letting compiler optimize such trivial things like num*(-1).

5. What to say about your other solution?
That one is almost in the league of what student wrote. Multiply, than square root? Compared to num*(-1) logic is complex and there's just too much work.


Other than this example, I support your comment 100%.

BR
Loreia

Reply Score: 3

RE[2]: Sad Truth
by phreck on Tue 25th Sep 2012 08:53 UTC in reply to "RE: Sad Truth"
phreck Member since:
2009-08-13

Nitpick: "Trigraphs" -> http://de.wikipedia.org/wiki/Trigraph

You really meant "Ternary Operator", often called "The Ternary [Operator]", because there is only one in both C and C++.

Then: Instead of multiply by -1, just use the unary negation operator.


I disagree about the bad readability of the ternary operator. It is just as readable as an if-statement or class-declarations. The one thing you have to do, like with all other things in C++, you just learn it. That's it.

As with if-statements, while-loops and everything else, you only have to know when to use, and not exaggerate it (again, like with other things in C++).


Apart from that, I totally agree to your last three points.

Edited 2012-09-25 08:59 UTC

Reply Score: 2

RE[3]: Sad Truth
by Loreia on Tue 25th Sep 2012 09:20 UTC in reply to "RE[2]: Sad Truth"
Loreia Member since:
2012-01-17

Nitpick: "Trigraphs" -> http://de.wikipedia.org/wiki/Trigraph

You really meant "Ternary Operator", often called "The Ternary [Operator]", because there is only one in both C and C++.

Then: Instead of multiply by -1, just use the unary negation operator.


I disagree about the bad readability of the ternary operator. It is just as readable as an if-statement or class-declarations. The one thing you have to do, like with all other things in C++, you just learn it. That's it.

As with if-statements, while-loops and everything else, you only have to know when to use, and not exaggerate it (again, like with other things in C++).


Apart from that, I totally agree to your last three points.


Yes, ternary operator, thanks for pointing it out, I didn't even notice my mistake.

I find ternary operator less readable than if-else block, for anything longer than:

bool ? 0 : 1

In this specific case, I see no reason in condensing function to one line by using ternary operator.
I prefer:

int funct (int num)
{
if (num < 0)
retrun num*(-1)

return num
}


It just takes less time and effort to read that than this:

int funct(int num){return (num<0)?num*(-1):num;}


Again, it is a personal preference, and ternary operator certainly has its place (and I do use it) in C/C++.

As with if-statements, while-loops and everything else, you only have to know when to use, and not exaggerate it (again, like with other things in C++).

Absolutely, that was exactly my point.

Then: Instead of multiply by -1, just use the unary negation operator.

Even better, I actually first read comment by Neolander, and followed what he said (trigraph and *(-1)). I guess lack of sleep kicked in and I didn't notice there was even simpler solution.

BR
Loreia

Reply Score: 2

RE[4]: Sad Truth
by phreck on Tue 25th Sep 2012 09:34 UTC in reply to "RE[3]: Sad Truth"
phreck Member since:
2009-08-13

I think you can write even complex ternary operator statements with only a good format:

return x ? foo :
y ? bar :
z;

(sorry, still don't know how to verbatim here)

I think what we discuss about is really personal preference, because I (and other proponents) find it not harder to read. To us, it really was only a matter of learning ;)

Reply Score: 1

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 11:33 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Question no. 1:
Really? we encounter ternary operator on a day-to-day basis. It's very common here. That snippet in my original post is just an example, for the sake of brevity.

Question No. 3:
This is already answered in one of my earlier replies. To put it another way, my question to the applicant was essentially "could you write an example of abs() implementation for me?".

As for No. 4:
Very few people forget such basic operation. Most fresh (or semi-fresh) grads still remember. And it's not a matter of optimization whatsoever. Again, that's just an example. It doesn't mean I would frown at solutions different from mine. I just don't like bad solutions.

Even the solution I wrote in my original post has a bug, which I would've asked about, if he would've come up with something similar. But this follow-up question is only meant to test his mastery, which is not compulsory for the position he was being interviewed for.

Question No. 5:
Given such solution, I would ask the applicant about overflows, but again, this is a test of mastery and is not compulsory for the position in question, but a test that must be performed nonetheless.

Reply Score: 1

RE[3]: Sad Truth
by phreck on Tue 25th Sep 2012 12:04 UTC in reply to "RE[2]: Sad Truth"
phreck Member since:
2009-08-13

I somewhat don't believe you that you knew about the bug when you wrote your first post.

Reply Score: 1

RE[4]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 12:32 UTC in reply to "RE[3]: Sad Truth"
JeeperMate Member since:
2010-06-12

Phreck, it's impossible to address such suspicion here, so I can't say anything about that.

Anyway, the function in my original post is pretty basic that anyone who has written enough arithmetic code would spot the bug just by glancing over it. I'm not saying I'm a wizard here, mind you.

Reply Score: 1

RE[3]: Sad Truth
by Loreia on Tue 25th Sep 2012 13:17 UTC in reply to "RE[2]: Sad Truth"
Loreia Member since:
2012-01-17

Question no. 1:
Really? we encounter ternary operator on a day-to-day basis. It's very common here. That snippet in my original post is just an example, for the sake of brevity.

Question No. 3:
This is already answered in one of my earlier replies. To put it another way, my question to the applicant was essentially "could you write an example of abs() implementation for me?".

As for No. 4:
Very few people forget such basic operation. Most fresh (or semi-fresh) grads still remember. And it's not a matter of optimization whatsoever. Again, that's just an example. It doesn't mean I would frown at solutions different from mine. I just don't like bad solutions.

Even the solution I wrote in my original post has a bug, which I would've asked about, if he would've come up with something similar. But this follow-up question is only meant to test his mastery, which is not compulsory for the position he was being interviewed for.

Question No. 5:
Given such solution, I would ask the applicant about overflows, but again, this is a test of mastery and is not compulsory for the position in question, but a test that must be performed nonetheless.


1. Yes really, I find that ternary operator out of place in your example. But as I said in another discussion, it is a matter of personal preference, and as such hardly worth a long discussion.

3. When you put it like that, it is a whole another story. In normal C++ code, one would use abs(num) and be done with it. But the way I read your posts here, it sounds like you think (or have thought) that abs is some sort of non standard, third library, hack. Another strange thing I noticed in some of your posts, was criticizing use of Google. What is the problem with that? Google is a great tool to find quick and simple solutions for small problems. In fact, Google will more likely that not (in my experience), point to the standard (most typical) way.

4. Still it is relatively complex and unintuitive binary hack and if I was mentoring you, I'd point that function as something that needs to be simplified. You say that you don't like bad solution, and converting to string for testing of presence of minus sign is certainly a bad solution, but I would argue that your implementation is also a bad solution just to a lesser degree. And the second solution you offered is bad in both performance and correctness as it covers only numbers up to 2**16 (for 32 bit integers).

And what bug are you talking about? Passing in unsigned int?

5. Fair enough.

The thing is, your original post made a lot of sense until you wrote your own code. You have obviously interviewed a newbie, and his mistakes were naive, even funny, but then you offered something from the same neighborhood. That is what I was aiming at.

BR
Loreia

Reply Score: 1

RE: Sad Truth
by phreck on Tue 25th Sep 2012 08:39 UTC in reply to "Sad Truth"
phreck Member since:
2009-08-13

Why so complicated:

int abs (int val) {
return val<0 ? -val : val;
}

or

template <typename T>
T abs (T const &val) {
return val<0 ? -val : val;
}


and squaring the number first is, in the real world, prone to overflow and assumes the presence of a square rooter.

But I am glad you and your friendly colleague enjoyed your sadism over that poor soul.

Reply Score: 2

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 12:15 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Yes, you would get a big smile from me for writing such code. But still, it contains the same bug as my example and I'd ask you about that.

Sadism? No at all. By that I mean we weren't making fun of the individual, we were just laughing at the funny code he wrote. We never even care whether an applicant is normal looking or not, or whether he walks on his two feet or rolls in a wheelchair.

Reply Score: 1

RE[3]: Sad Truth
by phreck on Tue 25th Sep 2012 12:47 UTC in reply to "RE[2]: Sad Truth"
phreck Member since:
2009-08-13

What would that bug be that would imply that most C++ implementations are wrong?

Here is the GNU implementation, located in bits/stl_algobase.h (an implementation detail of the head "algorithm"):

template<typename _Tp>
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
//return __a < __b ? __b : __a;
if (__a < __b)
return __b;
return __a;
}


And it is already sadism if you laugh about the product of someone's intellect, even if you do it behind closed doors, which would imply uncandidness, and possibly a breach of confidentiality regulations. But of course that is not my problem, so I stop lamenting about that.

Reply Score: 1

RE[4]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 13:01 UTC in reply to "RE[3]: Sad Truth"
JeeperMate Member since:
2010-06-12

That bug is your homework. Test the code thoroughly, and you'll find it very quickly.

Confidentiality only applies to personal information and all the documents sent to me or to the company. It doesn't apply to codes written by anyone during the interview. I haven't disclosed any bit of personal information pertaining to that guy, now have I?

Reply Score: 1

RE[5]: Sad Truth
by phreck on Tue 25th Sep 2012 13:58 UTC in reply to "RE[4]: Sad Truth"
phreck Member since:
2009-08-13

Why are you so shy to explain what's wrong? Seriously, if you would be a teacher, as you try to impose now, you'd be a really bad one.

So let's accept there is a bug depending on integral representation.

The other bug of course is _your_ use of "int", apart from other issues.

---

About the confidentiality: Seriously, I don't know how you define it in your company. But that code is indeed something personal, as are his answers or his resume. Additionally, you've screwed that guy before the others, and possibly no one who opens his/her own company will now ever hire him, or upon changing the job give a recommendation to the boss.

I don't know. The mills of data are patient.

It boils down to: What business do non-HR ppl have with documents from closed-room-interviews? Why use the illusion of a closed room at all (I assume that by the timeline you imply)? Well, let me break your illusion of you being "better".

I'd really like to ask which company that is you work at, so I can put it onto my "never waste money/time on that" blacklist, neither job-wise, nor business-wise.

Edited 2012-09-25 14:00 UTC

Reply Score: 1

RE[6]: Sad Truth
by Loreia on Tue 25th Sep 2012 14:09 UTC in reply to "RE[5]: Sad Truth"
Loreia Member since:
2012-01-17

So let's accept there is a bug depending on integral representation.


The problem is how do you treat number that consist of 1 followed by a bunch of zeros. So, when he is talking about a bug, he probably wants to treat return value as unsigned int.

I can't see any other problem with the code.

Reply Score: 1

RE: Sad Truth
by renox on Tue 25th Sep 2012 12:51 UTC in reply to "Sad Truth"
renox Member since:
2005-07-06

In case anyone is curious, this one liner function gives you the absolute value of some 32-bit integer 'num':
"int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }

"
Big fail!, what about INT_MIN?
The absolute value of a 32-bit integer needs to be given on a >32bit integer type.

Reply Score: 3

RE[2]: Sad Truth
by JeeperMate on Tue 25th Sep 2012 13:01 UTC in reply to "RE: Sad Truth"
JeeperMate Member since:
2010-06-12

Well, you've done your homework.

Reply Score: 0

RE[3]: Sad Truth
by phreck on Tue 25th Sep 2012 14:49 UTC in reply to "RE[2]: Sad Truth"
phreck Member since:
2009-08-13

Now finally come down from your wannabe-teacher-trip, because you haven't done "your homework". Relying on fixed bit patterns when using types of unknown size is outright dangerous and leads to stuff that kills space rockets.

Reply Score: 2

RE: Sad Truth
by Alfman on Tue 25th Sep 2012 14:35 UTC in reply to "Sad Truth"
Alfman Member since:
2011-01-28

JeeperMate,

"int myAbs(const int num) { return num < 0 ? (~num) + 1 : num; }"


I concur with everyone else that taking the not and adding one is a roundabout way of calculating what we really want, which is a simple negation.

However I'll go one further and claim that your solution is potentially invalid because you make an assumption about two's compliment that C doesn't guarantee. In fact it explicitly lists 3 different number sign representations.

http://stackoverflow.com/questions/3952123/representation-of-negati...

Now I'm clearly playing devil's advocate here, but arguably an ABS function implementation that converts an integer to string and removes the sign character is, according to the C standard, more correct than one that makes assumptions about the bits.

All this time you were laughing at him, and yet his inefficient solution may have been more correct than yours. I hope you can laugh at the irony. ;)

Reply Score: 2

Comment by wigry
by wigry on Mon 24th Sep 2012 21:12 UTC
wigry
Member since:
2008-10-09

Been in computer business for 18 years now and professional developer for 10 years. Before becoming developer, I've been everything from the box carrier boy to server admin. One of the things I see very valuable in software business is the understanding how computers work and not just theoretically but you really need to have that sysadmin experience to understand how OS works etc. Many new developers struggle in this part if they came from university and instantly become developers without proper background.

Second thing I've noticed about development over the years is the necessity and ability to hold myself back in a sense the while some things are cool (at the moment) it is not a good idea to use every cool thing in a long term enterprise project. I've had many-many unnecessary struggles where the earlier architect/developer had chosen the framework or library that was the buzzword of the month and now it has difficulty keeping up with the demands of the system. Therefore I've found that reasonable amount of oldschool is absolutely neccessary to be successful in enterprise development where the expected lifetime of the appliccation is 10+ years. You have to really chose the tools that are maintenance-free and rock solid and perform in all conditions.

Lastly I must point out that while it is absolutely cool to build layer upon layer upon layer of abstractions to end up with the coolest architecture on earth, it will cost insane amount of money and nerves in later maintenance phase. Therefore I personally have again chosen the oldschool simplistic architectural solutions where the amount of abstraction is minjmal but you have instant clear understanding what part of the app does which task.

And I am in love with MVC paradigm where you have the fat but intelligent model, and then just a thin controller and view layers. Works everywhere from embedded apps to big enterpise intranet solutions

Reply Score: 2

Developer
by WorknMan on Tue 25th Sep 2012 06:13 UTC
WorknMan
Member since:
2005-11-13

I fall definitely in the developer category and will admit that I'm not very proficient. The reason is because I really don't like coding; I usually end up forced into it because I can't find another solution that does a very specific thing that I need to have done.

Reply Score: 3

RE: Developer
by ssokolow on Tue 25th Sep 2012 07:36 UTC in reply to "Developer"
ssokolow Member since:
2010-01-21

I fall definitely in the developer category and will admit that I'm not very proficient. The reason is because I really don't like coding; I usually end up forced into it because I can't find another solution that does a very specific thing that I need to have done.


I'm an interesting case because I'm fairly firmly a high-level guy but I'm such an engineer that, until I taught myself to recognize that perfection is impossible if you never release, I hadn't released anything.

I'm basically a very odd mix of a UI/UX designer and an engineer. (and I'm currently retrofitting my approach to programming and my personal projects to incorporate automated testing... one of the areas where my obsessive perfectionism and ability to pay exhaustive attention to detail are hugely beneficial)

The kinds of programmer-engineer problems I usually solve are things like:

1. The URL normalizer I'm designing to do as much as reliably possible to normalize URIs and IRIs offline. (Because they may be normalized in such large batches that I'd get IP banned for doing HTTP lookups as part of the normalization process)

2. The PyGTK gtk.Entry subclass I'm working on that intuitively uses Tab both for focus-switching and for content completion. (For use in a high-speed, low-latency image-tagging GUI)

3. The pure-Python GIF parser I've finished (see gif.py on ssokolow.com) for examining GIF metadata without loading the entire image into memory which could do a framecount on 1000 GIFs in 9 seconds on my old PC.

Edited 2012-09-25 07:37 UTC

Reply Score: 3