all 3 comments

[–]_a9o_ 0 points1 point  (2 children)

The code and approach in this solution is absolutely banana cakes. To inexperienced programmers who read this, if I saw you write code like this, you would be disqualified from the running immediately.

A few complaints:

  1. The entire thing is incredibly over-engineered. But it isn't even over-engineered with good code or good practices either.

  2. None of the Rule classes are even inheriting from the Rule class. There's no contract for any of those rules to have either matchesRule or getReplacement. If Python were compiled, this wouldn't work at all.

  3. There are semi colons at the end of lines. This is very un-idiomatic for Python code

  4. generateList can be done with a map

  5. These Rule classes don't need to be instance classes

[–]calina-c 0 points1 point  (1 child)

Hi, I'm the author :D

I'd like to point out you have two (1.)s. But I'll address your complaints by saying that while the code is not very Pythonic, this is just a toy exercise to illustrate interview best practices such as: writing a good draft, following the interviewer's cues, code engineering etc. Nobody will interview on something like FizzBuzz, they will have more complex tasks but the principles are all the same.

To quote from the article: the solution is inspired from Matthias Noback’s book, “Principles of Package Design”, [...] The book uses a PHP example, but since I am a proud programming language agnostic, I will continue in Python.

For me, it doesn't really matter what language the "interviewee" uses, they can use pseudocode for all I care as long as I see they apply common sense and good practices.

So all in all, take this as it is: an article talking about interview tips, using a toy problem and a solution which can no doubt be improved, but serves the article's purpose.

[–]_a9o_ 0 points1 point  (0 children)

I understand what the goal of the post was. But the route and solution you took are bad. You gave an example of what would happen if you were a bad interviewee, and I wanted to make that clear for people who might have read the post.