4 Replies - 388 Views - Last Post: 27 May 2019 - 01:51 AM Rate Topic: -----

#1 tonystav   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-May 19

Please Critique My Code

Posted 23 May 2019 - 01:45 PM

Hello,

I created a feature-rich version of Conway's Game of Life as a coding challenge. I'd like if someone could critique my code so that I can improve my work. I attached a copy of the code to this message.

This is my first post, so please don't be TOO harsh!

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Please Critique My Code

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15116
  • View blog
  • Posts: 60,494
  • Joined: 12-June 08

Re: Please Critique My Code

Posted 23 May 2019 - 01:49 PM

It's.. ah.. missing the code. ;)
Was This Post Helpful? 0
  • +
  • -

#3 tonystav   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-May 19

Re: Please Critique My Code

Posted 23 May 2019 - 02:05 PM

Hi,

Sorry, I need to provide a link, because it won't let me post / upload the file. Here's the link: https://github.com/tonystav/GameOfLife

The code is functional, so you should only need to load it into your ide and run it.

Thanks.

This post has been edited by NormR: 23 May 2019 - 02:45 PM
Reason for edit:: Removed . at end of URL

Was This Post Helpful? 0
  • +
  • -

#4 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 780
  • View blog
  • Posts: 5,842
  • Joined: 25-December 13

Re: Please Critique My Code

Posted 24 May 2019 - 06:25 AM

Some observations:
Too many large methods.
Not enough comments
The code is not properly indented - some is because my IDE doesn't handle tabs correctly
Many hardcoded values
Repeated code that could be in a method: switch that sets colors

Cell sizes too small. To make them 5 to 20 vs 2 to 5 requires finding and changing several lines of code.

An option: Use colors to show a cell's transition from alive to dead and from not alive to alive.

This post has been edited by NormR: 24 May 2019 - 10:47 AM

Was This Post Helpful? 1
  • +
  • -

#5 Atspulgs   User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 537
  • Joined: 29-July 09

Re: Please Critique My Code

Posted 27 May 2019 - 01:51 AM

Stuff like this is kinda redundant.
if (displayMode.currentDisplayMode == displayModes.blackWhite) { return true; }
else { return false; }



your check already returns true or false so you can just do something like...
return displayMode.currentDisplayMode == displayModes.blackWhite;



I concur on what NormR says too. So much code seems to just have been copied and pasted. Try to code with the thought of how much code you can realistically and practically reuse.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1