The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Вариант для распечатки  
Пред. тема | След. тема 
Форум Разговоры, обсуждение новостей
Режим отображения отдельной подветви беседы [ Отслеживать ]

Оглавление

Python опередил PHP в рейтинге TIOBE, opennews (??), 13-Фев-11, (0) [смотреть все]

Сообщения [Сортировка по времени | RSS]


120. "Python опередил PHP в рейтинге TIOBE"  +/
Сообщение от Аноним (-), 15-Фев-11, 22:15 
Задача переопределить формат вывода при условии, что в программе многократно используется некая стандартная форма получения ( например текущего времени Time.new )

Ruby:
class Time
    def to_s
        return strftime "%d-%m-%Y"
    end
end
#....
puts Time.new
#....
puts Time.new
#....
puts Time.new

-----
С переопределенным методом стандартного класса будет 15-02-2011
Без переопределения Tue Feb 15 22:09:41 +0300 2011

Кто сможет подобное сделать на питоне без правки остального кода?

Ответить | Правка | К родителю #116 | Наверх | Cообщить модератору

122. "Python опередил PHP в рейтинге TIOBE"  +/
Сообщение от Аноним (-), 15-Фев-11, 22:41 
Вот, что об этом пишут квалифицированные руби-программисты:

"Monkey patching is the new black [in the Ruby community]. It's what all the hip kids are doing. To the point that smart, experienced hackers reach for a monkey patch as their tool of first resort, even when a simpler, more traditional solution is possible.

I don't believe this situation to be sustainable. Where I work, we are already seeing subtle, difficult-to-debug problems crop up as the result of monkey patching in plugins. Patches interact in unpredictable, combinatoric ways. And by their nature, bugs caused by monkey patches are more difficult to track down than those introduced by more traditional classes and methods. As just one example: on one project, it was a known caveat that we could not rely on class inheritable attributes as provided by ActiveSupport. No one knew why. Every Model we wrote had to use awkward workarounds. Eventually we tracked it down in a plugin that generated admin consoles. It was overwriting Class.inherited(). It took us months to find this out.

This is just going to get worse if we don't do something about it. And the "something" is going to have to be a cultural shift, not a technical fix. I believe it is time for experienced Ruby programmers to wean ourselves off of monkey patching, and start demonstrating more robust techniques."

ИМХО манкипатчинг надо запретить также, как в своё время все адекватные конторы запретили использование GOTO (из языков директива ушла позже).

Ответить | Правка | Наверх | Cообщить модератору

Архив | Удалить

Рекомендовать для помещения в FAQ | Индекс форумов | Темы | Пред. тема | След. тема




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру