-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: A Dated Inheritance

Вторник, 07 Июня 2016 г. 13:30 + в цитатник

Teppo works for a Finnish company that, among other things, develops a few mobile applications. This company is growing, and as growing companies do, it recently purchased another company.

One of the applications that came with this company had a mongrel past. It started as an in-house project, was shipped off to a vague bunch of contractors in Serbia with no known address, then back to an intern, before being left to grow wild with anyone who had a few minutes trying to fix it.

The resulting code logs in a mixture of Serbian and Finnish. Paths and IP addresses are hard-coded in, and mostly point to third party services that have long since stopped working. It has an internal ad-framework that doesnt work. The Git repository has dozens of branches, with no indication which one actually builds the production versions of the application. The back-end server runs a cron script containing lines like this:

* * * * * curl www.google.com  > ~/out.txt
* * * * * echo 'lalala' > ~/out1.txt

Its a terrible application that doesnt even barely work. The real test, of course, for an unsupportable mess of an application is this: how does it handle dates?

public static String getSratdate_time_date(String date) {
        String dtStart = date;
        try {
                SimpleDateFormat format = new SimpleDateFormat(
                        "yyyy-MM-dd HH:mm:ss");
                Date deals_date = format.parse(dtStart);

                String intMonth = (String) android.text.format.DateFormat.format(
                        "M", deals_date); // Jan
                String year = (String) android.text.format.DateFormat.format(
                        "yy", deals_date); // 2013
                String day = (String) android.text.format.DateFormat.format(
                        "dd", deals_date); // 20

                return (intMonth + " / " + day);

        } catch (Exception e) {
                e.printStackTrace();
        }
        return "";
}

This takes a string containing a date and converts it into a string containing M/dd. You may note, I used a date format string to describe what this code does, since the easiest way to write this might have been to do something like… DateFormat.format("M/dd", deals_date), which doesnt seem to be that much of a leap, since they used the DateFormat object.

Bonus points for using Hungarian notation, and triple that bonus for using it wrong.

[Advertisement] Infrastructure as Code built from the start with first-class Windows functionality and an intuitive, visual user interface. Download Otter today!

http://thedailywtf.com/articles/a-dated-inheritance

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку