aguillaume / TicTacToe

A simple game of Tic Tac Toe
http://aguillaume.github.io/TicTacToe
0 stars 0 forks source link

Refactor the code to use javascript best practices #12

Closed ruta-goomba closed 9 years ago

ruta-goomba commented 9 years ago

Use the best Javascript practices as described in 'Javascript: the Good Parts'(http://www.amazon.co.uk/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742)

aguillaume commented 9 years ago

I need to read the whole book??

ruta-goomba commented 9 years ago

I’ll send you some links to most relevant articles ☺ However, the book is rather small, easily read in couple of evenings.

From: Guillaume [mailto:notifications@github.com] Sent: 03 March 2015 08:27 To: aguillaume/TicTacToe Cc: Sakalauskaite, Ruta Subject: Re: [TicTacToe] Refactor the code to use javascript best practices (#12)

I need to read the whole book??

— Reply to this email directly or view it on GitHubhttps://github.com/aguillaume/TicTacToe/issues/12#issuecomment-76905140.


This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited Company Number: 519500 Registered in England Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL VAT Registration Number: GB 220 4302 31

ruta-goomba commented 9 years ago

Javascript Function Invocation Patterns: http://doctrina.org/Javascript-Function-Invocation-Patterns.html

Javascript scope and closures: http://doctrina.org/JavaScript:Why-Understanding-Scope-And-Closures-Matter.html#closures

Javascript object prototypes: http://doctrina.org/Javascript-Objects-Prototypes.html#pcip

Some others to follow later…

From: Guillaume [mailto:notifications@github.com] Sent: 03 March 2015 08:27 To: aguillaume/TicTacToe Cc: Sakalauskaite, Ruta Subject: Re: [TicTacToe] Refactor the code to use javascript best practices (#12)

I need to read the whole book??

— Reply to this email directly or view it on GitHubhttps://github.com/aguillaume/TicTacToe/issues/12#issuecomment-76905140.


This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited Company Number: 519500 Registered in England Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL VAT Registration Number: GB 220 4302 31

aguillaume commented 9 years ago

If it is such a short book then I'll have a look at it. I'll check out the articles as well. Thanks for those :) :+1:

aguillaume commented 9 years ago

I've been reading the articles you provided, and they are very intense... also some what confusing. I will have to re-read them a few times when I try to put them into practice.

I have been trying to design a Board object that can be used through out the Tic Tact Toe.

Are there any particular examples of bad coding in the Tic Tac Toe that you have seen? @ruta-goomba

ruta-goomba commented 9 years ago

Hi Guillaume,

TicTacToe is a small project not intended to expand massively so the code we have there is perfectly fine for that purpose. However, I’m taking this as a learning experience as well as a little project and I think we both want to learn the best practices that could later be used for larger scale projects. If we look at it from such perspective, then there are a few things we could do (sorry I didn’t have a chance to start on that):

1) Use only local scope variables, stop using global scope variables

2) Replace function declarations with function expressions

3) Avoid initiating functions with new keyword

4) Replace all i++ with i+= 1

5) Implement memoization for recursive function I introduced

Can’t think of anything else at the moment. If you want, we can have a meeting to discuss all this. Let me know.

Ruta

From: Guillaume [mailto:notifications@github.com] Sent: 03 March 2015 14:52 To: aguillaume/TicTacToe Cc: Sakalauskaite, Ruta Subject: Re: [TicTacToe] Refactor the code to use javascript best practices (#12)

I've been reading the articles you provided, and they are very intense... also some what confusing. I will have to re-read them a few times when I try to put them into practice.

I have been trying to design a Board object that can be used through out the Tic Tact Toe.

Are there any particular examples of bad coding in the Tic Tac Toe that you have seen?

— Reply to this email directly or view it on GitHubhttps://github.com/aguillaume/TicTacToe/issues/12#issuecomment-76959328.


This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited Company Number: 519500 Registered in England Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL VAT Registration Number: GB 220 4302 31

aguillaume commented 9 years ago

yes defiantly a learning experience. I have only started going through the book, and read the articles.. but i need to re - read them because i am still struggling to understand the whole function stuff...