hell I have been wanting to write this series of articles for a long time. Over the years I have come across very bad code examples and I have always wanted to share them with you guys, kind of in the way of "Watch and DON’T learn" :).

 

Everything you are about to see in this series is based on my personal experience and completely real, so before we begin I have only one request:

 

Don’t try this at home! :)


Continue Reading...

tape-measureSoftware Managers all around the globe, need to have some metric to estimate their workers. Sometimes the management event wants to create a precise and measurable way to know the programming progress and the developers productivity and performance. One of those methods is called SLOC – Source Lines Of Code. This metric is used measure the size of the software by counting the lines of the program source code. Some managers tend to love SLOC because it can be automated so it requires very little effort and the effect of it can be visualized. That is exactly what managers like! it is easy and it can be easily inserted into their reports, what could be better than that? It seems just perfect.


Continue Reading...

This is the fifteen post of the series of programming job interview challenge, 37 readers provided an answer to job interview challenge #14. As you can understand from the title, I have a little announcement to make, but lets first head on to last weeks question answers.

This time, Omar was the first one to provide an efficient and correct detailed answer:

Draw a line from the single point (any direction will do).
Count the number of times that this line intersects with lines of the polygon.
An even count (including zero) indicates that the point is outside of the polygon.
An odd count indicates that the point is inside the polygon.

Here is a nice image taken from Jon von Gillern blog post


Continue Reading...

The fourteenth post of the series of programming job interview challenge is out, 79 comments with answers were provided to job interview challenge #13. We didn’t publish a question last week due to a sever lack of time, so another week is gone and here we are again.

Mark R was the first to provide a correct and detailed answer (which I can quote here):

As you examine each character, classify it as either an opening or closing bracket. If it’s an opening bracket, push it onto a stack. If it’s a closing bracket, pop the top character off of the stack; if the stack was empty, or the character was not the matching open bracket, then return an error. At the end of input, if the stack is empty, you have a legal expression.

C++ has a built-in stack class, so this becomes a trivial problem. I’m not sure about other languages. You could always simulate a stack by appending and deleting characters from the end of a string.

So, in one word, the most efficient answer is use a stack. Here is a nice image which was crafted by David Tchepak in his blog post Brackets, braces, parentheses, and other such creatures:


Continue Reading...

job-interview

During the Job Interview Challenge Series we are running here at Dev102.com, we usually get some comments from readers who think that the quality of a specific question is not good. Here are some of those comments:

  1. I hate interview questions like this, as it’s just a race to see who gets the a-ha moment first“.
  2. “This is not a good interview question. What does it tell you about someone’s engineering ability? Little. It’s a brain-teaser; either you get it or you don’t”.
  3. Really enjoying the problems so far but I’m a little disappointed with this one. I prefer ‘thinking’ problems to ‘research’ ones“.
  4. Isn’t this an awfully language-specific question?“.
  5. If you presented this problem in an interview and made me an offer, I’d turn you down“.

On the other hand, many readers provided answers to the questions and enjoyed participating in those challenges. Some thought that the questions are very good:


Continue Reading...

The sixth of the series of programming job interview challenge is out. Other then commenting the solution, I remind you that you can post the solution on your blog and get a link next week!

Here is the solution to the previous challenge:
Two-way merge sort (External Sorting) : The idea is breaking the big file into subfiles, sorting them and than merging them back together. In the first pass read one page at a time, the records in the page are sorted (quicksort for example) and the page is written back to disk. in subsequent passes, each pair of sorted output from the previous pass are read and merged to produce sorted subfile twice as long:

1. Read each page, Sort it, Write it back
2. while more than one sorted subfile:
while subfiles from previous pass left to merge:
– Choose next two subfiles from previous pass
– Read each subfile into a memory page (one page at a time)
– Merge the subfiles (remember each of them is already sorted), write output to a memory page
– Write output page to disk when needed.


Continue Reading...

This is the fifth challenge in the series of programming job interview challenge. As usual, we’ll provide an answer to the previous challenge and give you a new challenge to keep you busy this week. Other then commenting the solution, I remind you that you can post the solution on your blog and let us know about it […]


Continue Reading...

This is the fourth post in the series of programming job interview challenge. Today, I will provide the answer to job interview challenge #3, talk about readers answers (all of the comments are now approved) and give you a new challenge. So, lets get into business:

The correct answer to challenge #3:

  1. Start with the lower left cell (first column, last row).
  2. If the value matches, you’re done.
  3. If the searched value is bigger than the current cell, go right. That way an entire column is eliminated (all of the values left in that column are lower than the searched value). If you can’t go right – the searched value is not in the matrix.
  4. If the searched value is smaller than the current cell, go up. That way an entire row is eliminated (all of the values left in that row are bigger than the searched value). If you can’t go up – the searched value is not in the matrix.
  5. Go back to 2.


Continue Reading...

This post is third in the series of programming job interview challenge, if you are not yet familiar with these series please take your time and read:

  1. A Programming Job Interview Challenge
  2. A Programming Job Interview Challenge #2

Well, last weeks challenge was very successful, all of the comments which contain answers to the question are now approved and can be viewed in challenge #2 post.


Continue Reading...

Job Interview ChallengeLast week I posted A Programming Job Interview Challenge which was very successful, both in the amount of page views and, in the amount of comments and mails we received. This fact made us (the Dev102 team) decide to add a weekly programming job interview challenge column to www.Dev102.com.


Continue Reading...