Assignment 1 #116
base: master
Are you sure you want to change the base?
Assignment 1 #116
Conversation
letters = [[NSMutableArray alloc] initWithObjects:@"A", @"T", @"G", @"C", nil]; | ||
lenght = 99; // для тестирования очень удобно выставить например 9 | ||
|
||
self = [super init]; |
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.
После этого не плохо было бы применить конструкцию if (self) {}. Это поможет избежать ошибок, когда по каким-то причинам self не создался.
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.
Добавил конструкцию
@public | ||
NSMutableArray *DNA; // массив для ДНК - длину не указываю - на то он и mutable | ||
NSMutableArray *letters; // массив букв для набора значений A, C, G, T | ||
int lenght; // максимальный индекс для массива ДНК |
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.
С названием лохонулся не спорю - буду бдительнее.
А храню чтобы менять можно было - удобно тестировать когда массив меньше чем 100
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.
Тогда задайте константу, например, с помощью #define, и используйте её.
Использование своей переменной такого плана допустимо, если вы создадите свой конструктор, что-то вроде initCellWithCapacity:(int)capacity;
Раз такого конструктора нет, то и переменная не нужна.
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.
init
- это как бы "конструктор по умолчанию", и мы его для нашего класса переписываем. Обратите внимание, что конструктор не принимает никаких параметров.
No description provided.