﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>James Culbertson commented on Negative hiring decisions, Part I</title><description>For those criticizing Ayende for posting this get real. If he was hard on the candidate he is doing him/her a favor by letting them know that they are either in the wrong field or need to rededicate a little bit to their craft and do better. Either way it would be no favor to the candidate to not tell them the truth. Political correctness and dancing around the issue will not be good for anyone involved and doesn't advance the field of software development.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment73</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment73</guid><pubDate>Sun, 02 Oct 2011 13:19:14 GMT</pubDate></item><item><title>CLee commented on Negative hiring decisions, Part I</title><description>Ask yourself this, is your blog post going to encourage people (even those that have the skills) to want to work for/with you?  Your right, she doesn't have the developer skills to get the job, but then again, she and others probably wouldn't want the job now after considering your social skills.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment72</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment72</guid><pubDate>Thu, 29 Sep 2011 19:34:48 GMT</pubDate></item><item><title>Ayende Rahien commented on Negative hiring decisions, Part I</title><description>Jernejg,
If he manages to do that ,good for him. I would add a twist to the problem, something new. 
For the tax problem, it would be persisting the tax rates, for an algorithm, it would be asking about the edge conditions and handling them, etc.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment71</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment71</guid><pubDate>Wed, 28 Sep 2011 07:48:52 GMT</pubDate></item><item><title>jernejg commented on Negative hiring decisions, Part I</title><description>@ayende
How do you feel about googling the problem and copy/pasting the solution. I mean if you give a candidate a standard problem to solve on an interview, like this tax thingy or a basic algorithm problem described from Knuuth's book are you really just testing his coding skills or are you also testing his skills of finding information on the web and optionaly modifying it. 

Or to put it in other words. Would you hire a programmer that would finish the test in 5 minutes and say "Here is the solution. The task that you gave me was a standard xx problem, so I googled the code and copy/paste it".?</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment70</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment70</guid><pubDate>Wed, 28 Sep 2011 07:05:03 GMT</pubDate></item><item><title>Lee commented on Negative hiring decisions, Part I</title><description>@Toni-anne Collins
Permission to post the code? Good question, maybe Ayende should require candidates to sign some kind of agreement saying that the code submitted may or may not be published, that will definitely weed out candidates, but there might not be any candidates then? :)

Anyway, no personally identifiable information, no defamation, no harm, if she does read the blog, there have been plenty of good solutions to learn from. As for, '...destroyed her confidence and affected her future in this industry.', a bit dramatic, we're not in high school.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment69</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment69</guid><pubDate>Tue, 27 Sep 2011 14:51:49 GMT</pubDate></item><item><title>iwayneo commented on Negative hiring decisions, Part I</title><description>even the method name has a spelling mistake.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment67</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment67</guid><pubDate>Tue, 27 Sep 2011 10:34:04 GMT</pubDate></item><item><title>majid rafie commented on Negative hiring decisions, Part I</title><description>sorry for my bad English...
this code is full of syntax errors...:D
incorrect use of switch-case syntax , declare method by int return type and then return a double value,net and tax is not Initialized, ...

GetTax method can simply wrote:

public decimal GetTax(decimal sal)
        {
            var taxFactor = new[] { 
                                 new { fac = 0.45m, Lim = 40230m },
                                 new { fac = 0.33m, Lim = 21240m },
                                 new { fac = 0.3m, Lim = 14070m },
                                 new { fac = 0.23m, Lim = 8680m },
                                 new { fac = 0.14m, Lim = 5070m },
                                 new { fac = 0.1m, Lim = 0m }
								 
							};

            decimal tax = 0;
            foreach (var item in taxFactor)
            {
                if (sal &gt; item.Lim)
                {
                    tax += (sal - item.Lim) * item.fac;
                    sal = item.Lim;
                }
            }

            return tax;
        }</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment66</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment66</guid><pubDate>Sun, 25 Sep 2011 07:24:51 GMT</pubDate></item><item><title>Ashaq Ali commented on Negative hiring decisions, Part I</title><description>I Believe it should work and calculate the tax, i know code is ugly, but u cant write better ode u r bored and checking the random blogs, was searching for signalR Example and got  hooked to this one, strange but true.


static void Main(string[] args)
        {
            float[,] slabs = new float[5, 2] { { 5070, 0.10f }, { 3590, 0.14f }, { 5410, 0.23f }, { 7170, 0.30f }, { 18990, 0.33f } };

            float income = 50000f;
            float totalTax = 0;
            for (int i = 0; i &lt; slabs.GetLength(0); i++)
            {
                float currValue = slabs[i, 0];
                float currTaxSlab = slabs[i, 1];

                if (income &gt;= currValue &amp;&amp; (i != (slabs.Length - 1)))
                {
                    income = income - currValue;
                    totalTax += currValue * currTaxSlab;

                }
                else if (income &lt; currValue &amp;&amp; (i != (slabs.Length - 1)))
                {
                    totalTax += income * currTaxSlab;
                    income = 0;
                }

            }

            if (income &gt; 0)
            {
                totalTax += income * 0.45f;
            }
            Console.Write("Total Tax: {0}", totalTax.ToString());
            Console.ReadKey();
        }</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment65</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment65</guid><pubDate>Sat, 24 Sep 2011 21:04:43 GMT</pubDate></item><item><title>Brian O commented on Negative hiring decisions, Part I</title><description>Here is what would sell very easily to a business analyst at an American bank :

        private decimal calcTax(decimal salary)
        {
            decimal tax = 0;
            int salaryInt = Convert.ToInt32(salary);

             // Tax each dollar one at a time in each tax bracket.
            for (int i = 1; i &lt;= salaryInt; i++)
            {
                if (i &gt; 40230)
                    tax += 0.45m;
                else if (i &gt; 21240)
                    tax += 0.33m;
                else if (i &gt; 14070)
                    tax += 0.3m;
                else if (i &gt; 8660)
                    tax += 0.23m;
                else if (i &gt; 5070)
                    tax += 0.14m;
                else
                    tax += 0.10m;
            }

            return tax;
        }


It taxes each dollar one at a time. I did a performance test using 80,000 dollars, and Visual Studio 2010 cannot detect a difference between this and the "Slices" version even down to the Tick count of the CPU.

I guess we can call this one "The Buffet Function". It taxes 800,000 bucks at $352,568.10.

</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment64</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment64</guid><pubDate>Sat, 24 Sep 2011 18:25:26 GMT</pubDate></item><item><title>gunteman commented on Negative hiring decisions, Part I</title><description>Dammit, the Dark Side of the Force got hold of Yedi Ayende again.

I hate these posts. Grow up.

</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment63</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment63</guid><pubDate>Fri, 23 Sep 2011 21:28:52 GMT</pubDate></item><item><title>Caleb commented on Negative hiring decisions, Part I</title><description>Ayende,

Did you contact the person who submitted this and let them know what the problem was before posting it here?  I would hate for them to see it on your blog without even hearing back from you.

Caleb</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment62</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment62</guid><pubDate>Fri, 23 Sep 2011 10:08:36 GMT</pubDate></item><item><title>Toni-anne Collins commented on Negative hiring decisions, Part I</title><description>As an HR Manager of a Software Development company who also uses code tests as part of our recruitment process I was interested to know if you discussed with the candidate why they  failed or asked for their permission to post the submission to your blog.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment61</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment61</guid><pubDate>Fri, 23 Sep 2011 10:07:34 GMT</pubDate></item><item><title>Lee commented on Negative hiring decisions, Part I</title><description>I feel extremely sorry for this person if she's read this post. You may have destroyed her confidence and affected her future in this industry.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment60</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment60</guid><pubDate>Fri, 23 Sep 2011 09:51:40 GMT</pubDate></item><item><title>Rob Kent commented on Negative hiring decisions, Part I</title><description>The post may or may not be harsh, but I disagree that it is not constructive: it produced some nice functional tax algorithms.

 </description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment59</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment59</guid><pubDate>Fri, 23 Sep 2011 08:05:59 GMT</pubDate></item><item><title>Ducas commented on Negative hiring decisions, Part I</title><description>I habe to agree with Bob, Luke and the others.

This post is quite harsh and in no way constructive.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment58</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment58</guid><pubDate>Fri, 23 Sep 2011 06:25:28 GMT</pubDate></item><item><title>Ayende Rahien commented on Negative hiring decisions, Part I</title><description>Bob,
I was quite careful to give no identifying details.
And I would rather have the candidate tell me that they weren't able to complete the task than send me code that didn't even compile.
</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment57</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment57</guid><pubDate>Fri, 23 Sep 2011 04:39:50 GMT</pubDate></item><item><title>Luke commented on Negative hiring decisions, Part I</title><description>Your demonstration of professional developer behaviour through a public review of a person rather than a constructive critique of the code has been most... enlightening... and I wish you well on your continuing journey down the road of dealing with software *and* humans.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment56</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment56</guid><pubDate>Fri, 23 Sep 2011 04:25:43 GMT</pubDate></item><item><title>Phil Bolduc commented on Negative hiring decisions, Part I</title><description>For all those who hard coded the tax table inside the method, remember, this is Ayende!  Sure it compiles, but do you think he'll hire you for doing that? Either an instance field/property or better yet something that returns the tax rate based on variable parameters, such as year, state/province, country.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment55</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment55</guid><pubDate>Fri, 23 Sep 2011 02:26:45 GMT</pubDate></item><item><title>Steve commented on Negative hiring decisions, Part I</title><description>Hi Ayende,

I personally think that anyone who posts blog entries like this should at least get their spelling and grammar correct before trashing the work of others.

Cheers,
Steve</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment54</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment54</guid><pubDate>Fri, 23 Sep 2011 01:16:09 GMT</pubDate></item><item><title>Drew Wells commented on Negative hiring decisions, Part I</title><description>What Bob said.  It's not even close to the worst code I've ever seen.  At least 'she' knows how to fall through on case statements.  

Besides who wants to write .NET code anyways? :P</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment53</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment53</guid><pubDate>Fri, 23 Sep 2011 00:31:22 GMT</pubDate></item><item><title>Leszczuu commented on Negative hiring decisions, Part I</title><description>The problem here is her version is quite readable apart from being non-working, and other versions show that problem is not so simple.
And common it's not public shaming, because none of us will ever know who's code was it. If she reads this she will know what was wrong with her code and how to fix it. It won't make her better coder instantly but she will have far greater chances when applying for a job like this next time.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment52</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment52</guid><pubDate>Thu, 22 Sep 2011 23:32:06 GMT</pubDate></item><item><title>Bob commented on Negative hiring decisions, Part I</title><description>Publicly shaming someone like this is a bit of a prick move, sure the candidate might not be ready for the position and could have a long way to go, but if I were this candidate I would rather have someone tell me I might be doing the wrong thing and not in a public forum be made out to be an idiot.

