Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Assignment 1 #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Assignment 1 #116

wants to merge 2 commits into from

Conversation

altabay
Copy link

@altabay altabay commented Nov 3, 2012

No description provided.

letters = [[NSMutableArray alloc] initWithObjects:@"A", @"T", @"G", @"C", nil];
lenght = 99; // для тестирования очень удобно выставить например 9

self = [super init];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

После этого не плохо было бы применить конструкцию if (self) {}. Это поможет избежать ошибок, когда по каким-то причинам self не создался.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласен - изменю

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил конструкцию

1.Добавил проверку в init
2. Поменял в mutate количество мутируемых на процент
@public
NSMutableArray *DNA; // массив для ДНК - длину не указываю - на то он и mutable
NSMutableArray *letters; // массив букв для набора значений A, C, G, T
int lenght; // максимальный индекс для массива ДНК
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут вы пишете максимальный индекс, а слово используете английское (пускай и с ошибкой), которое означает длину. Всё-таки, при использовании "говорящих" переменных старайтесь максимально отображать их суть.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И вот ещё - зачем нам хранить количество символов в последовательности в отдельной переменной?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

С названием лохонулся не спорю - буду бдительнее.
А храню чтобы менять можно было - удобно тестировать когда массив меньше чем 100

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда задайте константу, например, с помощью #define, и используйте её.
Использование своей переменной такого плана допустимо, если вы создадите свой конструктор, что-то вроде initCellWithCapacity:(int)capacity; Раз такого конструктора нет, то и переменная не нужна.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на самом деле мы как бы и создаем свой конструктор

Copy link

@slebedev slebedev Nov 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init - это как бы "конструктор по умолчанию", и мы его для нашего класса переписываем. Обратите внимание, что конструктор не принимает никаких параметров.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants