Skip to content
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

Question re Battleship game in Ch. 8: why functions are not part of our objects? #16

Open
mashablair opened this issue Sep 23, 2016 · 1 comment

Comments

@mashablair
Copy link

I have a question about this Battleship code in Chapter 8. We have the model, view, controller objects; however, some functions, like helper function parseGuess() and handler functions, like handleKeyPress are not a part of the objects.

For example, why couldn't we make the parseGuess() function a method of controller object? And is init function always a stand-alone function because it needs to start everything?

Thank you so much!

@h35ahmed
Copy link

Possibly because those functions could be used at a later time by another js-program. However you can move the functions into the models object. Those methods will yield the same result; however you'll need to make sure you use "this." when calling them from within the object.

Hope this helps

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

No branches or pull requests

2 participants