-
Notifications
You must be signed in to change notification settings - Fork 76
Conversation
honest-hrundel
commented
Oct 26, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 26, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 26, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 26, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 27, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 28, 2016
🍅 Пройдено тестов 7 из 16
honest-hrundel
commented
Oct 31, 2016
🍅 Пройдено тестов 6 из 16
по временной зоне банка
honest-hrundel
commented
Oct 31, 2016
🍅 Пройдено тестов 6 из 16
honest-hrundel
commented
Oct 31, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Oct 31, 2016
🍅 Не пройден линтинг или базовые тесты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Наверное, здесь функция должна называться getFreeTimes? Или можешь придумать еще понятнее?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Очень большая вложенность.
- Идет привязка с именам бандитов, что не есть хорошо. Вдруг они изменят состав?
- Переменные
beginиendинициализированы далеко от места использования, и неясно, начало и конец чего они обозначают. i,j,kтоже никак себя не объясняют.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привязка к конкретной дате
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь больше подойдет глагол get. Ты же его возвращаешь?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это название функции тоже не годится)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Однобуквенных переменных вообще быть не должно, только если в крайних случаях это не цикл по индексам.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно записать в 1 строку тернарными операторами)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть метод toString на крайний случай
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ай-ай-ай, константы!
chipolinka
commented
Nov 4, 2016
Исправлены не все замечания с прошлого раза. Советую тебе перечитать гайд по оформлению кода.
chipolinka
commented
Nov 4, 2016
🍅
honest-hrundel
commented
Nov 5, 2016
🍅 Не пройден линтинг или базовые тесты
honest-hrundel
commented
Nov 5, 2016
🍅 Пройдено тестов 10 из 16
honest-hrundel
commented
Nov 5, 2016
🍏 Пройдено тестов 16 из 16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это уже не просто hours
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно же так: hours += bankTimeZone - timeZone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут не нужна пустая строка
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему нельзя воспользоваться функцией Math.max?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у меня не работает Math.max для дат
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А если один из этих способов?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
О, давай через reduce. Типа пройти по всем датам и найти такую, которая больше других. Очевидно, что sort имеет сложность больше линейной - O(log(n) * n), а reduce будет O(n)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Функция должна занимать не больше 25 строк
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, что можно сначала просчитать все leadToDataType(schedule[key][i].to, bankTimeZone) для каждого i, а потом заполнить ими словарь.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И попробуй использовать reduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привязка к именам бандитов. И слишком большая вложенность. Такого быть не должно. Нельзя ли просто по ключам пробежаться?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
так делать совсем нельзя - а если будет сколько угодно бандитов или имена могу быть другими?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не проще ли сделать так: var day = WEEK[date.getDate()]?
Почему словарь называется WEEK? Почему метод getDate возвращает день?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что значит это название?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ты уверена, что без этих волшебных дат тут не обойтись?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше названия не сокращать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ты много где пушишь объект с этими полями. Можно вынести в отдельную функцию
chipolinka
commented
Nov 7, 2016
🚀
@Vittly
Vittly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в целом неплохо, но:
- есть косяки в названиях
- где-то слишком многословно
- совсем не используешь reduce
надо поправить, сорри за задержку - мой косяк не увидел отбивку. В следующий раз пиши в slack если буду тормозить
🍅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
судя по смыслу, аргумент лучше назвать freeIntervals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а почему такое название функции? formatE ? Судя по коду, мы тут интервалы пересекаем с [ПН, СР] и интервалы разбиваем по дням. Это скорее некая нормализация - normalizeIntervals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а что за даты такие? Чтобы стало понятнее, нужно сделать переменные с говорящими именами
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мы тут пытаемся разложить interval на отрезки по дням? и в итоге будут теже интервалы разложенные по дням - так? forEach, который собирает некий результат - лучше писать через reduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
хм, возможно, лучше назвать fromDay и toDay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
типа не дальше среды?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
О, давай через reduce. Типа пройти по всем датам и найти такую, которая больше других. Очевидно, что sort имеет сложность больше линейной - O(log(n) * n), а reduce будет O(n)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опять по смыслу reduce = проход по массиву и получение одного результата
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ты часто используешь конструкцию: new Date(0, 0, x, y, z) - кмк для нее лучше завести хелпер-функцию с говорящим именем, тогда такие вызовы будут не такими таинственными
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем нам объект? можно было бы сделать две переменные - bankStart и bankEnd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опять reduce нужен, смотри как коротко получается:
var intervals = timeToRobbery.reduce(function(res, interval) { if (interval.to - interval.from >= msInDuration) { res.push(interval); } return res; }, []);
и в конце можно написать тернарник: return intervals.length === 0 ? nul : intervals;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно без скобок
No description provided.