Mistři v programování na #hovnokod

Miluji funkce s nazvem hack... A co tenhle pattern: a = b; if(x) -> a=b; else if(y) -> a=b; c = d;

    private void hackDataAutoExtraFup(Service service, Product product) {
        service.setServiceStatus(IntegrationUtils.operationMapClient.get(OrderItemOperationType.ADD));
        if (product.getOrderItemOperation() == OrderItemOperationType.UPDATE) {
            service.setServiceStatus(IntegrationUtils.operationMapClient.get(OrderItemOperationType.ADD));
        } else if (product.getOrderItemOperation() == OrderItemOperationType.SUSPEND ||
                product.getOrderItemOperation() == OrderItemOperationType.REMOVE ||
                product.getOrderItemOperation() == OrderItemOperationType.REMOVE_ON_END_OF_PERIOD) {
            service.setServiceStatus(IntegrationUtils.operationMapClient.get(OrderItemOperationType.ADD));
            setParameterValue(service, ProductIvmAutoExtraFup.MAX_RENEWAL_COUNT, "0");
        }
    }

Anonymous,

Krasna pyramida

if ($predvypln_pocet_kin == 1) {
            $nahrad["{test}"] = $table_test1;
        } elseif ($predvypln_pocet_kin == 2) {
            $nahrad["{test}"] = $table_test1 . $table_test2;
        } elseif ($predvypln_pocet_kin == 3) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3;
        } elseif ($predvypln_pocet_kin == 4) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4;
        } elseif ($predvypln_pocet_kin == 5) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5;
        } elseif ($predvypln_pocet_kin == 6) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6;
        } elseif ($predvypln_pocet_kin == 7) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7;
        } elseif ($predvypln_pocet_kin == 8) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8;
        } elseif ($predvypln_pocet_kin == 9) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9;
        } elseif ($predvypln_pocet_kin == 10) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10;
        } elseif ($predvypln_pocet_kin == 11) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11;
        } elseif ($predvypln_pocet_kin == 12) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12;
        } elseif ($predvypln_pocet_kin == 13) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12 . $table_test13;
        } elseif ($predvypln_pocet_kin == 14) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12 . $table_test13 . $table_test14;
        } elseif ($predvypln_pocet_kin == 15) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12 . $table_test13 . $table_test14 . $table_test15;
        } elseif ($predvypln_pocet_kin == 16) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12 . $table_test13 . $table_test14 . $table_test15 . $table_test16;
        } elseif ($predvypln_pocet_kin == 17) {
            $nahrad["{test}"] = $table_test1 . $table_test2 . $table_test3 . $table_test4 . $table_test5 . $table_test6 . $table_test7 . $table_test8 . $table_test9 . $table_test10 . $table_test11 . $table_test12 . $table_test13 . $table_test14 . $table_test15 . $table_test16 . $table_test17;
        } else {
        }

Anonymous,


Anonymous,

if (bla.equals("")) {
            try {
                throw new ToolConfigException("Please contact the developers.");
            } catch (ToolConfigException e) {
                e.printStackTrace();
            } finally {
                System.exit(1);
            }
        }

Anonymous,

Jak snadno spočítat polovinu něčeho.

    /// <summary>
    /// Class for extensions.
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// Count the half value.
        /// </summary>
        /// <param name="valueToBeHalved">Value to be halved.</param>
        /// <returns>Returns half value</returns>
        public static double Halved(this double valueToBeHalved)
        {
            double halfCoefficient = 0.5;
            return valueToBeHalved * halfCoefficient;
        }
    }

Anonymous,