Skip to content

OCP refactoring #6

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

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

forshtreter
Copy link

forshtreter@ & frgt@

@@ -68,4 +101,8 @@ var questions = [
];

var questionRegion = document.getElementById('questions');
new QuestionView().render(questionRegion, questions);
var renderers = {};
renderers[AnswerType.Choice] = new choiceQuestionRenderer();
Copy link
Owner

Choose a reason for hiding this comment

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

Можно было совсем избавиться от AnswerType. И вместо Question сделать 2 класса:

var questions = [
    new QuestionChoice('НЛО?', ['Да', 'Неа']),
    new QuestionInput('Два+Два?')
];

Оба они могли иметь интерфейс IDomRender:

{
    /**
     * @retrun {HTMLElement}
     */
    render: function () {}
}

Copy link

Choose a reason for hiding this comment

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

в целом идея таже самая ведь, думали просто что question может не только рендерить, а что-от еще делать.

Copy link
Owner

Choose a reason for hiding this comment

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

Ну он и так сможет что-то делать. Он же имплементирует интерфейс, а не наследуется от класса.

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

Successfully merging this pull request may close these issues.

3 participants