</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment51</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment51</guid><pubDate>Thu, 22 Sep 2011 22:14:32 GMT</pubDate></item><item><title>Mark Brents commented on Negative hiring decisions, Part I</title><description>Wouldn't it be better to just have the tax rates in a table somewhere? </description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment50</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment50</guid><pubDate>Thu, 22 Sep 2011 21:55:41 GMT</pubDate></item><item><title>Noel Kennedy commented on Negative hiring decisions, Part I</title><description>Here's my earlier effort using a fold (it's called aggregate in LINQ for some reason)

public static decimal GetTaxes(decimal salary)
{
    var taxBands = new[]
        {
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(0, 5070, 0.1m),
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(5070, 8660, 0.14m),
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(8660, 14070, 0.23m),
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(14070, 21240, 0.3m),
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(21240, 40230, 0.33m),
            new Tuple&lt;Decimal, Decimal, Decimal&gt;(40230, Decimal.MaxValue, 0.45m)
        };

    return taxBands.Aggregate(0.0m, (taxOwed, taxband) =&gt;
        {
            if (salary &lt; taxband.Item1)
                return taxOwed;

            if (salary &lt; taxband.Item2)
                return taxOwed + ((salary - taxband.Item1) * taxband.Item3);

            return taxOwed + ((taxband.Item2 - taxband.Item1) * taxband.Item3);
        });
}</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment49</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment49</guid><pubDate>Thu, 22 Sep 2011 21:44:21 GMT</pubDate></item><item><title>JustinK commented on Negative hiring decisions, Part I</title><description>PhilB - Nice solution. I'd never heard of .Zip on IEnumerable before, opened my eyes.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment48</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment48</guid><pubDate>Thu, 22 Sep 2011 21:33:52 GMT</pubDate></item><item><title>Demis Bellot commented on Negative hiring decisions, Part I</title><description>Like a simpleton my previous example only calculated basic tax rate. F# is still a good choice for this, here is an example that calculates cumulative tax rate. It uses currying to compose higher order functions with different tax rates:

Gist here: https://gist.github.com/1236106

&lt;pre&gt;
//generic routine to calculate tax
let taxOf salary taxRates = 
	taxRates 
		|&amp;gt; Seq.mapi(fun i (rate, band) -&amp;gt; 
			let prevBand = (if i &amp;gt; 0 then taxRates |&amp;gt; Seq.nth (i-1) |&amp;gt; snd else 0m)
			match salary with 
				| x when x &amp;gt; band -&amp;gt; (band - prevBand) * rate
				| x when x &amp;lt; prevBand -&amp;gt; 0m
				| x -&amp;gt; (x - prevBand) * rate
			)
		|&amp;gt; Seq.sum

//define custom tax bands and rates
let usTaxRates = [
	( 0.1m, 5070m); 
	(0.14m, 8660m); 
	(0.23m, 14070m); 
	( 0.3m, 21240m); 
	(0.33m, 40230m); 
	(0.45m, System.Decimal.MaxValue)]


//use currying to build a higher order function to calculate US Tax Rates
let taxOfUS salary = usTaxRates |&amp;gt; taxOf salary
				
taxOfUS 10000m  //= 1317.80
&lt;/pre&gt;</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment47</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment47</guid><pubDate>Thu, 22 Sep 2011 21:32:51 GMT</pubDate></item><item><title>PhilB commented on Negative hiring decisions, Part I</title><description>Here's an implementation using the LINQ extension methods.  It's a bit hard to read if you ask me.

        public Decimal CalculateTax(Int32 salary)
        {
            var taxData = new[]
            {
                new { Rate = 0m,   Cap = 0 },
                new { Rate = 0.1m, Cap = 5070 },
                new { Rate = 0.14m, Cap = 8660 },
                new { Rate = 0.23m, Cap = 14070 },
                new { Rate = 0.3m, Cap = 21240 },
                new { Rate = 0.33m, Cap = 40230 },
                new { Rate = 0.45m, Cap = Int32.MaxValue },
            };

            return taxData
                .Zip(taxData.Skip(1), (prev, current) =&gt; new { Rate = current.Rate, PreviousCap = prev.Cap, BracketSize = current.Cap - prev.Cap })
                .Select(x =&gt; Math.Min(Math.Max(salary - x.PreviousCap, 0m), x.BracketSize) * x.Rate)
                .Sum();
                         
        }</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment46</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment46</guid><pubDate>Thu, 22 Sep 2011 21:15:25 GMT</pubDate></item><item><title>Josh T commented on Negative hiring decisions, Part I</title><description>Hmm...
From a readability standpoint, am I the only one who doesn't like Frank's solution at all?

If I was a developer who nothing about progressive taxing and had to come along and make a change to this code, I think that this implementation would confuse me even more.

The most glaring problem to me was that the solution had 2 independent arrays with the values declared.  This would immediately lead me down a path of thinking that those arrays could change independently.  Not until I went through multiple iterations of the examples in my head did it *click* that the code assumed you knew how the feature worked and that there is a need to keep the 2 arrays "in sync" by index, otherwise none of the logic works.  

To me, those are some of the most frustrating kinds of issues to deal with, where you have to spend time realizing a developer assumption/mistake before you can see what the code is trying to accomplish.</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment45</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment45</guid><pubDate>Thu, 22 Sep 2011 20:11:47 GMT</pubDate></item><item><title>Stan commented on Negative hiring decisions, Part I</title><description>at least she have a pet project. otherwise you was not call her for interview...</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment44</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment44</guid><pubDate>Thu, 22 Sep 2011 19:51:11 GMT</pubDate></item><item><title>sympathy commented on Negative hiring decisions, Part I</title><description>Am I the only one here who feels bad for her?
She probably reads this blog, and her code is being mocked.

I generally respect Ayende, and even enjoy his curmudgeonly informative attitude, but does this post really serve any purpose outside of venting some frustration?

There's not a doubt in my mind that she knew the code was poor, but for some reason or other felt pressured to submit it.

I personally would consider it a breach of trust if someone I was interviewing for posted my code as an example of what not to do.

</description><link>http://ayende.com/102401/negative-hiring-decisions-part-i#comment43</link><guid>http://ayende.com/102401/negative-hiring-decisions-part-i#comment43</guid><pubDate>Thu, 22 Sep 2011 18:29:37 GMT</pubDate></item></channel></rss>