View Single Post

Re: Job Interview In Two Days -- Tips?
Old 07-29-2010, 01:45 AM   #27
gekko
Knight
 
gekko's Avatar
 
gekko is offline
Now Playing:
Posts: 3,890
Default Re: Job Interview In Two Days -- Tips?

Just for the record, this is attempt #2 again. Why do I keep getting logged out?

Quote:
Originally Posted by manasecret View Post
But I'm curious, do you mean writing down the algorithm, or doing it in your head?
Mainly write down enough so you can walk through a couple test cases and make sure the algorithm works before you test it. If I'm reversing a string, I want to make sure as I'm going through a couple test cases that I go in the same order and don't skip any steps. If you're speaking out load, it should be easy to follow. Just avoid worrying about syntax issues and make sure you have the correct algorithm.

Quote:
You said make sure to do tests, how would you do tests? Maybe, pick a certain temperature and make sure the algorithm works? Or for your example, choose a sample string and iterate through the algorithm?
Generally, validate your inputs and test for edge cases (0, negative numbers, null pointers, etc.). In the case of reversing a string (from outside in), I would test 2 and 3 letter strings to handle the case of having the middle letter and not. Obviously ensure you didn't swap the null-terminator, and then move on to ensuring the user can't do anything stupid. Do you handle passing in a null pointer? What about an empty string ("")?

In the case of the heater, yes, pick values which should cause some expected result and ensure it happened. They might be asking a "What types of tests would you do" question which is just stating them, or they could ask you to write them (doubt it, seems like a waste of precious time). The other possibility is they want to see if you can design code in a way where it's easy to test.

If you're not familiar with writing test cases, find some articles on TDD and unit testing, and they should give you a good idea.
  Reply With Quote