-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Модуляция #4
Модуляция #4
Conversation
Генерация данных
@@ -0,0 +1,48 @@ | |||
import {getRandomNumber} from './getRandomNumber'; | |||
|
|||
const messages = [ |
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.
Название констант таких называй в верхнем регистре разделяя их нижним подчеркиванием
MESSAGES NAMES PHOTOS_DESCRIPTIONS
function getOneComment(i) { | ||
const oneComment = {}; | ||
|
||
oneComment.id = getRandomNumber(i * 10 + 1, (i + 1) * 10); |
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.
Магические числа, такие как 10, 6, 2 нужно выносить в константы и давать им имя, чтобы было понятно почему именно они, разработчик который в будущем будет смотреть код не будет знать о техническом задании для этой задачи и ему нужно показать так контекст
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.
Принято
export function getComments () { | ||
const comments = []; | ||
|
||
const maxComments = getRandomNumber(0,30); |
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.
30 тоже магическое число
export function getPhotos() { | ||
const photos = []; | ||
|
||
for(let i = 0; i < 25; 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.
25 вынеси в константу
onePhoto.id = i + 1; | ||
onePhoto.url = `photos/${onePhoto.id}.jpg`; | ||
onePhoto.description = photosDescriptions[i]; | ||
onePhoto.likes = getRandomNumber(15,200); |
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.
15 и 200 в константы
🎓 Модуляция