{"id":105,"date":"2014-03-17T18:00:06","date_gmt":"2014-03-17T18:00:06","guid":{"rendered":"http:\/\/www.karstencode.com\/?page_id=105"},"modified":"2014-03-17T18:01:34","modified_gmt":"2014-03-17T18:01:34","slug":"a-review-of-the-t3-project","status":"publish","type":"page","link":"http:\/\/www.karstencode.com\/?page_id=105","title":{"rendered":"A Review of the T^3 Project"},"content":{"rendered":"<p>This is a personal review of my post DBC work. After DBC I took time for family obligations and this is a review exercise. \u00a0I&#8217;m going to point out the parts in which I had problems and my thought process behind some of the work. Please feel free to leave comments. Actually, I insist that you give advice.<\/p>\n<p>First the code:\u00a0https:\/\/github.com\/ymeynot45\/T3_trials<\/p>\n<div>\n<dl id=\"attachment_93\">\n<dt><a href=\"http:\/\/www.karstencode.com\/wp-content\/uploads\/2014\/03\/Screen-Shot-2014-03-05-at-4.31.08-PM.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"Tic Tac Toe board\" src=\"http:\/\/www.karstencode.com\/wp-content\/uploads\/2014\/03\/Screen-Shot-2014-03-05-at-4.31.08-PM-300x237.png\" width=\"300\" height=\"237\" \/><\/a><\/dt>\n<dd>Tic Tac Toe board<\/dd>\n<\/dl>\n<\/div>\n<p>I&#8217;ll admit I found it really easy to figure out how to do the work, but I had more than one problem where I forgot terms. \u00a0Those are the issues that always take the most time for me as they are the hardest to figure out what was wrong.<\/p>\n<p>I started with the HTML, CSS and JS. I wanted to focus on the AJAX and knowing what data I was passing back and forth before I designed the backend to handle it. \u00a0I had used AJAX for some minor things in the past but it was normally sending only one or two pieces of data.<br \/>\nSo my first problem was<br \/>\n$(&#8220;#currentboard&#8221;).val(response.currentboard);<br \/>\nThis code was to pass the current condition of the board back and forth. Simple, except when writing it I put .value as the code in sublime turned blue indicating that it was a keyword and it is also the name of the CSS location I&#8217;m trying to change. \u00a0It&#8217;s one of those things when you haven&#8217;t done it in a while and it looks right, it sounds right, and it feels right&#8230; yet, it isn&#8217;t right. \u00a0I fixed it by unhiding the field and seeing that it wasn&#8217;t changing. \u00a0Then I threw a &#8220;puts&#8221; statement in the ruby right before sending back the info. \u00a0That made it real clear that the Ruby was working but JS was broken. \u00a0An easy fix once I knew where to look.<\/p>\n<p>Next came an issue from the Ruby. My memory failed me as I used a .to_s like I would with an integer, on an array. The code,<br \/>\ncols = [firstcol.join, secondcol.join, thirdcol.join]<br \/>\nI forgot that when you .to_s an array it converts the brackets and quote marks in the array. \u00a0I didn&#8217;t catch the error with a .class as it was supposed to be a string. I caught it with another print\/puts line. The extra quotes didn&#8217;t standout enough for me to take note, but the escapes for each of the quote marks inside of the brackets were a big clue.<\/p>\n<p>Structure&#8230; When I write code I like it when it reads like a book. \u00a0The methods in the main body are all wrapped in ones that I create so it is explicit what each of them do, but I&#8217;ve never gotten a good read from my mentors as to when too much is too much. \u00a0An example:<br \/>\nif board.include? &#8220;5&#8221;<br \/>\nreturn &#8220;5&#8221;<br \/>\nthat is a simple piece of code. \u00a0It is at the beginning of the process for the AI to choose a move. \u00a0It is easy to understand that if there are a five in board return a 5, but it doesn&#8217;t tell you why. \u00a0I like using method names to walk people through the code. \u00a0I didn&#8217;t make a new method because it is such a simple piece of code. \u00a0I look forward to having more mentors and teachers show me how to make my code more legible to programmers. How not to over complicate that which is already simple.<\/p>\n<p>Another decision in my code was:<\/p>\n<div>\n<dl id=\"attachment_98\">\n<dt><a href=\"http:\/\/www.karstencode.com\/wp-content\/uploads\/2014\/03\/Screen-Shot-2014-03-06-at-3.46.42-PM.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"line_check code\" src=\"http:\/\/www.karstencode.com\/wp-content\/uploads\/2014\/03\/Screen-Shot-2014-03-06-at-3.46.42-PM-300x169.png\" width=\"300\" height=\"169\" \/><\/a><\/dt>\n<dd>line_check code<\/dd>\n<\/dl>\n<\/div>\n<p>I originally had this as two separate methods: block_check &amp; win_check. \u00a0It include the line, but not the piece so it was practically the same method and only took one argument. \u00a0I debated combining the two as it made it more likely to break and harder to track where the problem might occur. I eventually did because I know we remove repetition to make our code better but there are occasion where I&#8217;m not sure if it applicable.<\/p>\n<p>The rest was easy, some planning &amp; some trial in error. \u00a0My next project for fun and as a refresher will be to convert a <a title=\"Lone Wolf\" href=\"http:\/\/en.wikipedia.org\/wiki\/Flight_from_the_Dark\" target=\"_blank\">Lone Wolf<\/a>\u00a0book in to a web game. \u00a0It will require basics like a login, sql storage of player &amp; character info, a lot of AJAX when combat takes place and an improvement in my UX skills to make the HTML and CSS accessible and attractive to a larger audience. \u00a0I hope that if I work hard that I could have it done with in two weeks. \u00a0I need another DBC like project with a ticking clock. \u00a0I do my best work under the gun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a personal review of my post DBC work. After DBC I took time for family obligations and this is a review exercise. \u00a0I&#8217;m going to point out the parts in which I had problems and my thought process behind some of the work. Please feel free to leave comments. Actually, I insist that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":65,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-105","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/pages\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.karstencode.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":3,"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/pages\/105\/revisions"}],"predecessor-version":[{"id":108,"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/pages\/105\/revisions\/108"}],"up":[{"embeddable":true,"href":"http:\/\/www.karstencode.com\/index.php?rest_route=\/wp\/v2\/pages\/65"}],"wp:attachment":[{"href":"http:\/\/www.karstencode.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}