<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Taylor McNeil on Medium]]></title>
        <description><![CDATA[Stories by Taylor McNeil on Medium]]></description>
        <link>https://medium.com/@taylor-mcneil?source=rss-9ebf3e4f9f7f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hOecmPb7pdrDNA5cnsa-XQ.jpeg</url>
            <title>Stories by Taylor McNeil on Medium</title>
            <link>https://medium.com/@taylor-mcneil?source=rss-9ebf3e4f9f7f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 13:27:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@taylor-mcneil/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Design Fundamentals for Developers]]></title>
            <link>https://medium.com/thedevproject/design-fundamentals-for-developers-271b8304ed0c?source=rss-9ebf3e4f9f7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/271b8304ed0c</guid>
            <category><![CDATA[design]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Taylor McNeil]]></dc:creator>
            <pubDate>Tue, 29 Mar 2022 10:02:54 GMT</pubDate>
            <atom:updated>2022-04-19T08:45:23.105Z</atom:updated>
            <content:encoded><![CDATA[<p>A crash course in design fundamentals for people who aren’t designers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HznlfJKWV_3nMcvb" /><figcaption>Photo by <a href="https://unsplash.com/@new_data_services?utm_source=medium&amp;utm_medium=referral">NEW DATA SERVICES</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Developers often find themselves sitting in design roles, despite design not being their job description. While this is not an ideal situation, it is often the reality we find ourselves in. While funny, the term “designed by a programmer” is often accurate. It is very easy to spot designs created by programmers or developers who don’t understand design fundamentals well. Let’s get rid of that term and take a quick crash course into design fundamentals. In this post, I will share eight design fundamentals and a few best practices to help you design better-looking interfaces. One important thing to remember is that: Design is subjective, and ultimately use your best judgment when creating your designs.</p><h3>The Eight Fundamentals</h3><h4>1.) Lines</h4><p>Lines are the building blocks of design. They create shapes and give form to different components. Lines can come in varying lengths and thicknesses, and your use of lines can convey different messages. Most lines will fall into two types: an implied line (elements or rectangles next to each other) or a literal line. Lines are great for separating information and creating emphasis on specific areas.</p><p>Here is an example of a literal line creating emphasis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*loO6ouT726N9CxgIwVVCDg.png" /></figure><p>Here is the same design with an extra line added and line thickness changed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*U_c82hJQ6aIEqF0pZd9PCg.png" /></figure><p>Notice that the design seems off now because the line no longer creates emphasis but instead groups information.</p><p>Here is an example of an implied line separating information. The different colors create a color-blocking effect separating the information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*CITkShJvIfwpSe__VpVVmQ.png" /></figure><h4>2.) Shapes</h4><p>A logical step up from the simple line would be a shape. Shapes can convey emotions and create different feelings depending on their alignment and size. They tend to fall into two categories: geometric or fluid. Geometric shapes are uniform and mathematically perfect. These shapes tend to convey strength and organization. Fluid shapes are natural shapes that tend to have many curves and are irregular mathematically speaking. Fluid shapes feel more relaxed and calming. Fun fact: The most common shapes in web design are the square and rectangle.</p><p>Here is an example of how geometric shapes convey a sense of organization and structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*As9K8mP5VacFkqVirikL2A.png" /></figure><p>Here is the same design, but I removed some of the rectangles that contained products. This has broken the organization of the grid and made the design look confusing, despite it not breaking any other design fundamentals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzpmlRK8-ug3U-3LvMUANQ.png" /></figure><p>Here is an example of mixing fluid and geometric shapes in the same design. There is no hard-fast rule stating that you cannot combine both but be careful of creating a visually cluttered layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*gx5S6AJadJasLviBAgn3ww.png" /></figure><h4>3.) Color</h4><p>Now that we have lines and shapes let’s talk about color. Colors convey different messages and meanings. Color theory is an entire school of thought and can get complex once we start talking about complementary colors, tertiary colors, hue, saturation, lightness, etc. My advice for this section is to use a premade color palette and understand the emotion you want to evoke from your users. You can use online generators for free or look at the color palettes from other websites you like. Color is one of the easiest design fundamentals to get wrong; however, it makes a huge difference when done correctly.</p><p>Here is an example of terrible color choices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*dlb6AS9_XJ8jZKrcc97SUg.png" /></figure><p>Here is the same design with colors that work well together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*WDRsTz3QDuBN-6hBr9GPkA.png" /></figure><h4>4.) Contrast</h4><p>Contrast is heavily related to color, so talking about this one next makes sense. Contrast is a very simple fundamental to understand; unless you are making a deliberate design choice, you want to ensure enough visual difference between elements to let users know where you want them to look. Contrast is best explained with pictures.</p><p>Here is an example of a landing page with good contrast. It is apparent to the user where the CTA is and what you want the user to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*3CfobDN6FESeF5lHMB6ZMQ.png" /></figure><p>Here is an example of bad contrast. Everything has a similar color; it is hard for users to know what they are supposed to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8vyiDOI6PgtdgTHYU_fWA.png" /></figure><h4>5.) White Space</h4><p>White space is the empty or negative space around different elements on your page. White space can serve a few goals. It can focus user attention, separate elements, or convey feelings. A quick note here, white space doesn’t always have to be white. It is just space free of elements. Let’s see a few examples.</p><p>Here white space is being used to separate elements. White space separates the heading from the paragraph text and the background.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*MjGhCenBO_EadpNMGUDNSw.png" /></figure><p>Here is the same text but with white space removed. White space is vital to how information is formatted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*NV4kmS9kUN90v4O_fpjKDg.png" /></figure><p>Now let’s look at how white space can convey feelings. In this example, the BBC website has a much more compact design emphasizing getting more information on the screen. This creates a rushed and crowded feeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-7Zxl6kztFFx9vp-ro90XA.png" /></figure><p>In this example, the resort page uses white space to convey ease and a serene feeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*MstfknvDwbUjpgUxBEH21w.png" /></figure><h4>6.) Typography</h4><p>Similar to color, typography is its own school of thought. When selecting the font types for your design, it is important to consider the other UI design principles such as white space, color, contrast, hierarchy, and alignment. We will speak about hierarchy and alignment later in this post. You want your fonts to work well together. Fonts that are too large or too similar can look bad when paired together. When choosing a typeface pair, it is vital to consider the feeling you are trying to convey; certain fonts evoke feelings of nostalgia, and others can evoke elegance. Regardless of the fonts you choose, remember to pick legible fonts and view the font pairs on different screen sizes. Not all fonts look good when scaled up.</p><p>Here is an example of bad typography. Three different typefaces appear in a small space, creating no consistency. The heading typeface is hard to read. The paragraph typeface is in all caps and could be considered a display font or heading typeface. None of these typefaces work well together, and they all invoke different emotions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*g01vHfV6dFtEVdNWxu_3KA.png" /></figure><p>Here is the same paragraph with easier to read and more cohesive typefaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*rzqlFFI-zf-KedL6F__CjQ.png" /></figure><h4>7.) Scale &amp; Visual Hierarchy</h4><p>While these can be considered separate design principles, scale and visual hierarchy work well together. Scale is a straightforward design principle. Elements of a similar type should be of a similar size. For example, if you are creating a grid, most of the items in the grid should be of similar size and take up the same amount of space. It’s fine to have elements that don’t conform to this rule, but too many incorrectly sized elements look weird. Let’s take a look at an example.</p><p>Here is a design in which we kept the “grid” but changed the size of the elements. This is visually confusing and makes for an unpleasant design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*f5kewrh21AsKUfwATc_nRQ.png" /></figure><p>Visual hierarchy is related to scale. It is through the use of scale that visual hierarchy is created. You can direct a user’s attention by having important elements be different sizes or colors. If there is no hierarchy present in your designs, they can often look flat or lack contrast. Hierarchy is best explained through visuals.</p><p>Here is an example of visual hierarchy done right. The larger photo and typeface make it easier for the eye to understand where to look first. The differences in shape help separate information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*f7RyoEhl5fzmPeXKa_cmXw.png" /></figure><p>Here is the same picture, but the visual hierarchy has been removed. This design makes it harder for the eye to pick a spot to land on. It is not a terrible design, just harder to understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*rQWKzA17XOpooNB8iUbrlw.png" /></figure><h4>8.) Alignment</h4><p>The last design principle is alignment. There is not much to say here, honestly. Alignment is a very visual principle, and it’s the idea that the position of all your elements should make sense in relation to each other. That’s it. Example time!</p><p>Here is an example of bad alignment. Elements are hanging around with no connection to one another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*bdTB61ak0u5-GnhFYMZ50Q.png" /></figure><p>Here is an example of good alignment. Everything just makes sense in relation to one another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*hqf4p67BMR0PnuSyIYBuPw.png" /></figure><p>Now that you understand the eight basic UI design fundamentals let’s talk about a few best practices and how everything fits together.</p><h3>Best Practices</h3><p>1.) Know your user. This is self-explanatory, but you should have a good idea of the primary demographic for your product or service. Creating user stories or mapping customer journeys can help understand what users may need and who they might be. Knowing your user enables you to choose the correct emotions for your design. Design fundamentals that tie back to this area are color, typography, and shape.</p><p>2.) Actionable steps. Ideally, we want users to interact with the design in a particular way or sequence. If we want this to happen, we must make it easy for users to understand what we want them to do. This can include “call to actions” in a different color, buttons for scheduling calls that are bigger than other buttons, etc. Design fundamentals that tie back to this area are color, contrast, and visual hierarchy.</p><p>3.) Use references. Overall this will make your life easier. If you are a developer that is not a designer, coming up with new and fresh ideas can be complicated. Using references or examples can help immensely in creating new designs. Websites like <a href="https://www.behance.net/search/projects?search=Website%20Design">behance </a>or <a href="https://dribbble.com/">dribbble </a>are great places to find inspiration for your designs.</p><p>4.) Keep it simple. Often less is more. Your design should tell a story. What is the product? How does the product work? How can your design help the user solve their problem? That’s it, nothing else. A simple design is easy to maintain and update.</p><p>5.) Test &amp; Validate. A very boring best practice but a useful one. After staring at a design for a while, we are often blind to its faults or shortcomings. Spend some time watching other people interact with your design to locate bugs and observe if people are reaching the desired outcome.</p><h3>Fin</h3><p>That was a lot of information to absorb, but hopefully, you can now create better-looking designs. No design fundamental is more important than the other, and they all work together to create seamless designs. If you follow the fundamentals and best practices, you will have great-looking designs in no time. You can find me on Twitter <a href="https://twitter.com/ThatDevTaylor">@thatDevTaylor.</a></p><p><em>Sign up for our </em><a href="https://newsletter.thedevproject.io/"><em>Free Weekly Newsletter</em></a><em>. Fresh content from developers all over the world, fresh and direct from the field! Don’t forget to follow our publication </em><a href="https://medium.com/thedevproject"><em>The Dev Project</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=271b8304ed0c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thedevproject/design-fundamentals-for-developers-271b8304ed0c">Design Fundamentals for Developers</a> was originally published in <a href="https://medium.com/thedevproject">The Dev Project</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Alternative Guide to Becoming a Kick-Ass Junior Dev]]></title>
            <link>https://medium.com/geekculture/an-alternative-guide-to-becoming-a-kick-ass-junior-dev-4039474e911f?source=rss-9ebf3e4f9f7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4039474e911f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[advice]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Taylor McNeil]]></dc:creator>
            <pubDate>Wed, 26 May 2021 03:42:44 GMT</pubDate>
            <atom:updated>2021-05-26T14:09:43.946Z</atom:updated>
            <content:encoded><![CDATA[<h4>Landing a job you want is actually hard</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xtbmn55t6x4N2Z0G" /><figcaption>Photo by <a href="https://unsplash.com/@helloimnik?utm_source=medium&amp;utm_medium=referral">Hello I&#39;m Nik</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There are so many amazing reasons to get into tech, and tech draws so many different types of people. However, one thing most people have in common is that they start from the bottom. I mean entry-level. For some, that may be QA or testing; for others, that might mean an internship that turned into a job. Either way, most of us are not starting as Elon Musk’s right-hand man, and that’s okay.</p><p>Alternatively, if you have had the pleasure of reading some of these entry-level job descriptions, you might have run across some of these under their lists of requirements:</p><ul><li>Multitasking Unicorn</li><li>Developer Ninja</li><li>Willing to work hard (There was an option to work softly?)</li><li>29 years of experience in Flutter ( Do I have to have a time machine too?)</li><li>Previous CTO experience is a plus ( okay jk this wasn’t an entry-level job, but the role definitely wasn’t a senior role)</li><li>Understanding of the blockchain (Your business model wouldn’t even benefit from the blockchain model.)</li></ul><p>This list could be endless. It’s common knowledge that those requirements are just a “wish list” or dreams of the hiring manager. But why are they dreaming of magical possibilities and paying in cheese sticks and experience? There is a disconnect here. Rather than tell you to “update your resume” or “network,” let me offer some alternative and potentially painful advice. Let’s Begin.</p><h3>1.) You aren’t special … yet</h3><p>Most of us are not blessed with super-rich parents or family members with unique connections, which means most people have never heard of you and don’t know you exist. If you combine this with being a newbie and lacking skills, it’s a recipe for disaster and having your resume thrown in the trash.</p><p>However, not all hope is lost; in fact, you can use this to your advantage. Everyone starts as a beginner, and as you learn, you will have the opportunity to teach and speak to other beginners. You don’t have to make tutorials or give talks but spread the knowledge that you acquire. Make content, even bad content, about what you are learning. Every time you spread your knowledge, you have the opportunity to meet new people and impact others. It’s through that impact that you start to amass some interesting skills.</p><h3>2.) You have done this before … right?</h3><p>When you are applying for entry jobs, you usually are competing with dozens of applicants, if not hundreds, for the same positions. What is it about you that will set you apart? It’s like applying to college all over again. If you don’t have a stellar resume with tons of work experience to back yourself up, what social proof can you show? Do you have projects on your GitHub? Have you participated in hackathons? Are you a heavy participant in your local coding communities?</p><p>Ignoring all the stigmas about coding interviews, it can be pretty hard to determine if a candidate has programming abilities. You can go a long way in promoting yourself by having social proof. Whether that social proof is people, GitHub, trophies from robotics competitions, or a recipe organizer for your mom, having something you can talk about at length that is not a calculator helps a lot.</p><h3>3.) You have to work for … free</h3><p><em>I am not telling you to take an internship or a job for no money. </em>I am telling you that people will have an easier time believing that you can do something if there is proof of you doing that thing. That may mean working for free on the weekend to create projects to fill up your portfolio. It might be working together with a local charity that really needs a website. Perhaps your little brother needs help hacking his game to beat his friends. Regardless of what path you take, being a developer is going to require you to learn a lot. Every moment of that learning is not always going to be paid. If you can accept that you need to work for free, building up social proof is a breeze.</p><h3>4.) You do know how to pitch … right?</h3><p>Say what you want about Shark Tank and Venture capitalists; they know how to get to the point. No one says no faster than a small child and VC accelerator fund. One of the main reasons for rejections, no unique value proposition. If I have 100 applicants in front of me and they are all equally awesome, why should I choose you? Saying “<em>Because I need a job</em>” is not an acceptable answer. While it may be true, it’s not winning any prizes.</p><p>This is the part where I get all touchy-feely and ask you to think about the places that you want to work and why you want to work there. Tech is a tough field. You will have some long nights; you may be asked to be on call. You might have interns delete your entire codebase. Knowing why you want to be somewhere helps get you through those tough times; it’s okay if the reason that you are working somewhere is purely selfish; own it.</p><p>On the flip side, getting strategic about where you want to work helps you tailor your unique value proposition. If you are a former teacher, you might be a great technical trainer or team lead. You could also take that experience and look for tech companies that focus on education. Philosophy majors can make for great software architects because they are used to thinking very abstractly and logically. Get creative. It’s a part of learning how to pitch.</p><h3>5.) You are already at the … bottom</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NReksugdNGz_d5R3" /><figcaption>Photo by <a href="https://unsplash.com/@artem_kniaz?utm_source=medium&amp;utm_medium=referral">Artem Kniaz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This may come as a shock to you right now, but you are already at rock bottom in terms of your tech career. You cannot become a bigger noob than you currently are right now, which is great. So be 100% shameless in your learning and growth. What do you have to lose? Everyone already knows that you suck. You will learn more by letting go of your ego and just embracing the suck. Honestly, it’s tiring pretending that you know things. I dare you, just once this week, say, “I don’t know.” Stare someone in the eye and say it. It’s freeing.</p><h3>Final Words &amp; Bonus Tip</h3><p>Becoming Kick-Ass is not easy. It will require long nights, lots of stress, and even some breakdowns, but I promise it is worth it. You don’t become Kick-Ass by winning a trophy or having someone grant you the title. You become Kick-Ass by putting some skin in the game and believing that you are.</p><p><em>Final Tip: Being a developer is a job, but a job is not who you are.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4039474e911f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/an-alternative-guide-to-becoming-a-kick-ass-junior-dev-4039474e911f">An Alternative Guide to Becoming a Kick-Ass Junior Dev</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tic Tac Toe in Java]]></title>
            <link>https://medium.com/codex/tic-tac-toe-e53212028341?source=rss-9ebf3e4f9f7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e53212028341</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Taylor McNeil]]></dc:creator>
            <pubDate>Thu, 06 May 2021 05:32:57 GMT</pubDate>
            <atom:updated>2022-04-18T17:22:01.417Z</atom:updated>
            <content:encoded><![CDATA[<h4>Java Tutorials — Tic Tac Toe</h4><h4>How to create a console Tic Tac Toe game in Java</h4><figure><img alt="Tic Tac Toe Game (created by author)" src="https://cdn-images-1.medium.com/max/500/1*A9Wa48URAJEve7GrqtyGJQ.png" /><figcaption>Tic Tac Toe Game (created by author)</figcaption></figure><p>Tic Tac Toe is a classic programming problem that many developers encounter on their programming journey. Deceptively simple, Tic Tac Toe can teach developers about:</p><ul><li>Arrays</li><li>Booleans</li><li>Conditionals</li><li>Functions</li><li>Looping</li><li>Variables</li><li>Data Structures</li></ul><p>In this tutorial, we will create a console tic tac toe game that relies on a random number generator to control the computer. Where applicable, I will comment on how the code can be improved. This tutorial is going to use the most basic solution to make this accessible to all skill levels. Always remember to test your code at the end of each section to make sure it works! Let’s begin.</p><p>Note: You can enjoy this entire tutorial in a video format on YouTube:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3KM6Q0TFC28%3Fstart%3D50%26feature%3Doembed%26start%3D50&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3KM6Q0TFC28&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3KM6Q0TFC28%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bad846ed6266d1f14951def9e7d6201e/href">https://medium.com/media/bad846ed6266d1f14951def9e7d6201e/href</a></iframe><p><em>If you get confused at any time, the full code can be viewed at any time </em><a href="https://github.com/Taylor-McNeil/YouTubeTutorials-/blob/master/TicTacToe.java"><em>here</em></a><em>.</em></p><h3>Building the Board</h3><p><em>For simplicity, this entire tutorial will be built in one class and feature several functions.</em></p><p>The first step in building our game is to create the board. We are going to use a 2D character array full of dashes [ - ], vertical bars [ | ], and spaces [“ “] to create our board. Let’s create an array called <em>gameBoard </em>and fill it. We will also create a function called <em>printBoard() </em>to allow us to visualize the board.</p><figure><img alt="A visualization of the gameboard (created by the author)" src="https://cdn-images-1.medium.com/max/1011/1*cLRBnJt4VzuzJnKU6M4wFg.png" /><figcaption>A visualization of the gameboard (created by the author)</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ed7c8ff6e453834fba24d8be354dff/href">https://medium.com/media/06ed7c8ff6e453834fba24d8be354dff/href</a></iframe><p>A quick explanation of this code snippet. The vertical bars underscores, and spaces represent the grid for the tic tac toe board. You can think of the board as spaces 1–9. The first space is [0][0]. The second space is [0][2]. The third space is [0][4], etc.</p><p><em>All the indices are noted in the comments. The vertical bars exist; however, we are not counting them in our game logic.</em></p><p><em>printBoard() </em>takes in a 2D array and prints the array contents to the console. It does this by using a nested for loop. The first loop tells the computer, for each character row within <em>gameBoard</em>, do the second loop.</p><p>The second loop is asking, for each character within the row, print the character out. At the end of each second loop, we create a new line to keep all the characters from being printed on the same line.</p><pre>/**<em>Note: Printing the board could be accomplished using the tradition for loop. I think the foreach loop is easier to read. **/</em></pre><pre>for (int row = 0; row &lt; gameBoard.length; row++) {<br>  for (int c = 0; c &lt; gameBoard[0].length; c++) {<br>    System.out.print(gameBoard[row][c]);<br>  }<br>  System.out.println();<br>}</pre><p>With this function complete, we have finished building the board.</p><h3>Placing Pieces</h3><p>Now that we have built our board, let’s dive into the game logic. We need a way of determining what character represents the player and the computer; and a way of placing these characters on the board. So let’s create some rules:</p><ul><li>The player will be represented by the <strong>X</strong> character and the number 1</li><li>The computer will be represented by the <strong>O</strong> character and the number 2</li><li>The valid indices for placing pieces are [0][0] , [0][2] , [0][4], [1][0] , [1][2] , [1][4], [2][0] , [2][2] , [2][4]</li></ul><p>Using all of these rules, we can create a method called <em>updateBoard.</em> It will allow us to update a position in the <em>gameBoard</em>, based on whose turn it is and what position they pick.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/448c3d087809de185f4e1421a48943f5/href">https://medium.com/media/448c3d087809de185f4e1421a48943f5/href</a></iframe><p><em>Note: This is the class from before; we have just added the updateBoard() function under the printBoard() function.</em></p><p><em>updateBoard() </em>takes in the location in which the piece will be placed, whose turn it is, and the state of the gameBoard.</p><p>Using our rules from earlier, the player is equal to 1, and their character is X; the computer is equal to 2, and their character is O. An if-else statement was used to determine whose turn it is and what is the correct piece to place.</p><p>After we determined whose turn it is, we need to determine where to place the piece. A switch statement is used to separate the different cases. Case 1 represents if the player or computer chose the first position. (Which is the top left corner) Depending on who chose that position, the corresponding piece is placed in that location, and we break out of the switch statement.</p><pre>/** Change the position and player to see the pieces move around the board. Insert this function call in the main method and play around with the numbers to see the pieces appear. **/</pre><pre>updateBoard(5, 1, gameBoard);<br>updateBoard(1, 2, gameBoard);<br>updateBoard(7, 1, gameBoard);</pre><p>At this point, you should be able to: add pieces to the board for both the computer, and the player. Be sure to test this feature out by switching from the player to the computer.</p><h3>Getting Player Input</h3><p>Now that we can see the board and place pieces on the board, we want the player to tell us where the pieces should go. To do this, we are going to create a new function called<em> playerMove(). </em>Inside of <em>playerMove()</em>, we are going to utilize the built-in Scanner class to retrieve player input and include some user validation to make sure the user inputs a valid response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c67b4e074cb17e58115d687ce5dea087/href">https://medium.com/media/c67b4e074cb17e58115d687ce5dea087/href</a></iframe><p><em>Note: This is the class from before; we have just added the playerMove() function under updateBoard(). We have also imported the Scanner library and created a new Scanner object on line #5. I have left the main method in for readability.</em></p><pre>/** We have created a static Scanner here because we will utilize the player input in other areas. If we create only one instance to hold the player response, we do not have to worry about deleted or having multiple Scanner objects. **/</pre><p>The<em> playerMove() </em>function itself is simple. We ask the player what position they would like to move to, save that response, and feed it into our <em>updateBoard() </em>function.</p><pre>/** Line #15 has code for testing this function. Play around with feeding different values into the function. Do you notice that something is off? **/</pre><p>If you played around with adding different values into the code, you might have noticed that something was off. That is, you can actually place characters on top of spaces that already contain characters. This is not allowed in Tic Tac Toe, and we need to fix this. To do this, we will create a function to validate the player’s move before we place the piece.</p><h3>Validating Moves</h3><p>To validate if the player made a valid move, we need to establish what a valid move is. In our world, we are building a game made of dashes [ — ], vertical bars [ | ], and spaces [“ “]. The dashes and spaces represent blank areas on the board.</p><pre>/**         _ | _ | _     Helpful indices:[0][0] , [0][2] , [0][4]<br>            _ | _ | _                     [1][0] , [1][2] , [1][4]<br>              |   |                       [2][0] , [2][2] , [2][4]   <br>**/     </pre><p>Thus, if a player chooses a space with anything other than a dash or space, that position is either invalid or occupied. For example, [0][1] is a vertical bar, and that is an invalid space for our game.</p><p><em>Note: If you look back in the notes or at the diagram, you can see what values coordinate to the valid spaces.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd3b15b41b26e3918f1438f8ccdd0873/href">https://medium.com/media/dd3b15b41b26e3918f1438f8ccdd0873/href</a></iframe><p><em>Note: We have updated the playerMove() function and added isValidMove() function underneath that.</em></p><p>The <em>playerMove</em>() function now checks whether the player is making a valid move before placing the piece and updating the board. We updated the <em>playerMove() </em>function to include a while loop and a boolean. The boolean is holding the result of the i<em>sValidMove</em>() function. While the result of the<em>isValidMove</em>() is false, the program will keep looping endlessly until the player inputs a valid move.</p><p>Diving into the <em>isValidMove</em>() function, the function accepts the move input by the player and tests to see if the position that the player entered is empty. If the position is empty, then true is return, else return false because the position is occupied.</p><pre>/** You could implement the validation differently. You could create a set for empty positions. You could check if the position was in the empty position set and return true or false based on that. You would need to fill the set with empty positions in the main method before running the game. **/</pre><pre>import java.util.HashSet;</pre><pre>static Set&lt;Integer&gt; emptyPositions = new HashSet&lt;Integer&gt;();</pre><pre>public static void main(String [] args){</pre><pre>  char [][] gameBoard = {{&#39;_&#39;,&#39;|&#39;,&#39;_&#39;,&#39;|&#39;,&#39;_&#39;},{&#39;_&#39;, &#39;|&#39;,   <br>  &#39;_&#39;,&#39;|&#39;,&#39;_&#39;},{&#39; &#39;,&#39;|&#39;,&#39; &#39;,&#39;|&#39;,&#39; &#39;}};</pre><pre>  for(int i =1; i&lt;10; i++){<br>      emptyPositions.add(i);<br>  }<br>  <br>  playerMove(gameBoard);</pre><pre>...omitting playerMove ...</pre><pre>public static boolean isValidMove(int move, char[][] gameboard){</pre><pre>if(!emptyPositions.contains(move)){<br>    return false;<br>  }else{<br>    emptyPositions.remove(move);<br>    return true;<br>  }</pre><pre>/** You can test this out by calling playerMove() a few times in the main method. Check and see if your invalid moves from before are allowed now. **/</pre><h3>Simulating the Computer</h3><p>To keep things simple, we are going to simulate the computer using a random number generator. The computer will choose a random number between 0–9 each turn. We will call the <em>isValidMove() </em>function inside the<em> computerMove() </em>function to ensure that our computer is also moving in valid spaces.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ef0019ab79c713a713139dc71ba51d9/href">https://medium.com/media/6ef0019ab79c713a713139dc71ba51d9/href</a></iframe><p><em>Note: This function is placed under the isValidMove() function.</em></p><p>The <em>computerMove()</em> function is very similar to the <em>playerMove()</em> function. The only difference is the introduction of the random Object. Don’t forget to import the Random library. The Random object will allow us to generate a number from 0 to 10.</p><pre>/** You could stop the bound of the random number generator at 10.</pre><pre>int move = rand.nextInt(10); <br>int move = rand.nextInt(9)+1;</pre><pre>These two lines of code are equivalent. Something worth pointing out is that the random number generator begins with zero and ends with the bound number not being included. That zero could cause us problems; however, we already handled that in our switch case in isValidMove(). Our valid moves only include 1 - 9. Anything else outside that range is automatically considered an invalid move and returns a false value for isValidMove().<br>You can test this out by calling computerMove() a few times in the main method. Mix it up and call playerMove() too. You should start to see the beginnings of a game now. **/</pre><h3>Winning the Game</h3><p>Our game is starting to take shape; only a few steps are left. We need to determine the winning condition or when the game is over. Following traditional tic tac toe rules, the winning conditions are as follows:</p><ul><li>A diagonal on the left axis</li><li>A diagonal on the right axis</li><li>Three across the top horizontal</li><li>Three across the center horizontal</li><li>Three across the bottom horizontal</li><li>Three down the right side</li><li>Three down the center</li><li>Three down the left side</li></ul><figure><img alt="Visual of all possible winning combinations (created by author)" src="https://cdn-images-1.medium.com/max/1011/1*EqNTsKuDTLFDROOZDjWCQA.png" /><figcaption>Visual of all possible winning combinations (created by author)</figcaption></figure><p>Those are the winning conditions; however, the game could also be in a tied state, in which all the spaces are filled, and none of the winning conditions have been met. Following that logic, we want to check if any of the winning conditions have been met each time the player or computer moves.</p><pre>/** Technically, we do not have to check after every move. We can start checking after five moves, but we will check after every move to keep it simple. **/</pre><p>The simplest way to check if a winning condition has been met is to check whether all the spaces in a combination are the same. For example, if [0][0], [1][0], and [2][0] are filled, then the player or computer has three down the left side vertically and has won. Let’s create a new function called <em>isGameOver().</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07dd8fe83399848d7d7405e363c928ec/href">https://medium.com/media/07dd8fe83399848d7d7405e363c928ec/href</a></iframe><p><em>Note: This function is placed under the computerMove() function.</em></p><p>This function is a giant expansion of the logic used earlier. There are eight possible win conditions and one tie condition. This function checks to see if any of the win conditions have been met by either the computer or the player. If a win condition or tie has been met, then the game is over, and a true result will be returned, else a false result will be returned.</p><pre>/** There are many ways to check to see if the player or computer has won. You could:</pre><pre>- Convert all the rows and diagonals into sets, and check the length. A set can only contain unique values. Thus a winning set will only have a length of 1.</pre><pre>-Make the current snippet smaller and check to see if the space is equal to the space next to it. For example is [0][0] == [0][2] == [0][4] and just determine what symbol is inside of the spaces.</pre><pre>-Use a for loop for checking instead of using a giant if statement. You could use a loop for the horizontal conditions, a loop for the vertical, and a loop for the diagonals.</pre><pre>These are just a few ways. There are more ways than these. **/</pre><h3>Play Again?</h3><p>It might not be apparent where to place this function, and that is because we haven&#39;t created the game loop. A game loop will allow the player to play again once a winning condition or tie has been met. To accomplish this, we are going to wrap the main method in two while loops. The first will be checking to see if the player wants to play again, and the second will be checking to see if the game is over. We will create two booleans, gameOver, and playAgain.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68d1b2d6e81af4b7900a70d1743ae5b0/href">https://medium.com/media/68d1b2d6e81af4b7900a70d1743ae5b0/href</a></iframe><p><em>Note: This is the main function of our game. All the other functions are written outside of this function.</em></p><p>playAgain is the main while loop. While playAgain is true, the entire game will continue. We start the game by welcoming the player and allowing them to make the first move. The game will continue by calling the <em>playerMove()</em> function and go through all the methods we created earlier. Then we will check the state of the board on line #12 using the <em>isGameOver()</em> function. If the game is over, we break out of the inner while loop and ask the player if they want to play again.</p><p>If the game is not over, it will become the computer&#39;s turn, and the sequence will repeat again and again until a win condition or tie has been met. Once <em>isGameOver()</em> returns false, we will print out the score and ask the player if they want to play again. We will reuse the scanner from before the save the player&#39;s input. Based on the input of the player, we will end the game or restart the game.</p><p>If you are looking closely, line # 34 contains a function that we have not written yet called <em>resetBoard()</em>. That is because it was not relevant until now. This function sets the board back to its beginning state. You could add a point system to keep the score if you wanted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a91cb3dea06380825d0207d1706af56a/href">https://medium.com/media/a91cb3dea06380825d0207d1706af56a/href</a></iframe><h3>Fin</h3><p>We are done. You now have a complete Tic Tac Toe console game written in Java. The world is your oyster. Continue to sharpen your coding skills by creating other games and never stop learning. <a href="https://en.wikipedia.org/wiki/Snake_(video_game_genre)">Snake </a>might be a fun game to take on. Once again <a href="https://github.com/Taylor-McNeil/YouTubeTutorials-/blob/master/TicTacToe.java">here</a> is the final code in all its glory, if you need a reference. You can find me on <a href="https://twitter.com/ThatDevTaylor">twitter</a> thinking of new articles and talking about games.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e53212028341" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/tic-tac-toe-e53212028341">Tic Tac Toe in Java</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>