tag:blogger.com,1999:blog-72579462986803180372024-03-14T08:12:02.559-07:00A Leaky MemoryBVB's blog about his journey through the field of software engineering.BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-7257946298680318037.post-89487593915836540572014-01-21T19:10:00.000-08:002014-01-22T09:36:25.578-08:00Light Light - a Simple Flashlight Application for AndroidAfter a 5-minute search around Google Play for a simple flashlight app led me nowhere, I decided to make my own, <a href="https://play.google.com/store/apps/details?id=com.borysboyko.lightlight">Light Light</a>. <span style="font-family: inherit;"><span style="background-color: white;">The app simply toggles your Android device's camera flash LED so that you can use your phone as a flashlight. Also, it has a setting for turning the flash on by default when the app starts. I didn't find many apps that do this, and I thought it would be a nice feature to have, because if you are starting a flashlight app, chances are you want the light to turn on ASAP.</span></span><br />
<br />
The app does require two permissions - CAMERA and INTERNET. CAMERA is used for access to the camera flash, while INTERNET is used for displaying ads. If the ads bother you, there's a simple setting to turn them off - feel free to do so. The app does not collect any data whatsoever or use the INTERNET permission for anything else.<span style="font-family: inherit;"><span style="background-color: white;"> There are never any no</span>tifications. Pl</span>ease give it a try and let me know what you think.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://play.google.com/store/apps/details?id=com.borysboyko.lightlight"><img border="0" src="http://1.bp.blogspot.com/9UsqHX2RCQRIVopuyytAWpoukfjvhnZI-tKe5YANH0TFj00x2YDRx8HsQkymCLXQ6ok=h900-rw" height="320" width="179" /></a></div>
<br />BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com1tag:blogger.com,1999:blog-7257946298680318037.post-54052190269096202642013-11-14T20:02:00.003-08:002013-11-19T08:11:33.581-08:00A Different Look at Managing Android Image Resources<div>
<br /></div>
<div style="text-align: justify;">
I have faced many challenges since I started working as an Application Engineer at <a href="http://www.youeye.com/">YouEye, Inc</a>. Most were involved with the development of software that targeted end users. Of course, it is sometimes necessary to step aside and create some internal tools that can aid the development process - making it quicker and more efficient by removing repetitive, excruciatingly boring tasks. Investing a day to save a week in the long run is always worth it, unless a deadline is just around the corner.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The latest tool that I worke<span style="font-family: inherit;">d on, <a href="https://github.com/YEDev/easyassets">easyassets</a>, is a Ruby script that can be described with its long name: a <span style="background-color: white; line-height: 19px;"><a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics">SVG</a> to <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a> image asset converter <a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)">Ruby script</a> for major mobile device's screen sizes and densities. The purpose of the script is to allow designers to quickly generate image assets required by a mobile application in order to support all screen sizes and screen densities by simply providing a vector image on a canvas in the <a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics">SVG format</a>.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; line-height: 19px;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; line-height: 19px;">This post describes the thought process behind the development of the easyassets tool. If you would like to skip reading and get the tool, please see this <a href="https://github.com/YEDev/easyassets">GitHub repository</a>. </span></span><span style="background-color: white; line-height: 19px;"><a href="https://www.youeye.com/">YouEye, Inc.</a> has released it to the public under the </span><a href="http://www.gnu.org/copyleft/gpl.html" style="line-height: 19px;">GNU General Public License, Version 3 (GPLv3)</a><span style="background-color: white; line-height: 19px;">.</span><br />
<span style="background-color: white; line-height: 19px;"><br /></span>
<span style="line-height: 19px;">The Android Developer website has a nice article that outlines how to <a href="http://developer.android.com/guide/practices/screens_support.html">support multiple screen sizes</a>. A few sections discuss <a href="http://en.wikipedia.org/wiki/Pixel_density">pixel density</a>. A 100 by 100 pixel image will look larger and more "pixelated" on a screen with a small pixel density than on a screen with a large pixel density. Android offers a solution for supporting screens of multiple pixel densities - suffixes for resource drawable directories. These suffixes include -ldpi, -mdpi, -hdpi, -xhdpi, and -xxhdpi. There are a few others, but I will only speak about the ones listed. A 100 by 100 pixel image on an mdpi screen would have to be 75 by 75 pixels in order to appear the same size on a ldpi screen, 150 by 150 pixels in order to appear the same size on a hdpi screen, 200 by 200 pixels on a xhdpi, and 300 by 300 pixels on a xxhdpi. This can be explained by the 3:4:6:8:12 ratio for ldpi:mdpi:hdpi:xhdpi:xxhdpi.</span><br />
<span style="line-height: 19px;"><br /></span>
<span style="line-height: 19px;">Why can't we just create multiple sizes of an image to support all screen densities? Well, we actually can! However, there are two problems:</span><br />
<br />
<ol>
<li><span style="line-height: 19px;">It is sometimes tedious to manually create multiple sizes of the same image.</span></li>
<li><span style="line-height: 19px;">Screen density is not the only screen parameter that we need to be concerned about.</span></li>
</ol>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">Let's talk about the second point. What if we want to create a splash screen with a large logo for our application? A 200 by 200 pixel image works great for a phone with an mdpi screen. That means it will look great on a tablet with an mdpi screen too, right? Well, the image will look great, but it will not fill an equal area of the screen as it does on the phone.</span></div>
<div>
<br /></div>
<div>
The above point makes it clear that taking the physical size of a screen into account is important when thinking about image resources. Android makes this possible with additional suffixes for resource drawables: -sw320dp, -sw360dp, -sw480dp, -sw600dp, -sw720dp, and others. In fact, any number can go between "sw" and "dp". The letters "sw" mean "smallest width" while the letters "dp" mean density-independent pixels. A density-independent pixel will always be the same physical size no matter the density of the screen, e.g. 13 dp on a ldpi screen is the same physical size as 13 dp on a xxhdpi screen. "sw360dp" means that the resources in this directory will be supported by devices with a screen that is at least 360 density-independent pixels wide. Larger, newer generation phones generally fall into this category. Resources in the "sw480dp" directory can be used by the largest phones, such as the Samsung Galaxy Note. "sw600dp" is for 7-inch tablets. "sw720dp" is for 10-inch tablets. I picked this particular set of "smallest-width" constraints in order to support Android devices of pretty much all sizes. The ratios for 320:360:480:600:720 can be simplified down to 8:9:12:15:18.</div>
<div>
<br /></div>
<div>
Android allows us to have resource directories with names such as "drawable-sw720dp-xxhdpi". That's right - we can refer to density and size at the same time! Let's combine the ratios for density and screen size. We will choose "1" for the value of a sw320dp-mdpi screen. It will serve as our point of reference.</div>
<div>
<br /></div>
<div>
<table cellpadding="0" cellspacing="0" dir="ltr" style="font-family: arial,sans,sans-serif; font-size: 13px; table-layout: fixed;"><colgroup><col width="120"></col><col width="120"></col><col width="120"></col><col width="120"></col><col width="120"></col><col width="120"></col></colgroup><tbody>
<tr style="height: 17px;"><td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000; padding: 0 3px; vertical-align: bottom;"></td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(0, 0, 0); border-top-style: solid; border-top-width: 1px; font-weight: bold; padding: 0px 3px; text-align: center; vertical-align: bottom;">sw320dp (8)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(0, 0, 0); border-top-style: solid; border-top-width: 1px; font-weight: bold; padding: 0px 3px; text-align: center; vertical-align: bottom;">sw360dp (9)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(0, 0, 0); border-top-style: solid; border-top-width: 1px; font-weight: bold; padding: 0px 3px; text-align: center; vertical-align: bottom;">sw480dp (12)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(0, 0, 0); border-top-style: solid; border-top-width: 1px; font-weight: bold; padding: 0px 3px; text-align: center; vertical-align: bottom;">sw600dp (15)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(0, 0, 0); border-top-style: solid; border-top-width: 1px; font-weight: bold; padding: 0px 3px; text-align: center; vertical-align: bottom;">sw720dp (18)</td></tr>
<tr style="height: 17px;"><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; direction: ltr; font-weight: bold; padding: 0px 3px; text-align: right; vertical-align: bottom;">ldpi (3)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">0.75</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">0.84375</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.125</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.40625</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.6875</td></tr>
<tr style="height: 17px;"><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; direction: ltr; font-weight: bold; padding: 0px 3px; text-align: right; vertical-align: bottom;">mdpi (4)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.125</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.5</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.875</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">2.25</td></tr>
<tr style="height: 17px;"><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; direction: ltr; font-weight: bold; padding: 0px 3px; text-align: right; vertical-align: bottom;">hdpi (6)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.5</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">1.6875</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">2.25</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">2.8125</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">3.375</td></tr>
<tr style="height: 17px;"><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; direction: ltr; font-weight: bold; padding: 0px 3px; text-align: right; vertical-align: bottom;">xhdpi (8)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">2</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">2.25</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">3</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">3.75</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">4.5</td></tr>
<tr style="height: 17px;"><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; direction: ltr; font-weight: bold; padding: 0px 3px; text-align: right; vertical-align: bottom;">xxhdpi (12)</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">3</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">3.375</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">4.5</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">5.625</td><td style="border-bottom-color: rgb(0, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-right-color: rgb(0, 0, 0); border-right-style: solid; border-right-width: 1px; padding: 0px 3px; text-align: center; vertical-align: bottom;">6.75</td></tr>
</tbody></table>
</div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">Awesome! We now have a way to know how to make an image take up an equal amount of space on a small screen and a large screen across multiple screen pixel densities. Let's go through a simple example. We have a 200 by 200 pixel logo that looks great on a mdpi phone with a small screen. How do we make the same logo take up a relatively same amount of space on a 10-inch tablet with hdpi pixel density? Let's find it in the table - row hdpi and column sw720dp. The value is 3.375. Thus, the logo should be around 200 x 3.375 by 200 x 3.375, or 675 by 675 pixels.</span></div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">But wait, you might say, this seems to be making things more complicated! We went from having to generate image resources for just various pixel densities to also having to support multiple screen sizes. Now we have to make 25 images! Who would want to spend the tedious hours doing this? No one. And no one has to, if a certain type of image is used - a vector image.</span></div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">Vector images are great, because they can be resized to any size without quality loss. We can take a vector image that is originally 100 by 100 pixels in size, make it 10,000 by 10,000 pixels, and it'll look just as smooth and not pixelated. I reckoned that if we start from a vector image, we can use a few tools to generate PNG images in all of the sizes we need.</span></div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">This is how <a href="https://github.com/YEDev/easyassets">easyassets</a> was born. It uses three libraries - <a href="https://wiki.gnome.org/LibRsvg">librsvg</a>, <a href="http://www.imagemagick.org/script/index.php">imagemagick</a>, and <a href="http://pngquant.org/">pngquant</a> to convert SVG images to PNG images in multiple sizes, and then trim unneeded blank space around the image. The script uses a hash map version of the above table to generate image resources and automatically place them into appropriate drawable directories. All you have to do is provide the SVG originals in a size that is expected to be used on a sw320dp-mdpi screen, run the tool, and you will have and you will have a set of directories with the PNGs you need. These directories can be pasted into the "res" directory of your project. Please see easyassets' <a href="https://github.com/YEDev/easyassets">GitHub page</a> for installation and usage instructions.</span></div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">I recommend starting with a 320 by 480 pixel canvas for each vector image, and drawing vectors in a place where you would like them to appear on the screen. Providing this SVG to the script will give you the perfect sized PNGs for all the screens you would like to support. Of course, there is a downside - having this many images will increase the size of your APK file by quite a bit. My application has 7 images and its file size went up from 3.6 megabytes to 9.6 when I switched from 5 sizes for each image to 25. However, this may not be a too-heavy price to pay for having a perfect image for every screen.</span></div>
<div>
<span style="line-height: 19px;"><br /></span></div>
<div>
<span style="line-height: 19px;">Hopefully you can find this useful! Please feel free to ask questions or make comments about my approach and the easyassets tool either on this post or on the <a href="https://github.com/YEDev/easyassets">GitHub page</a>.</span></div>
<ul>
</ul>
</div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com2tag:blogger.com,1999:blog-7257946298680318037.post-59211219635614957032013-03-24T21:46:00.001-07:002013-06-19T11:08:45.008-07:00Proposal for a Bill Splitter Programming Kata<br />
<div style="text-align: justify;">
You may have noticed that I mentioned several programming exercises, or <a href="http://en.wikipedia.org/wiki/Kata_(programming)" target="_blank">katas</a>, within this blog. I practiced these katas several times to improve my skills as a programmer and work on some of my weaknesses. Over the last week, I have been thinking about a potential project I could work on outside of my full time job. Instead, I came up with an idea for a new programming kata:<br />
<br />
<h4>
Bill Splitter Kata</h4>
<div>
<ol>
<li>Part 1: A group of friends has a small issue. They eat out a lot together. However, splitting the bill at the end of the meal always takes a long time and, in the end, some folks end up overpaying, while others get away with not paying their fair share. The group has asked you to develop a small application that would allow them to split the bill fairly. One person will be appointed to use the application at the end of every meal to enter the bill's data and read off the results to the rest of the group.</li>
<ul>
<li>A function header you can use:</li>
<ul>
<li><b style="font-family: 'Courier New', Courier, monospace;"><span style="font-size: 10px;">[]splitTheBill(foodCost, tax, tipPercent, []foodCostPerPerson)</span></b></li>
</ul>
<li><span style="font-family: inherit;">Sample</span></li>
<ul>
<li><span style="font-family: inherit;">input: </span><span style="font-family: Courier New, Courier, monospace; font-size: 10px; font-weight: bold;">splitTheBill(100, 10, 20, 30, 10, 45, 15)</span></li>
<li>output: <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b>39 13 58.5 19.5</b></span></li>
<li><b><span style="font-weight: normal;"><span style="font-family: inherit;">Note: the nth value in the output is the amount of money owed by the nth person in the input</span></span></b></li>
</ul>
</ul>
<li>Part 2: the group really likes your progress in part 1, but finds the implementation lacking in features. A member suggests that the application should include lazy calculation. She suggests that for every person whose food cost is entered as 0, the remaining bill shall be split evenly. Implement this functionality.</li>
<ul>
<li>input: <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b>splitTheBill(100, 10, 20, 0, 0, 45, 0)</b></span></li>
<li>output: <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b>23.83 23.83 58.5 23.83</b></span></li>
</ul>
<li>Part 3: the group was using the application to split their bill at a restaurant. However, some of the members did not carry any change and did not want to use a credit card to pay for their food. Add an option for rounding each person's share to the nearest dollar, while still covering the bill.</li>
<ul>
<li>header: <b style="font-family: 'Courier New', Courier, monospace;"><span style="font-size: 10px;">[]splitTheBill(foodCost, tax, tipPercent, round, []foodCostPerPerson)</span></b></li>
<li>input: <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b><b>splitTheBill(</b>100, 10, 20, true, 0, 0, 45, 0)</b></span></li>
<li>output: <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b>29 29 58 29</b></span></li>
<li>Note: make sure that those who are paying for an equal amount of the bill end up paying the correct amount. i.e., <span style="font-family: Courier New, Courier, monospace; font-size: 10px;"><b>29 28 59 29</b></span> would not be a correct output for the sample input, even though the bill is fully covered</li>
</ul>
</ol>
<div>
<br /></div>
<div>
Feel free to use any programming language.<br />
<br />
<b><span style="font-size: large;">03/26/2013 Update:</span></b><br />
<br />
The kata has been updated to be easier to read.<br />
<br />
<b><span style="font-size: large;">03/26/2013 Update:</span></b><br />
<br />
I have completed the kata. Parts 1 and 2 took me under an hour total. Part 3 took me over two hours. I believe that each part can be handled in many different ways. I ended up writing a lot of helper functions for the third part. Test driven and test first development could be of big help in this situation. If you have tried the kata as well, please post your experiences in the comments section.</div>
</div>
</div>
<div style="text-align: justify;">
</div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-44330693273239412172013-02-02T20:28:00.003-08:002013-06-19T11:11:19.610-07:00Highcharts legend woes - tooltips and data labels<b style="text-align: justify;"><span style="font-size: large;">Please don't forget to view the update at the bottom of this post.</span></b><br />
<div style="text-align: justify;">
<br />
I was recently introduced to a Javascript graphing library called <a href="http://www.highcharts.com/" target="_blank">Highcharts</a>. It's a wonderful tool for anyone who would like to embed a chart into a web page. However, it does not come without some quirks. For example, while there is a way to catch a click event on a legend entry, there is not an easy way to intercept a hover event. I ran into this problem while working on a column chart that would display data labels whenever a legend item is hovered over and keep them hidden otherwise. This issue was solved by using some jQuery trickery. A hover listener was added to the <span style="font-family: Courier New, Courier, monospace;">highcharts-legend-item</span> class. The data labels option would be enabled for the every column, or "point", in the chart series whose legend item is being hovered over and hidden for all other series.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbCakWMMdI3VzldS2CKEZFnFe2O6XJ-8HTcSmE47_Elkk5te-qEduYae8_Zhothh0XmzH2UH4sl1Gth6N6CIDIDTMTo7BLQB5qo4zlZXQ7VgCCjCB_aJV4lSKRy0xiJl7QJmwDFfJ1CTc/s1600/legend.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbCakWMMdI3VzldS2CKEZFnFe2O6XJ-8HTcSmE47_Elkk5te-qEduYae8_Zhothh0XmzH2UH4sl1Gth6N6CIDIDTMTo7BLQB5qo4zlZXQ7VgCCjCB_aJV4lSKRy0xiJl7QJmwDFfJ1CTc/s400/legend.png" width="400" /></a></div>
<br />
This led me to another problem: what if the user wanted to see a data label for a single column? Enabling tooltips seemed to be the right answer. Fortunately for many, but unfortunately for me, tooltips and data labels are handled separately by Highcharts. This means that their positions are controlled by separate functions and their styles are individually set. A quick search told me that I can define a <span style="font-family: Courier New, Courier, monospace;">positioner</span> function for the tooltip. The function must return the position where the tooltip would be placed. By using some information about the column being hovered over, I was able to calculate the appropriate position for the placement of tooltip above the hovered column. This position would match the placement of the data labels that would appear when the legend items are hovered over.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXzWJU-lfl_ymbZmJoVOtI13BET8arEsfH7P__v2lk6Cz8iMu1vvvp__ha9wxXaqbLdRBIXiPYiz4efqyAbwD_RgIBR0wymQurwYBzZ2GjeFhWTUSajNS3L35QuGLT4OsI7jG4UBsstgI/s1600/column.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXzWJU-lfl_ymbZmJoVOtI13BET8arEsfH7P__v2lk6Cz8iMu1vvvp__ha9wxXaqbLdRBIXiPYiz4efqyAbwD_RgIBR0wymQurwYBzZ2GjeFhWTUSajNS3L35QuGLT4OsI7jG4UBsstgI/s400/column.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Why not simply enable a single data label for a column hover event and disable the rest? Each Highchart has a single tooltip object. As the user moves the mouse pointer between different columns, the tooltip smoothly follows. Using data labels for this application would cause the tooltip to jump. Furthermore, due to the need to iterate through every data label and tell it whether it should be enabled or disabled causes performance issues that would cause the data label posing as a tooltip to show up rather slow, taking away from the smooth user experience of Highcharts.</div>
<br />
For my work, please see <a href="http://jsfiddle.net/D3XBY/2/" target="_blank">this jsFiddle</a>.<br />
<br />
<b><span style="font-size: large;">02/04/2013 Update:</span></b><br />
<br />
Due to performance issues, I have decided to leave data labels behind and solve my problem using tooltips. Since Highcharts come with a single tooltip element, I ended up simply iterating over every data point in a series, forcing the tooltip to come up via the hover event, and copying the tooltip element to persist it. Surprisingly, the visible performance of this technique was much quicker than using data labels. Please check out the latest jsFiddle <a href="http://jsfiddle.net/D3XBY/3/" target="_blank">here</a>. I am very happy with the outcome, as this method allows a single point of control for the styling and positioning of the tooltips/data labels.<br />
<br />
<b><span style="font-size: large;">06/18/2013 Update:</span></b><br />
<br />
It appears that the code no longer functions as intended as of Highcharts version 3.0. I updated the jsFiddle to use Highcharts 2.3.5. See it <a href="http://jsfiddle.net/D3XBY/6/" target="_blank">here</a>. I am sure the code can be modified to work with the latest version.</div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-78192248731520725462012-09-04T21:57:00.002-07:002012-09-25T22:35:32.472-07:00Android Room Manager<br />
<div style="text-align: justify;">
During my year as a Graduate Assistant at Carnegie Mellon University, Silicon Valley, I worked on an Android tablet application, Android Room Manager, which allowed students and staff to quickly reserve meeting rooms at the university. This post contains some screenshots from the application, which can be seen running on Android 3.0 (Honeycomb). I will make future posts outlining how the app was developed completely from scratch.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNKh4avNx3ootTSVUmZTiJxeFvWEKhmjpurMASORAH2SEIZppX4zPXTkFu7nqk4YvAYS7UM-I6goA4V0QMZ9PeGvLrz_Lmp6o_3Pj8gjq2jzv5lkmxfBeLN2lETfgc7-g9bhC8LPcbrNs/s1600/3_ARM_MainActivity_CMUSV.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNKh4avNx3ootTSVUmZTiJxeFvWEKhmjpurMASORAH2SEIZppX4zPXTkFu7nqk4YvAYS7UM-I6goA4V0QMZ9PeGvLrz_Lmp6o_3Pj8gjq2jzv5lkmxfBeLN2lETfgc7-g9bhC8LPcbrNs/s400/3_ARM_MainActivity_CMUSV.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4af4nv3keZcp72re6OYNcx5xl9PFMaD7mnqkNciZ9cHUSoyOsP_O-4DggAwFzwthRGAby7vJSUH0PMhLV-NklnPifYe0-1B1ORInHR0XaTbDz04KQ4Se4xrnxjIDPljbq-042UgvGx9g/s1600/7_ARM_ReserveRoomActivity.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4af4nv3keZcp72re6OYNcx5xl9PFMaD7mnqkNciZ9cHUSoyOsP_O-4DggAwFzwthRGAby7vJSUH0PMhLV-NklnPifYe0-1B1ORInHR0XaTbDz04KQ4Se4xrnxjIDPljbq-042UgvGx9g/s400/7_ARM_ReserveRoomActivity.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOFBctaBNUO3b7278asVGp3AMP9iQ1SeV0yLjjDQ1vcnhr1d3DuS_Fe9U90GoWUH_xkVZ2eyRPQFBHnca9xbY8QxNPArjgcPLjWJ600a2VlL0dAImdmcfRmQ82A9PUQV_2ErviQHk1iL0/s1600/11_ARM_ReserveRoomActivity_ReservedRoom.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOFBctaBNUO3b7278asVGp3AMP9iQ1SeV0yLjjDQ1vcnhr1d3DuS_Fe9U90GoWUH_xkVZ2eyRPQFBHnca9xbY8QxNPArjgcPLjWJ600a2VlL0dAImdmcfRmQ82A9PUQV_2ErviQHk1iL0/s400/11_ARM_ReserveRoomActivity_ReservedRoom.png" width="400" /></a></div>
<br /></div>
<div style="text-align: justify;">
</div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com56tag:blogger.com,1999:blog-7257946298680318037.post-9885279183888314512012-08-09T01:55:00.001-07:002013-02-26T11:10:58.872-08:00WordLord - Now Available!<div style="text-align: justify;">
Project WordLord</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
WordLord: Guess the Word - Become a Lord!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
WordLord is a party word-guessing game for 4+ players.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Download the free demo <a href="https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord_demo" target="_blank">here</a>:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/img.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/img.png" width="200" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Download the full version <a href="https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord" target="_blank">here</a>:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/img%20(1).png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/img%20(1).png" width="200" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Download from Amazon Appstore <a href="http://www.amazon.com/Borys-Boyko-WordLord/dp/B008QTR0IW" target="_blank">here</a>.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-1549383462943440222012-08-01T19:09:00.000-07:002012-08-09T01:52:16.506-07:00Smartphone Development - Week 12 - Project WordLord<div style="text-align: justify;">
My plan for the future:</div>
<div style="text-align: justify;">
<ul>
<li>The game's initial reception did not go as expected. There has been under 10 downloads of the demo version and just 1 download of the paid version. My goal was to make back the Google Play store publisher fee of $25. Hopefully, the application will help me to achieve this goal in the long run.</li>
<li>I would like to implement different game modes and include additional features.</li>
<li>I would like to create a website for WordLord where users can share custom word lists. The word lists can be upvoted or downvoted, with the most popular lists displayed first. The website would allow users of the full version of WordLord to easily find word lists to expand the game with.</li>
<li>I would like to collect more feedback from the user base. Perhaps this would explain why the game's launch was not as successful as anticipated.</li>
<li>I would like to advertise the application on more websites and perhaps on campus of my university.</li>
<li>Should the paid version fail, I will release an ad-supported version.</li>
</ul>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have made a new video to showcase WordLord. It is shorter than the old one. The video is available here: <a href="http://www.youtube.com/watch?v=AMPFWh5VJ_E">http://www.youtube.com/watch?v=AMPFWh5VJ_E</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
WordLord is now available on the Amazon Appstore: <a href="http://www.amazon.com/Borys-Boyko-WordLord/dp/B008QTR0IW">http://www.amazon.com/Borys-Boyko-WordLord/dp/B008QTR0IW</a></div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-11636307970652718182012-07-24T00:30:00.000-07:002012-08-09T01:57:53.679-07:00Smartphone Development - Week 11 - Project WordLord<div style="text-align: justify;">
This week, I have published WordLord to the Google Play Store.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Free Demo:</div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord_demo">https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord_demo</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Full Version ($1.99):</div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord">https://play.google.com/store/apps/details?id=edu.cmu.sv.bboyko.wordlord</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have also made a couple of posts on Reddit:</div>
<div style="text-align: justify;">
<a href="http://www.reddit.com/r/gaming/comments/xgpwd/finally_released_my_first_android_application_a/">http://www.reddit.com/r/gaming/comments/xgpwd/finally_released_my_first_android_application_a/</a></div>
<div style="text-align: justify;">
<a href="http://www.reddit.com/r/Android/comments/rdfdn/megapost_of_all_apps_created_by_randroid/c5m9jir">http://www.reddit.com/r/Android/comments/rdfdn/megapost_of_all_apps_created_by_randroid/c5m9jir</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have modified the user interface to scale for any screen resolution. This way, the game can be played on all types of Android devices that support landscape mode.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Screenshot of WordLord on a 10.1" tablet running Android Honeycomb 3.2.1:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week11/WL_Tablet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week11/WL_Tablet.png" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Screenshot of WordLord on a 4.3" phone running Android Gingerbread 2.3.3:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week11/WL_Phone.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week11/WL_Phone.png" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Supporting various devices increases the market for the application.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-84520101405261229692012-07-22T18:00:00.000-07:002012-08-09T01:39:31.436-07:00Smartphone Development - Week 10 - Project WordLord<div style="text-align: justify;">
This week, I continued styling the application. The new options screen can be seen below:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week10/WordLord_options.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week10/WordLord_options.png" width="320" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-731710957193295872012-07-11T20:08:00.000-07:002012-08-09T01:41:50.433-07:00Smartphone Development - Week 9 - Project WordLord<div style="text-align: justify;">
This week, I have created an icon for my application:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week9/icon.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week9/icon.png" width="320" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have also created a new user interface:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week9/WL2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week9/WL2.png" width="320" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I will now discuss several items:</div>
<div style="text-align: justify;">
<ol>
<li>Motivation behind the name</li>
<ol>
<li>Not taken</li>
<li>Rolls off the tongue</li>
<li>Fewer than 10 characters in length</li>
<li>States that the game is about words</li>
<li>Sets up the theme for the game</li>
<li>Domain name available</li>
</ol>
<li>Righteous feature set</li>
<ol>
<li>Simple and attractive user interface</li>
<li>Automatic scoring</li>
<li>Plenty of options</li>
<ol>
<li>Round timer</li>
<li>Score limit</li>
<li>Skip counter</li>
<li>Sound and vibration</li>
<li>Shake gesture recognition</li>
</ol>
</ol>
<li>Ways to get to market</li>
<ol>
<li>Release on Google Play Store and Amazon Appstore</li>
<ol>
<li>Advertise on www.reddit.com</li>
<li>Advertise by word of mouth</li>
<li>Create a website</li>
<li>Add support for tablets</li>
<li>Free ad-supported version</li>
</ol>
<li>Sell rights to a game/toy manufacturer</li>
<ol>
<li>Manufacturer handles advertising</li>
</ol>
</ol>
<li>Market analysis</li>
<ol>
<li>Over 200 million Android devices are active</li>
<li>Amazon Appstore users more likely to pay for apps</li>
<ol>
<li>Influence by Kindle Fire users</li>
</ol>
<li>Games dominate top-purchased lists</li>
<li>Over 5,000 purchases of similar apps at $1.99 and over</li>
<ol>
<li>True numbers are not publically available</li>
</ol>
<li>Over 100,000 downloads of similar apps</li>
</ol>
<li>Value of market testing</li>
<ol>
<li>Tested within my own demographic</li>
<li>Could be beneficial to test within other demographics</li>
<li>Would like to learn which word categories are most desired</li>
</ol>
<li>What I need to know</li>
<ol>
<li>How to style PreferenceActivity</li>
<li>How to style AlertDialog</li>
<li>How to release on Google Play Store</li>
<li>How to release on Amazon Appstore</li>
<li>How to go about contacting game manufacturers to see whether they would like to purchase the rights to the application</li>
</ol>
</ol>
</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-25159787147186548162012-07-05T18:49:00.000-07:002013-11-12T21:22:43.275-08:00Smartphone Development - Week 8 - Project WordLord<div style="text-align: justify;">
I have added the ability to play with custom word lists within WordLord. Users can simply deposit lists of words to the <external storage>/WordLord/ directory on their Android device and play with any words or phrases that they would like. The desired word lists can be selected when a game is started:</div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week8/device-2012-07-08-015933.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://f312963c-a-ee27b73d-s-sites.googlegroups.com/a/west.cmu.edu/summer-2012-smartphone/projects/borys-boyko-project-status/week8/device-2012-07-08-015933.png" width="320" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I have also added the ability for the developer (me) to easily add additional word lists to the game's .APK file. These word lists can be released in future updates of the game.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Next, I have done some some research on user interfaces of games similar to Hasbro Inc.'s Electronic Catch Phrase ™. Below are some screenshots:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://zachswee.com/wp-content/uploads/2012/07/HG05712lg.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://zachswee.com/wp-content/uploads/2012/07/HG05712lg.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The original game</td></tr>
</tbody></table>
<div style="text-align: center;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737025729/projects/borys-boyko-project-status/week8/phonefraze.png?height=266&width=400" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="213" src="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737025729/projects/borys-boyko-project-status/week8/phonefraze.png?height=266&width=400" width="320" /></a></td></tr>
<tr><td class="tr-caption">PhoneFraze (11,000 - 55,000 downloads, including 1,000 - 5,000 paid downloads at $3.99) </td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737054983/projects/borys-boyko-project-status/week8/phraseparty.png?height=239&width=400" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="191" src="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737054983/projects/borys-boyko-project-status/week8/phraseparty.png?height=239&width=400" width="320" /></a></td></tr>
<tr><td class="tr-caption">Phrase Party! (51,000 - 105,000 downloads, including 1,000 - 5,000 paid downloads at $1.99) </td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737084538/projects/borys-boyko-project-status/week8/buzzwordfrenzy.png?height=265&width=400" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="212" src="https://sites.google.com/a/west.cmu.edu/summer-2012-smartphone/_/rsrc/1341737084538/projects/borys-boyko-project-status/week8/buzzwordfrenzy.png?height=265&width=400" width="320" /></a></td></tr>
<tr><td class="tr-caption">Buzzword Frenzy (unknown amount of downloads)</td></tr>
</tbody></table>
<div>
<span style="background-color: white; font-family: georgia, serif; font-size: 13px; line-height: 19px;"><br /></span></div>
<div style="text-align: justify;">
Out of all the games, the latter (Buzzword Frenzy) seems to have the best user interface. However, Buzzword Frenzy is an iPhone game. I would like to mimic its sleekness in my application, perhaps in a simpler way. I believe that I can use 9-patch PNG images in order to create the sleek interface that elegantly frames its elements. Thus, I will have to perform some research in this area. I also enjoyed the game's website, <a href="http://www.buzzwordfrenzy.com/">http://www.buzzwordfrenzy.com</a>. Should I make a website for WordLord, I can refer to Buzzword Frenzy's page for inspiration.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sources for UI images:</div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=com.dev.games.ipartylite&hl=en">https://play.google.com/store/apps/details?id=com.dev.games.ipartylite&hl=en</a></div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=com.dev.games.ipartylite&hl=en">https://play.google.com/store/apps/details?id=theandroidworks.apps.PhoneFrazeLite&hl=en</a></div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=com.dev.games.ipartylite&hl=en">http://www.buzzwordfrenzy.com/</a></div>
<div style="text-align: justify;">
<a href="https://play.google.com/store/apps/details?id=com.dev.games.ipartylite&hl=en">http://www.gamenightapproved.com/game.aspx?gameid=6</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Below are some notes I took regarding the UI topic for WordLord:</div>
<div>
<ul>
<li>What is an appropriate frame for UI?</li>
<li>Metal, wood, desk-like?</li>
<li>Frills?</li>
<li>Simple?</li>
<li>Should the game have a shadow?</li>
<li>Paper that's tearing?</li>
<li>Font choice for current word - is there anything better?</li>
<li>Timer - put in frame?</li>
<li>Application name - how to make it cool looking?</li>
<li>Celebrate the current word</li>
</ul>
<div style="text-align: justify;">
<br />
I have set a goal that I would like to achieve by the end of the Smartphone Development II class - place WordLord on the Google Play store. I plan to charge $1.99 for the full version of the game. I may create a demo with a word list of around 900 words. I believe that WordLord has a nice set of features and options that differentiates it from the currently available Catch-Phrase-like games. For example, no game uses the device's sensors to accept the shake gesture and no game keeps score automatically.</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I should not run into any copyright-related problems. According to <a href="http://www.copyright.gov/fls/fl108.html">FL-108</a>, "copyright does not protect the idea for a game, its name or title, or the method or methods for playing it. Nor does copyright protect any idea, system, method, device, or trademark material involved in developing, merchandising, or playing a game."</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Research - not much of it exists on the topic of word guessing games. I do not believe that research of papers dealing with word guessing games will affect the outcome of my project. It would be more useful for me to have groups of people try each of the Catch-Phrase-like applications, including WordLord, and tell me what they like or dislike about them. This sort of feedback can help me differentiate my application in a positive manner and create a successful game that many want to play.</div>
BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-37722105430773207682012-07-05T18:47:00.000-07:002012-08-09T01:21:23.188-07:00Smartphone Development - Week 7 - Project WordLord<div style="text-align: justify;">
This week I have implemented the full options list for the application. All of the options are now fully functional. I have asked seven of my friends to play-test the application. They have found a few issues. One issue is that the user interface is not as nice as it could be for a game of this caliber. Another is that the timer is sometimes buggy when the application is paused.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
After fixing the bugs, I will implement custom word lists. Once this is complete, I will be able to finish the application by reworking the user interface.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-15112823607021077632012-06-26T02:00:00.000-07:002012-08-09T01:20:06.809-07:00Smartphone Development - Week 6 - Project WordLord<div style="text-align: justify;">
This week, I tested WordLord with my team from a different course. The feedback has been positive. We found several bugs for me to fix. I have also created a demo video for WordLord and posted it on YouTube. It is available here: <a href="http://www.youtube.com/watch?v=dnw-sPYOXEM">http://www.youtube.com/watch?v=dnw-sPYOXEM</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I am going to keep the application in its current state for the rest of the week. Remaining and additional features will be added in the second Smartphone Development course.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
EDIT: I have tested the WordLord application on a tablet device running Android Honeycomb (v. 3.2). The game looked and worked just fine. I may need to work on a better layout for tablets in the future.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
EDIT 2: I have enabled all of the options currently present in the game. I now have to add the ability to edit team scores, as well as add functionality for customizing word lists.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-9249741849188322482012-06-21T18:13:00.000-07:002012-08-09T01:18:30.008-07:00Smartphone Development - Week 5 - Project WordLord<div style="text-align: justify;">
The basic part of WordLord is now complete. My next goal is to work on the options of the application, which will differentiate it from its competitors. A screenshot of the application in its current state appears below:</div>
<div style="text-align: justify;">
<span style="background-color: white; font-family: georgia, serif; font-size: 13px; line-height: 19px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.imgur.com/UqTb0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" src="http://i.imgur.com/UqTb0.png" width="400" /></a></div>
<div style="text-align: justify;">
<span style="background-color: white; font-family: georgia, serif; font-size: 13px; line-height: 19px;"><br /></span></div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-38715734223678606702012-06-17T22:45:00.000-07:002012-08-09T01:14:37.595-07:00Smartphone Development - Week 4 - Project WordLord<div style="text-align: justify;">
I have added a few features to WordLord, including one that pauses the game if the home button is pressed, or if a phone call is received. The game can be resumed from the same point. I have also found a review of a competitor's application, <a href="http://androidforums.com/game-reviews/97336-phonefraze-pro-social-game-android-market.html">PhoneFraze</a>. My long-run goal is to make my application have more/better features than PhoneFraze, as well as create a sleeker user interface. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
EDIT: I am now around 60% done with the user interface. I will spend the rest of the week working on it, as well as adding options and features to the game.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-87663078719481332252012-06-07T23:04:00.000-07:002012-08-09T01:08:48.459-07:00Smartphone Development - Week 3 - Project WordLord<div style="text-align: justify;">
I have decided to go with the word game idea and came up with a name for the application - WordLord. I have come up with a basic UI layout, as well as a state machine. These items will be used as reference while coding the application. Speaking of coding, the development of the application is in full swing. The game is now "playable" - no words are generated, but a placeholder function serves a different word every time the button "Next" is pressed, or the device is shook. My next step is to work on the dictionary and the game options.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
EDIT: I have now completed the first version of the dictionary. In order to randomize the words, I made two lists. When a word is served, it is moved to the second list. When the first list runs out of words, the words from the second list get moved back to the first. The index of the chosen word is randomly generated. Every time the list is traveled through, the order of the words will change. Thus, the same word should not pop up often. The dictionary currently contains over 900 words, which should satisfy a play session of over an hour.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-33836255378057884872012-05-29T10:49:00.000-07:002012-09-05T19:42:54.181-07:00Smartphone Development<div style="text-align: justify;">
I have recently enrolled in an introductory smartphone development course at my university. From this point on, the blog will focus on my progress within the course. The professor required me to come up with several ideas for android applications. Below are my ideas.</div>
<br />
<b><span style="font-size: large;">Catchphrase-like Game with a Custom Dictionary</span></b><br />
<ol>
<li style="text-align: justify;"><b>Purpose:</b> create a game similar to Catchphrase. The game will have a settings mode that would allow users to add their own words and phrases to the dictionary that will be used by the game.</li>
<li style="text-align: justify;"><b>Market analysis:</b> PhoneFraze is an application that has a similar goal. However, there are several issues with it. For example, users complain that it repeats the same words within a round of play - something that should never happen in such a game. Should I make the application, I would allow the word list to be expanded, so that users do not have to keep playing with the same set of words.</li>
<li style="text-align: justify;"><b>Initial development plan:</b></li>
<ol>
<li style="text-align: justify;">Create a simple UI layout with all of the elements required for the game</li>
<li style="text-align: justify;">Determine which data structure would be best for storing the dictionary</li>
<li style="text-align: justify;">Determine how to randomly pick a word</li>
<li style="text-align: justify;">Determine how to keep score</li>
<li style="text-align: justify;">Implement a countdown timer</li>
<li style="text-align: justify;">Implement a buzzer mode (to be used on others' phones in the case that the player states one of the words that they are having their teammates guess)</li>
<li style="text-align: justify;">Improve the UI</li>
</ol>
</ol>
<br />
<b><span style="font-size: large;">Effort Log Editor for My University</span></b><br />
<ol>
<li style="text-align: justify;"><b>Purpose:</b> allow a user to log into the university account and edit effort logs on a smartphone within a visually appealing interface.</li>
<li style="text-align: justify;"><b>Market analysis:</b> no such application exists - students currently must use a mobile browser in order to access the sluggish effort log interface. A mobile application would be useful to any student with an Android phone at the university.</li>
<li style="text-align: justify;"><b>Initial development plan:</b></li>
<ol>
<li style="text-align: justify;">Find out whether the application is viable (need to see whether can log into university accounts using Android account manager; need to see whether can get access to the university's website) </li>
<li style="text-align: justify;">If the application is found to be viable, work on a visually appealing UI</li>
<li style="text-align: justify;">Implement functionality to add courses</li>
<li style="text-align: justify;">Implement functionality to select effort types</li>
<li style="text-align: justify;">Implement functionality to input effort for logging</li>
<li style="text-align: justify;">Implement functionality for viewing previously logged effort from past weeks</li>
<li style="text-align: justify;">Implement functionality for adding up the total effort for a particular course, effort type, semester, or school year and displaying the amount to the user</li>
</ol>
</ol>
<br />
<b><span style="font-size: large;">Spreadsheet Editor</span></b><br />
<ol>
<li style="text-align: justify;"><b>Purpose:</b> create a simple spreadsheet application for quick data organization and calculations. If there is time, expand the application to allow visual representation of data via graphs.</li>
<li style="text-align: justify;"><b>Market analysis:</b> there are many spreadsheet applications available in the Google Play store. However, most of them are intended to work with Excel file formats. Many of the top rated applications cost money. There is a free spreadsheet application, Simple Spreadsheet (free/ads), but users have been reporting lack of functionality, such as the inability to compute 4 or more cells together.</li>
<li style="text-align: justify;"><b>Initial development plan:</b></li>
<ol>
<li style="text-align: justify;">Look for open source spreadsheet calculation code</li>
<li style="text-align: justify;">Determine how to use data structures appropriately for storing spreadsheet data</li>
<li style="text-align: justify;">Create a visual layout for a spreadsheet application</li>
<li style="text-align: justify;">Combine the calculation code with the visual layout</li>
<li style="text-align: justify;">Work on advanced functionality, such as adding all values in a given row or column</li>
<li style="text-align: justify;">If there is time, add graphing capabilities</li>
</ol>
</ol>
<br />
<b><span style="font-size: large;">Friend Scheduler</span></b><br />
<ol>
<li style="text-align: justify;"><b>Purpose:</b> I have had experiences with many instances in which my friends and I agree to meet somewhere at a particular time. Unfortunately, someone always ends up being late because they underestimated how long it will take them to get to our meeting location. I would like to create an application that will tell the users when to head out from their current location to make sure that they arrive at the meeting place just on time.</li>
<li style="text-align: justify;"><b>Market analysis:</b> I was able to find a similar application in the Google Play store - saambaa. The application allows users to create events and share them with their friends, as well as get directions to their meeting location. However, it does not provide functionality for telling the users when they should be leaving for the meeting location.</li>
<li style="text-align: justify;"><b>Initial development plan:</b></li>
<ol>
<li style="text-align: justify;">Determine how to obtain the current GPS coordinates of a user's phone</li>
<li style="text-align: justify;">Determine how to query the Google Maps API on Android with a start and end address, as well as obtain the time for the quickest route to the address</li>
<li style="text-align: justify;">Consider other functionalities that may be included, such as allowing the user to specify additional stops and the time for such stops (e.g., in cases where a person may be offering a ride to a friend)</li>
<li style="text-align: justify;">Consider including group text messaging/communication functionality, such that a planned destination on one phone can be sent to the phone's user's chosen contacts</li>
</ol>
</ol>
<br />
<b><span style="font-size: large;">Multi-timer</span></b><br />
<ol>
<li style="text-align: justify;"><b>Purpose:</b> allow users to keep track of multiple timers and/or stopwatches at the same time. The timers will be displayed on one page and will turn different colors when the time runs out, so that it is easy for the user to see which of the timers has expired. The timers will be allowed to have a short description label for easy tracking by the user.</li>
<li style="text-align: justify;"><b>Market analysis:</b> there are hundreds of applications available on the Play Store that offer the functionality of both stopwatches and timers. However, there does not seem to be an abundance of applications that allow running multiple timers or stopwatches at the same time. A multi-timer application would be very useful to many. It was requested of me by a graduate physics student who would like to use it in his physics lab.</li>
<li style="text-align: justify;"><b>Initial development plan:</b></li>
<ol>
<li style="text-align: justify;">Determine whether it is possible to run multiple timers at the same time in one application</li>
<li style="text-align: justify;">Learn how to make a simple timer application</li>
<li style="text-align: justify;">Learn how to make a simple stopwatch application</li>
<li style="text-align: justify;">Create an application that allows the user to create multiple timers, each of which can be started and stopped independently</li>
</ol>
</ol>
<div>
<div style="text-align: justify;">
<span style="font-family: georgia, serif; font-size: x-small;"><span style="line-height: 19px;"><br /></span></span></div>
</div>
I will choose one of the ideas above and work on the chosen project throughout my last semester.BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-37360499796564467882012-04-29T22:16:00.000-07:002012-04-29T22:16:48.927-07:00Bowling Game Kata<br />
<span style="text-align: justify;">Today, I have completed the </span><a href="https://docs.google.com/viewer?a=v&q=cache:Ysvza_kdlEgJ:butunclebob.com/files/downloads/Bowling%2520Game%2520Kata.ppt+&hl=en&gl=us&pid=bl&srcid=ADGEESh3W5lVfXqFWA3iOMDhIRth1NLRoqo5jjYjl4TEIFg7_IixlklyZae3Egi35cJp7-gsn6bJ7R2Lvb2mnK8fmOq2OGuv8VCFGZZLDTJvQrf8UeaY0bcytj3-br7z0rHjY2Rz1IRL&sig=AHIEtbR_RVPmJMyemR-6SqWzIX3hxSzTBA" style="text-align: justify;" target="_blank">Bowling Game Kata</a><span style="text-align: justify;">. Below are my notes:</span><br />
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">It took me three three hours to complete.</li>
<li style="text-align: justify;">I wanted to do this kata because I was interested in learning how scoring of bowling games worked.</li>
<li style="text-align: justify;">The kata ended up very frustrating, because I had to refactor code extremely often.</li>
<li style="text-align: justify;">The problem seemed like a great exercise for TDD.</li>
<li style="text-align: justify;">I was able to see where I was not following DRY principles. It was easy for me to convert non-DRY code to DRY code. I am feeling more confortable with constantly thinking about DRY as I am coding.</li>
</ul>
<div style="text-align: justify;">
<br />
P.S. I would have to say that my level of self-awareness of copying code was IV during this kata. Please see what the levels mean in my <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">learning plan</a>.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-19681542627065639102012-04-25T15:52:00.003-07:002012-04-25T15:52:57.327-07:00Simplifying Time Conversion<div style="text-align: justify;">
Recently I <a href="http://aleakymemory.blogspot.com/2012/04/reinventing-time.html" target="_blank">refactored some old code</a> with a friend. The functions we were writing allowed us to practice both TDD and DRY. We demonstrated the code to our class yesterday and immediately, many constructive comments were offered. It immediately made me feel that I was back to <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">Level I</a>. However, I would like to share what I learned about the Java String.format() function.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is the code my pair programming partner and I came up with for this self-explanatory function:</div>
<div style="text-align: justify;">
<span class="s1"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="s1">public</span> <span class="s1">static</span> String monthDayYearToString(<span class="s1">int</span> month, <span class="s1">int</span> day, <span class="s1">int</span> year) {</span></div>
<div style="text-align: justify;">
</div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> String monthString = Integer.toString(month);</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> String dayString = Integer.toString(day);</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> String yearString = Integer.toString(year);</span></div>
<div class="p4">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> </span></div>
<div class="p4">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> if (month < 10) {</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> monthString = "0" + monthString;</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> }</span></div>
<div class="p4">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> <span class="Apple-tab-span"> </span></span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> if (day < 10) {</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>dayString = "0" + dayString;</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> }</span></div>
<div class="p4">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> <span class="Apple-tab-span"> </span></span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> String formattedDate = monthString + "-" + dayString + "-" + yearString;</span></div>
<div class="p4">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span"></span><span class="Apple-tab-span"></span> return formattedDate;</span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">}</span></div>
<div class="p2">
<br /></div>
<div class="p2">
Here's the refactored code:</div>
<div class="p2">
<span class="s1"><br /></span></div>
<div class="p2">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="s1">public</span> <span class="s1">static</span> String monthDayYearToString(<span class="s1">int</span> month, <span class="s1">int</span> day, <span class="s1">int</span> year) {</span></div>
<div class="p2">
</div>
<div class="p1">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span"></span><span class="Apple-tab-span"></span><span class="s1"> return</span> String.format(<span class="s2">"%02d-%02d-%d"</span>, month, day, year);</span></div>
<div class="p1">
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">}</span></div>
<div class="p1">
<br /></div>
<div class="p1">
Neat! I wonder, what other tricks could save developers like me from writing unnecessary and potentially copied code?</div>
<br />BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-26696439647117462812012-04-25T13:50:00.001-07:002012-04-25T13:50:24.627-07:00Weighing with Stones Kata<span style="text-align: justify;">Today, I have completed the </span><a href="http://craftsmanship.sv.cmu.edu/posts/weighing-with-stones-kata" style="text-align: justify;" target="_blank">Weighing with Stones Kata</a><span style="text-align: justify;">. Below are my notes:</span><br />
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">It took me three two and a half hours to complete.</li>
<li style="text-align: justify;">I first worked out the problem in notepad to find a combination of weights that would satisfy the criteria outlined in the kata.</li>
<li style="text-align: justify;">I took a brute-force approach to development. However, I saved some execution time by forcing one of the weights to have a value of 1. I believe that my execution time was O(n^3), where n is the weight of the initial stone.</li>
</ul>
<div style="text-align: justify;">
<br />
P.S. I would have to say that my level of self-awareness of copying code was III during this kata. Please see what the levels mean in my <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">learning plan</a>.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-6979288797677509752012-04-22T21:42:00.000-07:002012-04-22T21:43:24.150-07:00String Calculator Kata<br />
<div style="text-align: justify;">
Today, I have completed the <a href="http://craftsmanship.sv.cmu.edu/posts/string-calculator" target="_blank">String Calculator Kata</a>. Below are my notes:</div>
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">It took me three hours to complete.</li>
<li style="text-align: justify;">The most time consuming activities involved performing TDD, which the kata description suggested to use, and figuring out how to handle certain regular expressions in Java.</li>
<li style="text-align: justify;">Java requires escaping the ']' character, but does not allow the use of the '\' character to do so. Instead, one must use the java.util.regex.Pattern class. This was a necessity for handling both long and multiple delimiters.</li>
<li style="text-align: justify;">I was able to DRY up some use cases, while keeping them DAMP.</li>
<li style="text-align: justify;">I had trouble employing DRY principles when writing the add() function. It was very unnatural to have to use multiple methods of dealing with regular expressions.</li>
</ul>
<div style="text-align: justify;">
<br />
P.S. I would have to say that my level of self-awareness of copying code was III during this kata. Please see what the levels mean in my <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">learning plan</a>.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-17134675330047099762012-04-17T20:46:00.002-07:002012-04-17T20:46:10.776-07:00Coin Change Kata<div style="text-align: justify;">
Today, I have completed the <a href="http://craftsmanship.sv.cmu.edu/posts/coin-change-kata" target="_blank">Coin Change Kata</a>. Below are my notes:</div>
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">It took me three and a half hours to complete.</li>
<li style="text-align: justify;">I realized that using a greedy algorithm was not best, as choosing the largest possible coin denomination would only work for US coin denominations, but not necessarily others.</li>
<li style="text-align: justify;">It was fun, yet frustrating, to revisit dynamic programming. The last time I wrote a program using dynamic programming was in an algorithms course in my undergraduate university.</li>
<li style="text-align: justify;"><span style="text-align: -webkit-auto;">The way I wrote the code was not modular enough to use TDD to solve the problem. Thus, I had to perform a lot of debugging by manually going through the code line by line. The double for loop did not help.</span> <span style="text-align: -webkit-auto;">Manual testing was very frustrating and took much longer than I expected.</span> <span style="text-align: -webkit-auto;">If I were to redo the kata, I would perhaps write helper functions that could be tested individually.</span></li>
</ul>
<div style="text-align: justify;">
<br />
P.S. I would have to say that my level of self-awareness of copying code was III during this kata. Please see what the levels mean in my <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">learning plan</a>.</div>
<div style="text-align: justify;">
</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-18953347602354563062012-04-17T17:53:00.003-07:002012-04-17T17:53:46.645-07:00"Crappy Code is Other People's Code"<div style="text-align: justify;">
An ex-CMU-SV student posted a <a href="http://video.google.com/videoplay?docid=3217540637672747357" target="_blank">video presentation</a> by Google's <a href="http://www.albertosavoia.com/" target="_blank">Alberto Savoia</a> in CMU-SV's Facebook group. In the presentation, Mr. Savoia speaks about writing "less crappy code". I found watching the short 49-minute video very informative and entertaining.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-76865059366610120722012-04-16T16:59:00.001-07:002012-04-16T17:03:00.942-07:00Mars Rover Kata<div style="text-align: justify;">
Today, I have completed the <a href="http://www.amirrajan.net/Blog/code-katas-mars-rover" target="_blank">Mars Rover Kata</a>. Below are my notes:</div>
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">It took me about two hours to complete. The kata was not overly difficult by itself. However, it may be difficult depending on one's learning focus.</li>
<li style="text-align: justify;">I took a very object-oriented approach to the problem. I wrote separate classes for the rover, grid, and location points.</li>
<li style="text-align: justify;">I am not sure whether I followed DRY principles correctly. I would like to find someone to review my code. If you are interested in helping me out, please send me an e-mail. Alternatively, you could practice writing test cases to see whether my code will pass them. I have only written one test case, because my learning focus is not TDD.</li>
<li style="text-align: justify;">I would like to find a program that could detect duplicate code and point it out to me. If anyone is aware of such a program, feel free to shoot me an e-mail. :)</li>
</ul>
<div style="text-align: justify;">
<br />
P.S. I would have to say that my level of self-awareness of copying code was stuck somewhere between II and III during this kata. Please see what the levels mean in my <a href="http://aleakymemory.blogspot.com/2012/04/dry-learning-plan.html" target="_blank">learning plan</a>.</div>
<div style="text-align: justify;">
</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0tag:blogger.com,1999:blog-7257946298680318037.post-84534462856570137332012-04-14T21:04:00.001-07:002012-04-14T21:04:56.673-07:00Tracking Copy History in Windows<div style="text-align: justify;">
One of my DRY learning activities involves monitoring when I copy/paste code. Unfortunately, I cannot track this manually, because I may subconsciously copy/paste code without realizing that I should record when I have done so. Thus, I have decided to look for a piece of software that can do it for me. <a href="http://www.cybermatrix.com/clipboard_magic.html" target="_blank">CyberMatrix Clipboard Magic</a> seems to be good enough. It allows tracking when copying has occurred, and even provides an option to play a sound. The sound can remind me to reflect upon the reasons that I am copy/pasting code.</div>BVBhttp://www.blogger.com/profile/07712589606797986008noreply@blogger.com0