Code examples and interviews



  • @mfah said:

    @tster said:

    I don't see anywhere in the problem the use of the word "function" or "functions."   Functionality != functions 

    It was actually in the OP.  But the key thing here is a "letter of the law" vs. "spirit of the law" thing. Most of us would see the most relevant part of the directions as being "to directly solve the problem".  This would mean that indirect is fair game.

     

    I agree completely with this post.  I am simply trying to point out that the wording of the question is open to interpretation, and is not clear at all in what specifies "directly solve." 



  • @drinkingbird said:

    If  you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[(0), in which case it's one of the built in string methods.
     

    Again, read the actual requirements. I think the intention is clear. Being pedantic would not benefit the interviewer or interviewee.



  • @tster said:

    I don't know what MSDN your refering to here, but the C# keyword "string" is directly mapped to System.String.

    Fair enough, I'm not too proud to admit I'm wrong when I'm wrong, and I was wrong there.

    But the main point still stands, you can array-index a string also. 



  • @MasterPlanSoftware said:

    @drinkingbird said:

    If  you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[(0), in which case it's one of the built in string methods.
     

    Again, read the actual requirements. I think the intention is clear. Being pedantic would not benefit the interviewer or interviewee.

     

    Again, read my actual post. I think the intention is clear. The point was to nitpick for the hell of it. Your comments benefit neither reader nor writer.



  • @drinkingbird said:

    Again, read my actual post. I think the intention is clear. The point was to nitpick for the hell of it. Your comments benefit neither reader nor writer.
     

    Thanks for the delightful contribution.



  • @drinkingbird said:

    @MasterPlanSoftware said:

    @drinkingbird said:

    If  you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[(0), in which case it's one of the built in string methods.
     

    Again, read the actual requirements. I think the intention is clear. Being pedantic would not benefit the interviewer or interviewee.

     

    Again, read my actual post. I think the intention is clear. The point was to nitpick for the hell of it. Your comments benefit neither reader nor writer.

    MPS is right.  The array index is a property rather than a method anyway. 



  • @mfah said:

    @drinkingbird said:

    @MasterPlanSoftware said:

    @drinkingbird said:

    If  you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[(0), in which case it's one of the built in string methods.
     

    Again, read the actual requirements. I think the intention is clear. Being pedantic would not benefit the interviewer or interviewee.

     

    Again, read my actual post. I think the intention is clear. The point was to nitpick for the hell of it. Your comments benefit neither reader nor writer.

    MPS is right.  The array index is a property rather than a method anyway. 

     

    would you consider a property to be functionality?  If you claim a property is not functionality please explain the difference between a getter method and a property read. 



  • @tster said:

    would you consider a property to be functionality?  If you claim a property is not functionality please explain the difference between a getter method and a property read. 
     

    I resign from this argument. You are arguing against all logic and intent. I don't know why I thought common sense might prevail.



  • @tster said:

    would you consider a property to be functionality?

    Sometimes, depending on how it's coded. 

    @tster said:

    If you claim a property is not functionality please explain the difference between a getter method and a property read. 
     

    No. 



  • @mfah said:

    @tster said:

    would you consider a property to be functionality?

    Sometimes, depending on how it's coded. 

     

    Are you saying that given an interface:

    IFoo { int Prop { get; }}

     and two classes:
    Foo1 accesses a local variable from memory to get the value of Prop

    Foo2 accesses a remote server to get the value of Prop.

     

    that Foo1 is not a functionality while Foo2 is a functionality?  They are meeting the same contract, and therefor they are both functionality.  

     

    MasterPlan,
    I'm not arguing that it is impossible to do, I've already stated that I was simply arguing that to play devils advocate.  I'm arguing, as has been my point the whole time, that the wording of the question is poor.  The problem with the argument "software developers should be able to figure out a way to work around unclear specifications" isn't valid because these specifications are imposing arbitrary rules.  When developing real software for users, such arbitrary rules do not apply, therefore there is no correlation. 



  • @tster said:

    Are you saying that given an interface:

    IFoo { int Prop { get; }}

     and two classes:
    Foo1 accesses a local variable from memory to get the value of Prop

    Foo2 accesses a remote server to get the value of Prop.

     

    that Foo1 is not a functionality while Foo2 is a functionality?  They are meeting the same contract, and therefor they are both functionality. 

    No. 



  • @tster said:

    the wording of the question is poor
     

    Only to you. The rest of us understand it fine.



  • @mfah said:

    @tster said:

    Are you saying that given an interface:

    IFoo { int Prop { get; }}

     and two classes:
    Foo1 accesses a local variable from memory to get the value of Prop

    Foo2 accesses a remote server to get the value of Prop.

     

    that Foo1 is not a functionality while Foo2 is a functionality?  They are meeting the same contract, and therefor they are both functionality. 

    No. 

     

    then what is a case that a property is a functionality and what is a case when a property is not a funtionality.  You seem to be good at taking a position, but poor at providing any kind of reasoning.  Simply agreeing with the majority will not prove that you are correct. 



  • @tster said:

    then what is a case that a property is a functionality and what is a case when a property is not a funtionality.

    Edit time expired before I could change that one to "yes", actually.  The implementation of Prop in Foo1 doesn't depend on anything outside of Foo1, whereas the implementation of Prop in Foo2 does (namely, all sorts of interesting and fun conditions that could apply to the remote server).  That's the key difference.  The same applies to the original example, where .Length () and an array index don't depend on anything outside of the original String, whereas IndexOf () does. 



  • @mfah said:

    @tster said:

    then what is a case that a property is a functionality and what is a case when a property is not a funtionality.

    Edit time expired before I could change that one to "yes", actually.  The implementation of Prop in Foo1 doesn't depend on anything outside of Foo1, whereas the implementation of Prop in Foo2 does (namely, all sorts of interesting and fun conditions that could apply to the remote server).  That's the key difference.  The same applies to the original example, where .Length () and an array index don't depend on anything outside of the original String, whereas IndexOf () does. 

     

    that's an interesting definition of functionality.  What about an interator's next() method?  It depends only on the internal state of teh iterator, yet I would most certainly consider it functionality. 



  • @tster said:

    that's an interesting definition of functionality.  What about an interator's next() method?  It depends only on the internal state of teh iterator, yet I would most certainly consider it functionality. 

    That's a very good example.  One could add that anything (exposed externally) that changes internal state is also functionality (seems a no-brainer), or one could argue that the initial filling of the list (which the iterator definitely depends on) qualifies under my original interpretation (I prefer that term to "definition" here) - although that seems a very weak argument IMO (the filling could be purely internal).



  • @mfah said:

    @drinkingbird said:

    @MasterPlanSoftware said:

    @drinkingbird said:

    If  you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[(0), in which case it's one of the built in string methods.
     

    Again, read the actual requirements. I think the intention is clear. Being pedantic would not benefit the interviewer or interviewee.

     

    Again, read my actual post. I think the intention is clear. The point was to nitpick for the hell of it. Your comments benefit neither reader nor writer.

    MPS is right.  The array index is a property rather than a method anyway. 

     

    Properties are just dressed up get/set methods. I don't know why C# et al have to muddy the waters on this. Is it so hard to comprehend that obj.property = "blah" could just be calling the method obj.property= ?

    Since the property isn't just an exposed instance variable, it behaves as a method.

    Besides which, MPS wasn't actually addressing any property/method definiton, just missing the point that I was nitpicking for the hell of it.



  • @mfah said:

    @tster said:

    that's an interesting definition of functionality.  What about an interator's next() method?  It depends only on the internal state of teh iterator, yet I would most certainly consider it functionality. 

    That's a very good example.  One could add that anything that changes internal state is also functionality (seems a no-brainer), or one could argue that the initial filling of the list (which the iterator definitely depends on) qualifies under my original interpretation (I prefer that term to "definition" here) - although that seems a very weak argument IMO (the filling could be purely internal).

     

    the problem with that interpretation (I agree, a better term) is that now you have excluded hasNext() from the relm of functionality.  I think the only safe way to interpret functionality is as "any accessable member that gives information and/or causes side effects."   



  • @tster said:

    the problem with that interpretation (I agree, a better term) is that now you have excluded hasNext() from the relm of functionality.  I think the only safe way to interpret functionality is as "any accessable member that gives information and/or causes side effects."
     

    hasNext () would depend on the current value of the iterator though, which is set externally.

    I do like your interpretation (even if mine is different, I'd exclude giving information and focus more on "actually doing stuff"), but it opens the question of what do we consider "information" to be.  In the case of a string, I would personally consider length and array indexes to be more side-effects of the real information.  For an iterator, each item being iterated through and returned would constitute information in it's own right.



  •  I think we are going to have to agree to disagree on this.  



  • @pitchingchris said:

    would the regular expressions class be considered in the category of built in string functions ?

    I'd say so since they're built in.  Sure, they're not "The C# String library" but since its pretty obvious what they're asking the candidate to do, being "clever" by using a regex isn't going to win them over.



  • @MonkeyCode said:

     http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2098703&SiteID=1

    This one just blows me away. He can't figure out how to check what the first character of a string is. That is just so fundemental, it's beyond belief. It's Paula level ability.

    Yet in his current position he seems to be developing (either alone or in a team) something like a stock management system. By the sound of the database question, he's playing around in the live system, too (perhaps the only server is the live server, too). I wish I knew what company he was working for...



  • @Soviut said:

    @pitchingchris said:

    would the regular expressions class be considered in the category of built in string functions ?

    I'd say so since they're built in.  Sure, they're not "The C# String library" but since its pretty obvious what they're asking the candidate to do, being "clever" by using a regex isn't going to win them over.

     

    "Now they have two problems" </jwz> 



  • @MasterPlanSoftware said:

    @taylonr said:

    And this, boys and girls, is why I call myself a software developer or software engineer, and NOT a programmer. 
     

    So do half of the people who behave this way... Title means nothing. Ask anyone who has interviewed numerous candidates. You will find 'Architects' and 'Engineers' who can barely write a hello world in Java...

     I guess I didn't mean that I call myself that on applications as a way to distinguish between me and programmers.  But rather, when people ask what I do, I tell them I'm a "Software Engineer" (wouldn't consider myself an architect yet).  And about 50-60% of the time that opens up the question like "Do you mean a programmer?" And that gives me an oppportunity to explain.

     



  • @taylonr said:

    But rather, when people ask what I do, I tell them I'm a "Software Engineer" (wouldn't consider myself an architect yet). 
     

    Right, my point is that the people you are trying to differentiate yourself from also do the same thing unfortunately.



  • @AbbydonKrafts said:

    @tster said:
    given the wording of the question, the task is impossible

     

    But, I've also heard people refer to everything as "functions", including properties. So, if that is the case here, then yes, it would become impossible because then even Length would be disallowed.

     

     Perhaps they come from a javascript or similar background, where, if I recall correctly, every property can be invoked as if it were a function. Some languages really don't distinguish, and their liberal taxonomy seems to confuse novices who move from weakly-typed to strongly-typed environments.



  • gotcha, maybe I'm just a programmer after all ;)

    That's okay, though, because I'm brillant



  • @taylonr said:

    gotcha, maybe I'm just a programmer after all ;)

    That's okay, though, because I'm brillant

     

    I would say the proof is your actions, not in your title. 

     

    Oh.. and the quality of your business cards!



  • @MasterPlanSoftware said:

    @taylonr said:

    gotcha, maybe I'm just a programmer after all ;)

    That's okay, though, because I'm brillant

     

    I would say the proof is your actions, not in your title. 

     

    Oh.. and the quality of your business cards!

     

    My department's last round of business cards all had the wrong phone number on them: they went to a non-technical contact in a different department.

    Naturally, we gave them out liberally and encouraged everyone to call us instead of emailing.



  • Would you get extra credit for enterprisyness?

    function GetOccurrancesOf (text, sub_text)

    wrap text in XML

    submit to GetOccurrancesOf web service

    parse returned XML

    return answer

     

    Skizz 

     



  • @Skizz said:

    Would you get extra credit for enterprisyness?

    function GetOccurrancesOf (text, sub_text)

    wrap text in XML

    submit to GetOccurrancesOf web service

    parse returned XML

    return answer

     

    Needs more wooden table.



  • @MasterPlanSoftware said:

    @AbbydonKrafts said:

    The problem is that if it's taken literally, "in built string functions" was the only exclusion.

    Actually, if you read the actual requirements that he was given, you wont find that wording. (Holy crap! Who would think to RTFA huh?)

    Perhaps you would like to take a look at the OP again?

    @MonkeyCode said:

    Not terribly hard, it's just a simple string manipulation exercise: Given a string, find all occurences of a substring without using any in built string functions.

    My reply was to a combination of the OP and the MDSN post. If only the MSDN post is used, then it doesn't make sense at all. What exactly would "external functionality" mean? The example given is, and is even stated as, built-in. "External" sounds like another library or non-String class functionality (such as RegEx).

    You don't always have to be a smartass, you know? I read both and had no problem understanding the words.



  • @tster said:

    I'm not arguing that it is impossible to do, I've already stated that I was simply arguing that to play devils advocate.  I'm arguing, as has been my point the whole time, that the wording of the question is poor.  The problem with the argument "software developers should be able to figure out a way to work around unclear specifications" isn't valid because these specifications are imposing arbitrary rules.  When developing real software for users, such arbitrary rules do not apply, therefore there is no correlation. 

     

    Tster, would you post the question "as it should have been done", please? So we can start nitpicking you :) 



  • @AbbydonKrafts said:

    What exactly would "external functionality" mean? The example given is, and is even stated as, built-in. "External" sounds like another library or non-String class functionality (such as RegEx).
     

    It is outlined in the requirements, as I keep saying. They are saying to not use any of the obvious string class functions like contains or indexof to complete the task. Again, more than enough explanation for anyone they should be considering for the job.

    And no, I am not going by the wording in the OP at all, because the whole point is what requirements he was actually given, and could not complete.

     

    I think the intent here is clear. The interviewee not being able to perform the task at all is a WTF and posting to the MSDN forums for help with it is even more of a WTF.



  • @mister said:

    Tster, would you post the question "as it should have been done", please? So we can start nitpicking you :) 

    Complete the following function:

    List<int> findAllOccurences(char[] text, char[] token)  { }

    You are allowed to use any operators of C#.  You are allowed to use any functions or properties exect:  Any functions or properties in the List class; any functions of properties that you write.

     The function should <insert contract here>.



  • @tster said:


    Complete the following function:

    List<int> findAllOccurences(char[ text, char[ token)  { }

    You are allowed to use any operators of C#.  You are allowed to use any functions or properties exect:  Any functions or properties in the List class; any functions of properties that you write.

     The function should <insert contract here>.

     

    That is much clearer!

    But how do I use a 'char['?

    What does 'exect' mean?

    Why am I not allowed to use 'any functions of properties that [I] write.'? What is the purpose of the exercise if I cannot write anything?

    Can't I just take the (presumably) char[] and make a string out of it (string s = new string(text);) and just use the string library? What would this tell you about the candidate? That they know how to use string.contains or string.LastIndexOf?



  • @MasterPlanSoftware said:

    @tster said:


    Complete the following function:

    List<int> findAllOccurences(char[ text, char[ token)  { }

    You are allowed to use any operators of C#.  You are allowed to use any functions or properties exect:  Any functions or properties in the List class; any functions of properties that you write.

     The function should <insert contract here>.

     

    That is much clearer!

    But how do I use a 'char['?

    What does 'exect' mean?

    Why am I not allowed to use 'any functions of properties that [I] write.'? What is the purpose of the exercise if I cannot write anything?

    Can't I just take the (presumably) char[ and make a string out of it (string s = new string(text);) and just use the string library? What would this tell you about the candidate? That they know how to use string.contains or string.LastIndexOf?

    obviously the forum ate part of my post.

    obviously I mistyped except.  

    obviously you can use functions that you write... that's why I wrote that rule. 

    You're making yourself look like kind of an ass for nitpicking that my post got garbled by the forum software, not once, but twice about the same thing.



  •  @tster said:

    You're making yourself look like kind of an ass for nitpicking that my post got garbled by the forum software, not once, but twice about the same thing.

    OHHHH nitpicking makes you look like an ass huh?

     

    Just what I was thinking. Thanks.



  • @mfah said:

    [snip]

    I don't know much C# at all, but does it really have to be that big?

     

    #include <cstdio>
    

    char lower(char ch)
    {
    if (ch >= 'A' && ch <= 'Z')
    return ch + 32;
    return ch;
    }

    void printMatches(const char *text, const char *subtext)
    {
    const char *s = subtext;
    for (const char *t = text; *t; t++)
    {
    if (lower(*t) == lower(*s))
    s++;
    else
    {
    if (!*s)
    printf("Found a match at %d.\n", t - text - (s - subtext) + 1);
    s = subtext;
    }
    }
    }



  • @MasterPlanSoftware said:

     @tster said:

    You're making yourself look like kind of an ass for nitpicking that my post got garbled by the forum software, not once, but twice about the same thing.

    OHHHH nitpicking makes you look like an ass huh?

     

    Just what I was thinking. Thanks.

     

    There is a substantive difference between me saying that their question is worded to unclearly and you saying that I mispelled a word and that I didn't chant the magic forum song before posting code.  Usually, on the internet, when one party is reduced to correcting spelling and formatting mistakes as their only argument, the other party can consider the discussion over.  As I now consider this discussion unless you have anything substantive to say. 



  • @tster said:

    There is a substantive difference between me saying that their question is worded to unclearly and you saying that I mispelled a word and that I didn't chant the magic forum song before posting code.  Usually, on the internet, when one party is reduced to correcting spelling and formatting mistakes as their only argument, the other party can consider the discussion over.  As I now consider this discussion unless you have anything substantive to say. 
     

    I told you I gave up on the argument itself a long time ago...

    You didn't just misspell things, your post was very unclear. Less clear than the original requirements. Considering you were replying to somone who TOLD you upfront he was only asking so we could nitpick against it, you are just acting like a baby.

    You criticized someone's communication skills, and then failed yourself. Don't cry when someone points it out.



  • @Faxmachinen said:

    @mfah said:

    [snip]

    I don't know much C# at all, but does it really have to be that big?

     

    #include <cstdio>
    

    char lower(char ch)
    {
    if (ch >= 'A' && ch <= 'Z')
    return ch + 32;
    return ch;
    }

    void printMatches(const char *text, const char *subtext)
    {
    const char *s = subtext;
    for (const char *t = text; *t; t++)
    {
    if (lower(*t) == lower(*s))
    s++;
    else
    {
    if (!*s)
    printf("Found a match at %d.\n", t - text - (s - subtext) + 1);
    s = subtext;
    }
    }
    }

     

    Ummmm, that's C++.  You can certainly do it a lot smaller, neater and cleaner in C or C++ (yay pointers!), or even something not a million miles from your version with unsafe code in C#.

    Last comment before I bow out (unless the subject changes very quickly) - "Let's sing another song boys, this one has grown old and bitter" - L. Cohen.

     



  • @mfah said:

    You can certainly do it a lot smaller, neater and cleaner in C or C++ (yay pointers!), or even something not a million miles from your version with unsafe code in C#.
    Isn't the entire point of C# to be able to write less code that does more?



  • @Lingerance said:

    @mfah said:
    You can certainly do it a lot smaller, neater and cleaner in C or C++ (yay pointers!), or even something not a million miles from your version with unsafe code in C#.
    Isn't the entire point of C# to be able to write less code that does more?
     

    You CAN write it very quickly. But tying your hands behind your back (not using the built in string capabilites) before trying it is certainly a hinderance. 

    Please stop trying to stir up flame wars everytime you hear something MS related. You are not nearly knowledgable enough with anything MS related to be a good judge or critic.



  • @MasterPlanSoftware said:

    Please stop trying to stir up flame wars everytime you hear something MS related. You are not nearly knowledgable enough with anything MS related to be a good judge or critic.
    Actually that wasn't my goal, I was just curious to as why the C# solution would be more code, not everything I post that you read as "anti-MS" is a critique, sometimes it is just a question to expand my knowledge. If you treat it as a flame I usually respond as neutrally as I can. Also yes, many of my posts about MS are misinformed about either MS or I forget what was already discussed in the thread (by extension losing the context), such as now when I forgot they were attempting to replicate functionality of a library function without using any other library function. Also sometimes I hide text which I feel is pure-flame-bait in an HTML comment, and tag it appropriately.



  • I just thought of a great over-the-phone screen question that you can ask to weed out those who don't know how to code.

    [quote user="Yahweh"]Could you explain programming please?  I want to make a game like Halo, but I don't know how to start. Could you explain what I need to do?[/quote]

    It's perfect.  The noobs will try to give it a shot, while the experienced coders will recognize the question as ridiculous. 



  • @belgariontheking said:

    It's perfect.  The noobs will try to give it a shot, while the experienced coders will recognize the question as ridiculous. 
     

    And most likely never talk to you again.



  • @tster said:

    Complete the following function:

    List<int> findAllOccurences(char[ text, char[ token)  { }

     Sorry, but you've missed the point of the exercise on a few levels. The idea isn't for the potential hire to develop a character searching algorithm. It's for them to display that 

    a) they can understand a reasonably defined question. ( It's a better defined question that you'll ever get in your carreer as a developer. You're either a pedant or not good enough if you have issues with it - neither of which are desirable attributes)

    b) they have a rudimentary knowledge of how .net works (ie, a string can be represented as a char array)

    c) they can write a simple application, which works. ( the style of which gives a reasonably good indication of their coding ability.)

     

    With your version, you've essentially given them the answer, and also have given them the ability to do the brain dead easy

    string textToSearch = new string(text)

    string subtext = new string(token)

    allowing them to use textToSearch.IndexOf(subtext) - which takes away the point of the exercise.

     

    The real wtf is that this article actually generated more conversation than "oh my god, what an idiot" 




  • @tster said:

    @MasterPlanSoftware said:

    @tster said:


    Complete the following function:

    List<int> findAllOccurences(char[ text, char[ token)  { }

    You are allowed to use any operators of C#.  You are allowed to use any functions or properties exect:  Any functions or properties in the List class; any functions of properties that you write.

     The function should <insert contract here>.

     

    That is much clearer!

    But how do I use a 'char['?

    What does 'exect' mean?

    Why am I not allowed to use 'any functions of properties that [I] write.'? What is the purpose of the exercise if I cannot write anything?

    Can't I just take the (presumably) char[ and make a string out of it (string s = new string(text);) and just use the string library? What would this tell you about the candidate? That they know how to use string.contains or string.LastIndexOf?

    obviously the forum ate part of my post.

    obviously I mistyped except.  

    obviously you can use functions that you write... that's why I wrote that rule. 

    You're making yourself look like kind of an ass for nitpicking that my post got garbled by the forum software, not once, but twice about the same thing.

     Ok, I'm confused.  You say "obviously you can use functions that you write... that's why i wrote that rule"  but the rule you wrote said "You are allowed to use any functions or properties exect:  Any functions or properties in the List class; any functions of properties that you write"  Which when broken down, means I could do anything OTHER than list operations and custom functions.

    Not only is your question completely solvable (as mentioned earlier, String X = new string(text); X.LastIndexOf(token )  But it actually accomplishes the exact opposite of what was intended.  Because now the user is simply showing they know how to do a .LastIndexOf rather than understand that strings are character arrays.

     /Devils Advocate FTW ;)



  • shit.  I left out a "not"  I meant, you are NOT allowed to use any functions/properties except: ... 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.