legoboku.enghttp://legobokueng.blogspot.com/Slowing down is exactly what is needed to go fast! The careful, thoughtful and verified work leads to higher quality.<br>
– James Grenning, "Test Driven Development for Embedded C"ennoreply@blogger.com (yohei)Sun, 07 May 2017 05:47:53 PDTBlogger http://www.blogger.com35125noreply@blogger.comnoSlowing down is exactly what is needed to go fast! The careful, thoughtful and verified work leads to higher quality. – James Grenning, "Test Driven Development for Embedded C"Slowing down is exactly what is needed to go fast! The careful, thoughtful and verified work leads to higher quality. – James Grenning, "Test Driven Development for Embedded C"Friend to friend car sharing service implementation with Kinoma Createhttp://legobokueng.blogspot.com/2014/09/friend-to-friend-car-sharing-service.htmlHackathonIoTKinoma Createnoreply@blogger.com (yohei)Wed, 17 Sep 2014 23:00:26 PDTtag:blogger.com,1999:blog-8130227023372706902.post-7064947328395034218<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-UJaZpRzj1ng/VBpozGI6WJI/AAAAAAAAVxE/dN4FxwFaxQs/s1600/IMG_20140906_181415373.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-UJaZpRzj1ng/VBpozGI6WJI/AAAAAAAAVxE/dN4FxwFaxQs/s1600/IMG_20140906_181415373.jpg" height="180" width="320" /></a></div>&nbsp;I joined <a href="http://attcarhomehackathon.com/">AT&amp;T Hackathon @ Super Mobility Week - Code for Car &amp; Home</a>&nbsp;at&nbsp;Las Vegas on September 6-7 with my two other team members Rama and Kishore. This hackathon is aimed towards developing new applications for connected car and home industry by utilizing AT&amp;T api’s and IoT hardware and software provided by multiple vendors present&nbsp;<a href="http://attcarhomehackathon.com/sponsors/">here</a>. In the hackathon, we tried to make a friend to friend car sharing system which is more secure and interactive than existing services. We intended to use <a href="http://kinoma.com/create/">Kinoma Create</a> platform as in car unit interface that interacts with a driver by visual and audio information. We joined <a href="http://www.meetup.com/sfnodejs/events/199887782/">Kinoma Create meetup</a> before the hackathon and Kinoma team lend us their pre-release version to be used with our Hackathon. So, we would like to share our experience in this entry.<br /><div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;"><div style="line-height: 1.15;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div><h2>Our motivation for the AT&amp;T hackathon</h2>Most people in United states use their car less than 2 hours per day, that is less than 10% utilization rate. At the same time when you need an additional car for a weekend trip or travel outside of home town it is expensive to rent a car. Our concept takes advantage connected car technology to easily share this underutilized car between friends and family. Both parties in this transaction will be benefited as borrower can use car for fraction of rental car cost while owner can use incentive (monetary or points) from this transaction for his future travel. As new P2P car sharing application like getaround, relayrides are getting popular but they will not be useful for sharing cars with friends, family and neighbors. Since these P2P companies takes a portion of rental cost they will not suit sharing scenarios where friends and family will use each others car. In our scenario, we are not considering monetary incentive but this can be easily added as form of points or any other form to our system.<br /><br />Our major motivation in this project is to develop an application that can help a friend, trusted neighbor or family member to easily request, safely use and return car as per agreed schedule. At the same time our application also aims to provide car owner with tools to learn about borrowers past driving score, giving guidelines about his car usage and report on how his car was handled by borrower. To achieve this we developed friend-to-friend car sharing application to solve technical challenges in car sharing scenarios as discussed here.</div><br /><h2>Technical challenges for friend to friend car sharing</h2>Next, we explain technical challenges for the car sharing that we tried to solve in the AT&amp;T hackathon based on the scenario above. We tried to solve common issues we see when we share own cars with friends, family and neighbors.<br /><br /><h3>Owner’s problem</h3><h4><ul><li>(security) It is difficult to give car keys to borrowers if owner is not available at the time of pickup.</li><ul><li><b>(1) Actual world authentication</b></li><ul><li><span style="font-weight: normal;">If the owner is not available at the time of pickup, the owner can’t check borrower’s ID and the borrower lose a chance to share his car. To make a sharing process easy, the owner needs not only online authentication at a time of reservation but also actual world authentication that works remotely.</span></li></ul><li><b>(2) Electronic keys for car and garage&nbsp;</b></li><ul><li><span style="font-weight: normal;">If the owner is not available at the time of pickup, the owner also can’t give keys to the borrower. The owner need a way to provide electronic keys for car and garage from remote.</span></li></ul></ul><li>(safety) Owner wants his car to be driven without aggressive driving and return on schedule without any problems.</li><ul><li><b>(3) reinforce the borrower with good driving behavior</b></li><ul><li><span style="font-weight: normal;">Even though the borrower is reliable person, the borrower might not be safe driver. The owner might want to have a way to monitor the borrower’s driving and reinforce the borrower with good driving behavior.&nbsp;</span></li></ul></ul></ul></h4><div><h3>Borrower’s problem</h3><h4><ul><li>(usability) It may be difficult for borrowers to drive this car without knowing operation details or local driving etiquette.</li><ul><li><b>(4) Less distractive car operation details for a car</b></li><ul><li><span style="font-weight: normal;">It is common that we don’t know how to operate a car if we rent different type of car from own car. The borrower wants to operate the car with the same way as his own car.</span></li></ul></ul></ul><div><span style="font-weight: normal;"><br /></span></div></h4></div><h2>System overview</h2><div>Our solution aims to provide two main features for car sharing. First it support automatic borrower authentication through in-home unit. Our in-home unit detects proximity of borrower by bluetooth beacon technology and enables him to access car parked inside a garage. Second we provide authentication and driving related information through in-car unit.</div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-ov_B75cWfVM/VBpxJTlwnMI/AAAAAAAAVxQ/hQvXU_ZXCQs/s1600/2014-HackArhchitecture.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-ov_B75cWfVM/VBpxJTlwnMI/AAAAAAAAVxQ/hQvXU_ZXCQs/s1600/2014-HackArhchitecture.png" height="480" width="640" /></a></div><div><br /></div><div><h2>Why we chose Kinoma Create</h2><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-IqsmghpeB4s/U_6mqfGC5GI/AAAAAAAAVQE/TP9jnS-W1CA/s1600/IMG_20140827_200625473_HDR.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-IqsmghpeB4s/U_6mqfGC5GI/AAAAAAAAVQE/TP9jnS-W1CA/s1600/IMG_20140827_200625473_HDR.jpg" height="180" width="320" /></a></div><div>We planned to use Arduino and Raspberry Pi to implement the in-car unit. Although, when we joined the Kinoma Create meetup, we found out that it supports the following requirements and it is easier to implement the in-car unit. So we decided to use it for the in-car unit.</div><div><ul><li>Built in network functionality to communicate with server and mobile application</li><li>Display and touch interface to implement interactive user interface for a driver</li></ul></div><div><br /></div><h2>Our impression on Kinoma Create</h2><div>Kinoma platform is helpful for us to quickly develop a simple prototype for our application due to its hardware programming capabilities, built in connectivity and sample application provided by Kinoma team. Developing application on Kinoma studio is straightforward and easy to port completed application to platform. Programmers who are familiar with Java Script may find it easy to write new applications while Hardware programmers like flexibility of programmable pins. Their examples need to be expanded for network and protocol applications but with little effort we were testing our first applications.</div><div><br /></div><h2>Conclusion</h2><div>We defined and created a simple car sharing application for friends, family and neighbors. We used multiple hardware platforms. We used Kinoma Create to build our in-car unit quickly with built in network functionality and display and touch interface. Through the prototyping, we saw potential of Kinoma Create for mainly web developer to build IoT application rapidly.</div><div><br /></div><h2>Acknowledgment</h2><div>Thank you Kinoma Team for providing pre-release version! Since Kinoma Create is nice product for Javascript programmers to take a step into IoT world. We believe this product will become successful in IoT industry.</div></div>0Stepping into a pattern for handling asynchronous operations in Java Script called "JavaScript Promise"http://legobokueng.blogspot.com/2014/07/stepping-into-pattern-for-handling.htmlAsynchronousHTTPJavaScriptProgrammingnoreply@blogger.com (yohei)Thu, 24 Jul 2014 10:21:31 PDTtag:blogger.com,1999:blog-8130227023372706902.post-2852972774031254593I have been currently working on <a href="http://parse.com/">Parse.com</a> and <a href="https://www.automatic.com/">Automatic</a> for my prototyping. I had a problem communication between Parse and Automatic web service through HTTP.<br /><br />Here is my question on <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="043a5038-eedb-44b8-89f8-1e5209c4eccd" id="117de7dc-b0ad-4efe-9c0a-f7549a33bc51">stackoverflow</span>.<br /><br /><a href="http://stackoverflow.com/questions/24772571/parse-cloud-httprequest-call-with-http-request-header">Parse<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="88033d12-e531-4a36-aebb-09bcc0ef61a5" id="b551d82b-a4f4-4512-9dd9-9e4e03e12b76">.</span>Cloud<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="88033d12-e531-4a36-aebb-09bcc0ef61a5" id="e87875c4-5806-4455-8391-3ad4d5c68b22">.</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="88033d12-e531-4a36-aebb-09bcc0ef61a5" id="4ba75d7c-6363-430b-a65b-4b2a2c90c794">httpRequest</span> call with HTTP request header</a><br />The point is that I sent an HTTP request but any callback functions are not called.<br /><br />According to <a href="http://stackoverflow.com/questions/24772571/parse-cloud-httprequest-call-with-http-request-header/24791007#24791007">the suggested solution</a>, I found the following two mistakes in my code.<br /><br /><ul><li>Wrong callback function</li><li>I did not respond to a response from a server&nbsp;</li></ul><br />Thanks to the solution, I could learn how to write a callback function&nbsp;for &nbsp;asynchronous operations in JavaScript.<br /><br /><iframe width="100%" height="300" src="http://jsfiddle.net/legoboku/PJ3fR/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>This is a pattern for handling asynchronous operations in JavaScript that you can see in JavaScript libraries like AngularJS. It is called "<a href="http://wildermuth.com/2013/8/3/JavaScript_Promises">JavaScript Promises</a>".<br /><br />I stepped into the very beginning of asynchronous operations in JavaScript this time. If I found something interesting, I will write it on this blog.0Completed "Introduction to Databases" of Stanford Univeristy with "distinction" http://legobokueng.blogspot.com/2014/03/completed-introduction-to-databases-of.htmldatabaseonline coursenoreply@blogger.com (yohei)Sun, 23 Mar 2014 09:18:59 PDTtag:blogger.com,1999:blog-8130227023372706902.post-8072700024253522486<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-kWoXyLH_e0g/Uyjsbop7YII/AAAAAAAAQjk/LdBddIUrVRg/s1600/state_of_accomplishment.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-kWoXyLH_e0g/Uyjsbop7YII/AAAAAAAAQjk/LdBddIUrVRg/s1600/state_of_accomplishment.png" height="221" width="320" /></a></div><br /><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">I completed "<a href="https://class.stanford.edu/courses/Engineering/db/2014_1/about">Introduction to <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="6c8d64a4-a132-40ab-9440-bdf4228785a3" id="0eaecdb3-2e43-4253-96d9-a50119d18a80">Databeses</span></a>" of Stanford Univeristy with "Distinction", Yeah! This entry explains how this online course looks like.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><h4 style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px; margin: 0px; position: relative;">Why <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="e1272b27-096c-4bb8-b9ab-160753dd80b1" id="635ad649-6735-4e8e-a5ca-b85f8b76460b"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="da0f9f8c-ca4b-4b39-8206-a8ae1e7b3691" id="137b2368-f6ae-4c57-9f30-d4dc647cf4ab">did I participated</span></span> in this course?</h4><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">I was embedded software engineer and seldom use databases. Although, I was transferred&nbsp;to the Business Intelligence company as temporally&nbsp;trainee last October. Then, I often use several relational databases&nbsp;recently. So, I became to think I need to study database again. At that time, I found this course. Studying with <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="43bd02cc-f0ef-4abe-964c-99dbd2c77998" id="8f3cf63e-47da-4d7d-94e8-1f42b6a479a8">book</span> alone is a little bit hard, So I took this course.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><h4 style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px; margin: 0px; position: relative;">Topics that this course covers</h4><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">As I expected this course focuses on relational database theory, including SQL or table design, but they also cover non relational database including XML and JSON.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;"><li style="margin: 0px 0px 0.25em; padding: 0px;">Relational Database&nbsp;Overview</li><li style="margin: 0px 0px 0.25em; padding: 0px;">XML Data</li><li style="margin: 0px 0px 0.25em; padding: 0px;">JSON Data</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Relational Algebra</li><li style="margin: 0px 0px 0.25em; padding: 0px;">SQL</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Relational Design Theory</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Querying XML</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Unified Modeling Language</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Indexes</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Transactions</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Constraints and Triggers</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Views</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Authorization</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Recursion</li><li style="margin: 0px 0px 0.25em; padding: 0px;">Online Analytical Programming</li><li style="margin: 0px 0px 0.25em; padding: 0px;"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c66ee2f4-fe5b-46d4-9e43-ae5e722953c4" id="f86f4b4a-426b-4de3-a434-bc50edf6a32e"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c4307c08-61aa-465f-b365-6594c360a9a1" id="b479a1c1-2b81-4671-8d5d-719d57f57be3">NoSQL</span></span>&nbsp;Systems</li></ul><div><br /></div><div><br /></div></div><h4 style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px; margin: 0px; position: relative;">How to participate in this course</h4><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">In this course, every material became&nbsp;public from the beginning. You can start from any topic. Although, deadline of each assignment work is different. So, you should pick a topic that deadline is close first.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">For each topic, you repeat the following procedure:</div><div style="background-color: white;"><ul style="margin: 0.5em 0px; padding: 0px 2.5em;"><li style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 1.4; margin: 0px 0px 0.25em; padding: 0px;">Watch some short videos that explain topics</li><li style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 1.4; margin: 0px 0px 0.25em; padding: 0px;">Answer simple quizes（No score here）</li><li style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 1.4; margin: 0px 0px 0.25em; padding: 0px;">Try to basic problems</li><ul style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;"><li style="margin: 0px 0px 0.25em; padding: 0px;">multi-selection question（low score）</li><li style="margin: 0px 0px 0.25em; padding: 0px;"><span style="line-height: 1.4;">Programming work（middle score）</span></li></ul><li><span style="font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif;"><span style="font-size: 15px; line-height: 21px;">Try to challenge problems</span></span></li><ul style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;"><li style="margin: 0px 0px 0.25em; padding: 0px;">Advanced programming work（high score）</li></ul></ul><div style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><h4 style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px; margin: 0px; position: relative;">Certification</h4><div style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">When you answer each question, it is automatically scored. You can see how much percentage of scores you already got. If you solve all basic problems, you get 50 % and can complete the course. If you also try challenge problems and get 75 %, you can get "State of Accomplishment with Distinction".</div></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><h4 style="margin: 0px; position: relative;">Oh, everything is English!</h4></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br />It is really hard point for Japanese people. I actually worked in the office where no one speaks in English but now <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c1909db2-e442-40ad-9840-457482da0050" id="2008a34c-0299-46ef-8a1a-ab7fc71eb398">my</span> all coworkers speak in English. So, no problems with this for me now.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">Although, I felt difficulty when a teacher talked really fast about a topic&nbsp;that I was not familiar&nbsp;with. At the time, I had to watch the videos again and again. As a result, I tried to understand by solving some problems. Or sometimes I research some Japanese materials related to the topics.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><h4 style="margin: 0px; position: relative;">How hard it was?</h4></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">It depends on your skill and knowledge. It seems that it takes 3 hours&nbsp;every week to complete the course. You need 7 to 8 hours&nbsp;every week to complete with distinction. I sometimes had to study all day on Saturday or Sunday. If you work full time, you cannot take more than one course at the same time.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><h4 style="margin: 0px; position: relative;">The important point to take an online course</h4></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">If every material becomes public from the beginning, you should consider your private schedule and make a concrete schedule for the course. You might be struggling&nbsp;with difficult problems, so you should have some time to spare.</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">You should not postpone challenge problems even though their deadlines are late because you might forget about details when you are back to the problems :)</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">--</div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></div><div style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 15px; line-height: 21.559999465942383px;">Have fun with an online course!!</div>0"Fluentd: Open Source Log Management" by Sadayuki Furuhashi, Treasure Data at SF Metric Meetuphttp://legobokueng.blogspot.com/2014/03/fluentd-open-source-log-management-by.htmlFluentdmeetupOSSTreasure Datanoreply@blogger.com (yohei)Sat, 22 Mar 2014 22:58:24 PDTtag:blogger.com,1999:blog-8130227023372706902.post-5189021672656477742<iframe allowfullscreen="" frameborder="0" height="281" mozallowfullscreen="" src="//player.vimeo.com/video/87210603?title=0&amp;byline=0&amp;portrait=0" webkitallowfullscreen="" width="500"></iframe> <br /><a href="http://vimeo.com/87210603">Sadayuki Furuhashi talks about Fluentd: Open Source Log Management</a> from <a href="http://vimeo.com/librato"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="52ad1cc0-cbce-478f-9c79-8041c4f7ea0e" id="40bbb074-8cc1-4ee8-b6f8-666f3e7069be">Librato</span></a> on <a href="https://vimeo.com/">Vimeo</a>.<br /><br />This is a participation report for the SF Meetup. This <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="d86231da-75cb-429b-885b-557f3c3b9158" id="b8531036-5333-4d1b-8c41-2be88c17723b">meetup</span>&nbsp;is probably data analysis for server administration. A log management is really far from my current <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c21923b0-b338-4b4d-a7f4-574bdc0f05ae" id="7feda611-2e18-4401-b81b-7d3ea762e3a8">job but</span> I have been interested in <a href="http://fluentd.org/"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c21923b0-b338-4b4d-a7f4-574bdc0f05ae" id="b49ad62e-6b61-4bd5-9873-435cf5c631c0">fluentd</span></a>&nbsp;since I knew that it is <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c21923b0-b338-4b4d-a7f4-574bdc0f05ae" id="9175782b-a8d5-4370-8d30-001136b71660">good approach</span> to make data collection easy. And this is a good chance to hear about it from the founder. So, I participated in this.<br /><br /><h4>About SF Metric Meetup</h4><blockquote class="tr_bq">In the 21st Century successful teams are data-driven. This monthly <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="3a17a880-4556-42bd-911c-632378338777" id="e0fc7695-649e-4350-b43e-ae0976b94175">meetup</span> provides a forum for monitoring geeks to gather and trade new ideas, data, and war stories. If you love data, this <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="2b5c77d3-5153-4e71-9b12-4ae90fee273a" id="c4c37035-8b1f-4906-b0a2-8eaadafb35be">meetup</span> is for you! (<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="14a07a53-7fa9-44be-92b6-c09fe8185bef" id="507d9327-e56f-4d6b-a18b-de5291a25d62">cited</span> from <a href="http://meetup.com/">meetup.com</a>)&nbsp;</blockquote><br /><h4>About the speaker</h4>Sadayuki Furuhashi is an architect and founder of Treasure Data. He is also a founder of some open source projects including <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="6d26873c-0d7b-44ea-8fe3-dd94d1571f81" id="b7c1eaaa-274e-4aa6-b205-9602584e0135">fluentd</span>.<br /><br /><h4>About <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="45b7b7e4-035a-45aa-8406-3b206c20d35f" id="a4b45e41-7105-46ad-879d-939d589fe7de"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="45b7b7e4-035a-45aa-8406-3b206c20d35f" id="7f551ebb-0233-4113-aec6-bd9459c2488a">fluentd</span></span></h4>Fluentd is extensive log management tool written by Ruby. Nowadays, the major web tech <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="ab27d2ea-5ad2-4da2-a7dc-2798d140f14c" id="1ac416d2-cd2a-4634-a206-073c0aba435f">companes</span> produce millions of lines of logs every day and their analysis sever operational status with the logs. <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="11e6e1dc-7810-4fb5-9c85-897c387343b0" id="222b9c83-cceb-4d57-8a24-8705063552d6">Fluentd</span>&nbsp;makes this collection/shape/analysis process easier.&nbsp;<div><br /></div><h4>What they tried to do in this <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="cc845ac0-63f8-4eab-9e1f-e0a7d31bcf5e" id="6165890c-9818-46a2-9022-5fbd5247cb2f">meetup</span></h4><div>This time he came to the <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="188ad18f-1e66-4dac-8ace-12441b25c4c1" id="3982c733-6326-42c3-bffe-1a687452927b">meetup</span>&nbsp;with his coworkers of Treasure Data.&nbsp;I talked&nbsp;with some his coworkers about their business.&nbsp;They are trying to make his open source projects, including Fluentd, MessagePack popular through some <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="1b0e8ac6-2946-41cc-9ad2-a8facd440954" id="da289c93-561a-4116-8d2c-02bcf2e30698">meetups</span>,&nbsp;before providing charged service. I realized that it is important to have this kind of networking opportunity and talk about own products to potential customers. I keep paying attention to their products and services.</div>0Remote debugging for Tomcat and IntellJ on Max OS Xhttp://legobokueng.blogspot.com/2014/03/remote-debugging-for-tomcat-and-intellj.htmlDebugIntellJJavaTomcatnoreply@blogger.com (yohei)Sat, 22 Mar 2014 22:26:00 PDTtag:blogger.com,1999:blog-8130227023372706902.post-3938484681731658904IntellJ supports remote debugging for Tomcat. It is really convenient&nbsp;for debugging. This entry shows how to adopt remote&nbsp;debugging with Tomcat and IntellJ.<br /><br /><h4>My dev environment</h4><br /><ul><li>Max OS X 10.9.2</li><li>Java 1.8.0</li><li>Tomcat 8.0.3</li></ul><div><br /></div><h4>Set up</h4><div>Tomcat</div><ol><li>Create a new file called &lt;Tomcat install directory&gt;/bin/<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="a39181f3-da20-4abe-8727-b1087673b0be" id="dc8b6fd9-b96b-435b-acfb-11752162b9a9">setenv</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="a39181f3-da20-4abe-8727-b1087673b0be" id="8d6445f0-ed5e-4287-ad72-b9a23cb4e996">.</span>sh. (This file will be automatically read by <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="731dc784-8dd1-4d54-90e3-9917a9e0b62d" id="e45ae0ed-a585-4dda-9edb-7f44cf46bff5">catalina</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="731dc784-8dd1-4d54-90e3-9917a9e0b62d" id="497358f8-2a13-44cd-bd03-3be62e068560">.</span>sh)</li><li>Add the following content to <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="62729075-d0cc-4c3f-b47c-835ee67d6292" id="2e4e5cd4-6513-4999-b6ea-857e34e7dc09">setenv</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="62729075-d0cc-4c3f-b47c-835ee67d6292" id="b06ff6d3-773c-4f78-8ca2-408448a3597d">.</span>sh. 8080 is a port number for Tomcat. Please specify for your tomcat.</li><ul><li><span class="s1">CATALINA_OPTS</span><span class="s2">=</span>"-<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="57714c92-c62f-4358-9869-b38dd80cea47" id="4f8fe84a-f4ea-4c4c-8ba3-84047d52b1e1">agentlib</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="57714c92-c62f-4358-9869-b38dd80cea47" id="197a0146-9bc1-4924-ab8e-e6167ed8cf48">:</span>jdwp=transport=dt_socket<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="57714c92-c62f-4358-9869-b38dd80cea47" id="639b6093-b1aa-4975-a33f-3cdcde6b5a88">,</span>address=8080<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="57714c92-c62f-4358-9869-b38dd80cea47" id="8d52577f-72dc-4ad3-a467-a0455da2cff8">,</span>server=y<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="57714c92-c62f-4358-9869-b38dd80cea47" id="7f8c9a68-a5e1-45ac-9c3b-5ada27878b9b">,</span>suspend=n"</li></ul><li>Start Tomcat normally using startup<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="43ac1381-a2fd-40ee-9fc5-f5e82daeb5d6" id="6df68c4a-cd2d-454f-b07b-6a52b71033f6">.</span>sh.</li></ol><div><br /></div><div>IntellJ</div><div><ol><li>Select "Run -&gt; Edit Configuration" then "Run/Configuration" screen is open.</li><li>Specify "Name" like "Tomcat".</li><li>Specify "Port", which is the same number as Tomcat's port <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="1893a829-c1c4-4cca-87a9-8fffb7fd3724" id="e1c43b77-d91e-4cd5-8068-525a834155a0">numer</span></li></ol><div><br /></div></div><div><h4>Debug</h4></div><div><ol><li>If you want to start debugging on IntellJ, just select "Run -&gt; debug 'Tomcat'".&nbsp;</li><li>If IntellJ shows a message like below, you are already connected.</li><ul><li>Connected to the target VM, address: '<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="ba2826f7-ce55-4f3b-8d56-7fcd1c4375d2" id="19ccbd65-9bda-48b4-9e1f-25ac702506fc">localhost</span><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="ba2826f7-ce55-4f3b-8d56-7fcd1c4375d2" id="8bf7aa93-c197-470a-9807-abd2b731a472">:</span>8080', transport: 'socket'</li></ul><li>Now you can debug. Please refer <a href="https://www.jetbrains.com/idea/webhelp/debugging.html">here</a> for more detail about debugging by IntellJ.</li></ol></div>0Apache Lucene: Then and Now, Java User Group meetup at Twitter HQhttp://legobokueng.blogspot.com/2014/02/apache-lucene-then-and-now-java-user.htmlClouderaHadoopJavameetupTwitternoreply@blogger.com (yohei)Wed, 16 Apr 2014 21:14:35 PDTtag:blogger.com,1999:blog-8130227023372706902.post-87445926309088073<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-8FT0-eL0_RA/UwJOImhu7SI/AAAAAAAAQPg/34NnJc4DVFE/s1600/highres_332557642.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-8FT0-eL0_RA/UwJOImhu7SI/AAAAAAAAQPg/34NnJc4DVFE/s1600/highres_332557642.jpeg" height="211" width="320" /></a></div><br /><br /><iframe width="560" height="315" src="//www.youtube.com/embed/5444z-L2V2A" frameborder="0" allowfullscreen></iframe><br /><br /><a href="http://www.meetup.com/sfjava/events/159274122/" target="_blank">Meetup.com - Apache Lucene: Then and Now</a><br /><br />This time, Doug Cutting (<a href="https://twitter.com/cutting">@cutting</a>) talked about the history of Apache Lucene and how Apache Lucene is used for the implementation of Internet search engines and local, single-site searching in major tech companies like Linkedin or Twitter. He also mentioned this project is integrated with Hadoop and still evolving.<br /><div><br /></div><blockquote class="tr_bq">Doug Cutting (<a href="https://twitter.com/cutting">@cutting</a>) is the founder of numerous successful open source projects, including Lucene, Nutch, Avro, and Hadoop. Doug joined Cloudera in 2009 from Yahoo!, where he was a key member of the team that built and deployed a production Hadoop storage and analysis cluster for mission-critical business analytics. Doug holds a Bachelor’s degree from Stanford University and sits on the Board of the Apache Software Foundation. (<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7e01bb55-5089-48c8-a7f5-182337b4e668" id="2b54dd90-be53-4bb3-bf7a-98ea7a4602b9">cited</span> from <a href="http://www.meetup.com/sfjava/events/159274122/">Meetup.com</a>)&nbsp;</blockquote><br />His talk is based on the following blog entries.<br /><br /><ul><li><a href="http://blog.cloudera.com/blog/2013/06/cloudera-search-the-newest-hadoop-framework-for-cdh-users-and-developers/">Cloudera Search: The Newest Hadoop Framework for CDH Users and Developers</a></li><li><a href="http://blog.cloudera.com/blog/2013/07/the-blur-project-marrying-hadoop-with-lucene/">The Blur Project: Marrying Hadoop with Lucene</a></li></ul><br />As you see, his roles in his company (Cloudara) is the implementation of the new open source project, Blur.<br /><blockquote class="tr_bq"><a href="http://incubator.apache.org/blur/">Blur</a> is an Apache Incubator project that provides distributed search functionality on top of Apache Hadoop, Apache Lucene, Apache ZooKeeper, and Apache Thrift. When I started building Blur three years ago, there wasn’t a search solution that had a solid integration with the Hadoop ecosystem. Our initial needs were to be able to index our data using MapReduce, store indexes in HDFS, and serve those indexes from clusters of commodity servers while remaining fault tolerant. Blur was built specifically for Hadoop — taking scalability, redundancy, and performance into consideration from the very start — while leveraging all the great features that already exist in the Hadoop stack. (<span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7fa3acc9-26ef-40ff-a492-cb62fbfafc86" id="0c91df45-1c57-42f9-970b-f7eaa81903ef">cited</span> from <a href="http://blog.cloudera.com/blog/2013/07/the-blur-project-marrying-hadoop-with-lucene/">blog.cloudera.com</a>)</blockquote>And Cloudera is providing a better way for non-programming users interact with Hadoop data.<br /><blockquote class="tr_bq">In the context of our platform, <a href="http://www.cloudera.com/content/cloudera/en/products/cdh.html">CDH</a> (Cloudera’s Distribution including Apache Hadoop), Cloudera Search is another framework much like MapReduce and <a href="http://www.cloudera.com/content/cloudera/en/products/cdh/impala.html">Cloudera Impala</a>. It’s another way for users to interact with Hadoop data and for developers to build Hadoop applications. Each framework in our platform is designed to cater to different families of applications and users (<a href="http://blog.cloudera.com/blog/2013/06/cloudera-search-the-newest-hadoop-framework-for-cdh-users-and-developers/">cited from blog.cloudera.com</a>)</blockquote>&nbsp;See Cloudera blog for more details.<br /><br />It seems that there are <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="c27d6c8a-1b0b-493e-b49b-a1978a80cab7" id="8ef7fd73-00c9-43f8-acda-de0621f38efd">meetup</span>&nbsp;of <a href="http://www.meetup.com/sfjava/">Java user group in SF</a> once or twice a month. I am planning to continue joining <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="44a86b50-175f-410b-be4b-a72c9dd0def5" id="fdd92fd1-1f6b-42a8-9257-63cc7e028af3">meetup</span>.0JSON Lint - validation tool for JSONhttp://legobokueng.blogspot.com/2014/01/json-lint-validation-tool-for-json.htmlJSONtoolnoreply@blogger.com (yohei)Sat, 18 Jan 2014 18:13:41 PSTtag:blogger.com,1999:blog-8130227023372706902.post-368300367122415187There are several validation tools for JSON. These tools help you to write and test JSON data or schema.<br /><br /><br /><ul><li><a href="http://jsonlint.com/" target="_blank"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="f64b3f27-3a4f-4a3e-9b8f-9f5c7ad810eb" id="38cd3f0e-4d49-4d1b-a7ae-c8df26290a34">JSONLint</span></a></li><ul><li>This tool validates that JSON data is valid or not.</li><li>It does not deal with JSON schema.</li></ul><li><a href="http://jsonschemalint.com/" target="_blank">JSON Schema Lint</a></li><ul><li>This tool validates</li><ul><li>JSON schema is valid</li><li>JSON data is valid</li><li>JSON data is valid against <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="4c68682a-18d3-482b-8e95-491d19a677ae" id="df84ea36-93c4-4c31-af06-9317052edf04">JSON schema</span></li></ul></ul></ul><br /><div><br /></div><div><ul><ul></ul></ul></div>0INSERT VS COPY: The fastest way to do a bulk insert into PostgreSQLhttp://legobokueng.blogspot.com/2014/01/insert-vs-copy-fastest-way-to-do-bulk.htmldatabasePostgreSQLnoreply@blogger.com (yohei)Sat, 11 Jan 2014 11:43:48 PSTtag:blogger.com,1999:blog-8130227023372706902.post-8072053507666438824It takes time to populate lots of data in database by many "INSERT" statements. The official PostgreSQL documentation mentions the topic.<br /><br /><a href="http://www.postgresql.org/docs/current/interactive/populate.html" target="_blank">PostgreSQL 9.3.2 Documentation Chapter 14. Performance Tips&nbsp;14.4. Populating a Database</a><br /><br />The chapter shows many options, but I am paying attention to first two.<br /><br /><h4>Disable autocommit</h4><br />PostgreSQL commits each statement automatically. That means if you run an INSERT statement, it runs like this for each statement:<br /><br /><ol><li>Open a transaction</li><li>Insert data</li><li>Close the transaction</li></ol><br />It is redundant. In this case, it becomes faster if you use autocommit&nbsp;like this:<br /><br /><blockquote class="tr_bq">BEGIN; -- the beginning of the transaction<br />INSERT xxxx<br />INSERT xxxx<br />END; &nbsp; &nbsp;-- the end of the transaction</blockquote><br />PostgreSQL does not commit the statements between BEGIN and END.<br /><br /><h4>COPY</h4><br />COPY is also to use populate data, but the different point is that COPY does not offer autocommit. It means that PostgreSQL commit after all data is populated&nbsp;on a database.<br />Please refer to <a href="http://www.postgresql.org/docs/current/interactive/sql-copy.html" target="_blank">the document </a>about how to use COPY statement.<br /><br /><br />0Auto increment primary key in PostgreSQLhttp://legobokueng.blogspot.com/2014/01/auto-increment-primary-key-in-postgresql.htmldatabasePostgreSQLnoreply@blogger.com (yohei)Sat, 11 Jan 2014 11:20:41 PSTtag:blogger.com,1999:blog-8130227023372706902.post-8357444430282816762If you want to increment primary key automatically in Postgres,&nbsp;"serial" is a good option.<br /><br /><ul><li><a href="http://www.postgresql.org/docs/9.3/static/datatype-numeric.html#DATATYPE-SERIAL" target="_blank">PostgreSQL 9.3.2 Documentation&nbsp;Chapter 8. Data Types&nbsp;8.1.4. Serial Types&nbsp;</a></li><li><a href="http://stackoverflow.com/questions/7718585/set-auto-increment-primary-key-in-postgresql" target="_blank"><span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="673bee7e-dfb7-4d26-b3a5-bd8c93f53429" id="8a9d9910-80f6-4612-a890-3cad6c6abe97">Stackoverflow</span> - Set auto increment primary key in Postgresql</a></li></ul><div><br /></div><div>Please that you do not need to specify a primary key to insert data to your database.</div>0How to fix an error "Unable to find a $JAVA_HOME at “/usr”, continuing with system-provided Java"http://legobokueng.blogspot.com/2013/12/how-to-fix-error-unable-to-find.htmlJavaTroubleshootingnoreply@blogger.com (yohei)Sat, 14 Dec 2013 19:05:41 PSTtag:blogger.com,1999:blog-8130227023372706902.post-8673673995064542917Somehow, I have got this error whenever I run Java command:<br /><br /><blockquote class="tr_bq">$java -version<br />Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...<br />java version "1.7.0_25"<br />Java(TM) SE Runtime Environment (build 1.7.0_25-b15)<br />Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)</blockquote><div class="p1"><br /></div><div class="p1">I found the same error as my case at&nbsp;the <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7003d8b7-e6ba-442b-8256-3c03013be1f8" id="834651ed-0967-4383-aff4-ff0e6386dd73">stackoverflow</span>.</div><div class="p1"><br /></div><a href="http://stackoverflow.com/questions/15673709/unable-to-find-a-java-home-at-usr-continuing-with-system-provided-java" target="_blank">Unable to find a $JAVA_HOME at “/usr”, continuing with system-provided Java</a><div><br /></div><div>This happens when $JAVA_HOME is not set correctly. In my case, the following works <span class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="017c45ad-036f-492b-80cb-a6429cc48c57" id="993439a3-282f-43d3-ace5-ee686593b37f">form</span> me.</div><div><br /></div><blockquote class="tr_bq">export JAVA_HOME="$(/usr/libexec/java_home)"</blockquote><div><br /></div><div>My environment is as follows:</div><div><ul><li>OS X 10.9</li><li>Java 1.7.0_25 (installed by brew)</li></ul><div><br /></div></div>0Install R with homebrew under Montain Lion (Mac OS X 10.8.X)http://legobokueng.blogspot.com/2013/09/install-r-with-homebrew-under-montain.htmlhomebrewMacRnoreply@blogger.com (yohei)Thu, 12 Sep 2013 05:19:01 PDTtag:blogger.com,1999:blog-8130227023372706902.post-7753294645250311068<div>You need to install <span class="GINGER_SOFATWARE_noSuggestion GINGER_SOFATWARE_correct" ginger_sofatware_markguid="97db9773-9ba4-4ba5-b310-b51a6ef9e408" ginger_sofatware_uiphraseguid="439b1f56-1f21-4252-82be-b0477e959357" grcontextid="gfortran:0">gfortran</span>&nbsp;before R.&nbsp;</div><blockquote class="tr_bq">$ brew <span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="8c018856-7c88-42f9-994a-52e59747e1b6" ginger_sofatware_uiphraseguid="c90c462a-488e-4d21-9712-88f050c507b1" grcontextid="install:0">install</span> <span class="GINGER_SOFATWARE_noSuggestion GINGER_SOFATWARE_correct" ginger_sofatware_markguid="b770b4d7-fba8-4170-abe8-9130eb70b008" ginger_sofatware_uiphraseguid="c90c462a-488e-4d21-9712-88f050c507b1" grcontextid="gfortran:1">gfortran</span></blockquote>You might find that you don't have XQuartx. Please download and install it at&nbsp;<a href="https://xquartz.macosforge.org/">https://xquartz.macosforge.org</a>.<br /><blockquote class="tr_bq">$ brew <span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="58c20617-ee80-4af3-895d-19f4a3750dbf" ginger_sofatware_uiphraseguid="c7f5f7d3-eb79-47d6-9784-874aa77438d8" grcontextid="install:0">install</span> R<br />Unsatisfied dependency: XQuartz<br />Homebrew does not package XQuartz. Installers may be found at:<br />https://xquartz.macosforge.org<br />Error: An unsatisfied requirement failed this build.</blockquote><div>After you install XQuartz, you can install R like this:</div><blockquote class="tr_bq">$ brew&nbsp;<span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="bda33966-56a6-46b1-a2bf-4074659b7add" ginger_sofatware_uiphraseguid="f4e85335-a131-435a-b303-1866eb0958e6" grcontextid="install:0">install</span>&nbsp;R</blockquote><div><br /></div><div><br /></div>0Ant 1.8 "warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds"http://legobokueng.blogspot.com/2013/09/ant-18-warning-includeantruntime-was.htmlAntJavanoreply@blogger.com (yohei)Sat, 07 Sep 2013 02:29:36 PDTtag:blogger.com,1999:blog-8130227023372706902.post-5631223953638561356I installed Ant 1.8 and build Java applications with Ant. Then, I found the following message:<br /><br /><blockquote class="tr_bq"><span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="a1f83a89-6cb2-4c30-bb65-394a547ba931" ginger_sofatware_uiphraseguid="41783934-ef3d-4747-a3f7-c05a4e2bec5a" grcontextid="warning:0">warning</span>: '<span class="GINGER_SOFATWARE_noSuggestion GINGER_SOFATWARE_correct" ginger_sofatware_markguid="3e2a74e3-a0f6-466d-bc46-da6078762823" ginger_sofatware_uiphraseguid="41783934-ef3d-4747-a3f7-c05a4e2bec5a" grcontextid="includeantruntime:1">includeantruntime</span>' was not set, defaulting to build<span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="a9f4766f-5503-4113-a155-514b71b7c021" ginger_sofatware_uiphraseguid="41783934-ef3d-4747-a3f7-c05a4e2bec5a" grcontextid=".:2">.</span>sysclasspath=last; set to false for repeatable builds</blockquote>You can find a good explanation of this warning with following link:<br /><br /><a href="http://ant.1045680.n5.nabble.com/warning-includeantruntime-was-not-set-td2639463.html">http://ant.1045680.n5.nabble.com/warning-includeantruntime-was-not-set-td2639463.html</a><br /><br />There were incompatible&nbsp;change on Ant version 1.8. So, you may find the same message if you build <span class="GINGER_SOFATWARE_correct" ginger_sofatware_markguid="8c20c6ae-6eea-4f68-abf4-4f9b7bb7c4ef" ginger_sofatware_uiphraseguid="1651376b-ad73-4387-a888-aee1d83e63ef" grcontextid="old ant file:0">old ant file</span> with Ant 1.8.<br /><br />Please just add includeantruntime="false" to <span class="GINGER_SOFATWARE_noSuggestion GINGER_SOFATWARE_correct" ginger_sofatware_markguid="74c91b1e-e1a2-4898-948f-5681f13b0892" ginger_sofatware_uiphraseguid="d18fd058-b2ba-4e8e-b698-fae96a723ba9" grcontextid="javac:0">javac</span> task.<span style="font-family: arial, sans-serif;"><br /></span><br /><br /><br />0How I did interpretration for TDD workshop by James Grenning at #agilejapan http://legobokueng.blogspot.com/2013/06/how-i-did-interpretration-for-tdd.htmlagileTDDnoreply@blogger.com (yohei)Sun, 02 Jun 2013 06:19:39 PDTtag:blogger.com,1999:blog-8130227023372706902.post-9007990578813138514I did interpretation for TDD workshop by James Grenning, the author of "<a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c" target="_blank">Test Driven Development for Embedded C</a>" at Agile Japan 2013 on May 24th. This was first time for me to be interpreter at a conference.<br /><br /><iframe allowfullscreen="" frameborder="0" height="356" marginheight="0" marginwidth="0" mozallowfullscreen="" scrolling="no" src="http://www.slideshare.net/slideshow/embed_code/21929867" style="border-width: 1px 1px 0; border: 1px solid #CCC; margin-bottom: 5px;" webkitallowfullscreen="" width="427"> </iframe> <br /><div style="margin-bottom: 5px;"><strong> <a href="http://www.slideshare.net/legoboku/testdriven-development-for-embedded-c-by-james-grenning-at-agile-japan-2013" target="_blank" title="Test-Driven Development for [Embedded] C by James Grenning at Agile Japan 2013">Test-Driven Development for [Embedded] C by James Grenning at Agile Japan 2013</a> </strong> from <strong><a href="http://www.slideshare.net/legoboku" target="_blank">Yohei Onishi</a></strong> </div><br /><div>This time was good lesson for me. I summarized my experience so that this entry also become good lesson for some other people.</div><div><br /></div><div><h2>Why did I become one of interpreters for the workshop?</h2><div>Let me tell you about history that I became interpreter fot the workshop.</div><div><br /></div><div>I am an organizer of study group for "Test Driven Development for Embedded C" in Tokyo, Japan and I also was a reviewer for Japanese translation of the book. When translation was going to an end, I proposed to Akiyuki Takoshima, a supervisor for translation, that we invited James to Japan for publication party for translation. We thought Agile Japan was the best for it because it was planed to held after publication and organizers of Agile Japan usually invite keynote speaker from foreign country, mostly US.&nbsp;</div><div><br /></div></div><div>I expected that it would be difficult negotiation but the answer from Kenji Hiranabe, one of organizers, was very good. He said "Oh, that's nice idea. I have wanted to invite him to discuss about importance of quality in agile software development". Then Agile Japan organizer started negotiation and I and Akiyuki started preparetion for TDD workshop.</div><div><br /></div><div><h2>Basics of technical interpretation</h2><div>Next, I want to tell you about technical interpretation.</div><div><br /></div><div>You may think interpretation is just word exchange of different languages. I think real interpretation is more than that. In my opinion, we do interpretation as follows:</div><div><br /></div><div><i><span style="color: #cccccc;">Maybe this is almost same as what non-native English speaker do when they talk in English...</span></i></div><div><br /></div><div><ol><li>Understand what speaker said</li><li>Understand its intention and digest result of step 1</li><ul><li>If we don't understand its intention, we have to ask speaker</li></ul><li>Just exchange result of step 2 from original language to target language</li><li>Change result of step 3 in natural and simplified expression and talk to other people&nbsp;</li><ul><li>We do step 3 and step 4 at a time</li></ul></ol></div><div><br /></div>I think you think that step 3, automatic language exchange, is interpretation but I have to do more because we want to avoid loosing original speaker's intention and to tell it people in an easy-to-understand way.</div><div><br /></div><div>To do this, we need both language skill and specialized knowledge for target area because we have different terminology each area. If we don't care about that, attendee don't understand what speaker say.</div><div><br /></div><div>For example, in the case of translation, we often found that reviewers on amazon.co.jp write comment for translation of technical book that quality of translation is very bad.This is because there are problems on either step above.</div><div><br /></div><div><ul><li>Problem on step 1: translator don't understand original text&nbsp;</li><li>Problem on step 2: translator don't have enough knowledge for target area</li><li>Problem on step 3:&nbsp;translator don't improve quality of translation</li></ul><div><br /></div></div><div><h2>Then what do interpreter do during workshop?</h2><div>It depends on workshop. I basically think that interpreter there are two tasks.</div><div><ul><li>Tell trainer's explanation to attendee</li><li>Help question and answer</li></ul></div><div>No big deal. That's it.<br /><br /></div><h3>Tell trainer's explanation to attendee</h3><div>For this, interpreter see trainer carefully and waits good time to interpret. Then good time come, interpreter tells it to attendee. Trainer sometimes tell us about timing for interpretation but he/she usually want to focus on what he/she say and attendee's reaction . So interpreter should &nbsp; &nbsp; manipulate timing.</div><div><br /></div><h3>Help question and answer</h3><div>For this, it is easy. We just hear question from attendee, check its intention and tell it to trainer. When trainer answer then we do opposite.</div></div><div><br /></div><div><h2>What do interpreter should prepare?&nbsp;</h2><h3>(1) acquisition of specialized knowledge for target area</h3><div>As I wrote above, we need specialized knowledge for target area to interpret. we have to read whole workshop material. We also should read trainer's blog, interview article or movie to understand content of workshop, trainer's way of speaking/pronunciation.. If we do, we can understand what trainer say easily.&nbsp;</div><div><br /></div></div><h3>(2) Practice of interpretation</h3><div>I think shadowing is easy and best for practice of interpretation. There are good books for interpretation. If you are interesting in practice, please refer the books.</div><div><br /></div><div><h2>Retrospective for this time</h2><div><h3><br />Keep（Good point, what I want to continue）</h3><div><br />(1) I had enought time to aquire specialized knowledge for target area</div><div>Before workshop, I held study group, wrote interview article, reviewed translation of the book and &nbsp; translated workshop material. I knew everything. No worries about that :)<br /><br /></div><div><h4>(2) I had meeting with trainer twice before workshop</h4></div><div>I had meeting with trainer 1 week before and 2 hour before workshop. I could solve our question such as timing for Q&amp;A, laptop for demo, etc.&nbsp;</div><div><br /></div><h4>(3) I could do interpretation without any eye contact</h4><div>In this time, interpreter manipluated timing for interpretation so that trainer can focus on what he/she say. We sometimes made mistakes but we did good job in general.</div><div><br /></div><h3>Problem</h3><div><h4><br />(1) We translated workshop material then trainer couldn't read it</h4></div><div>In this time, we are not professional interpreter. So we thought we should show Japanese translation of workshop material so that attendees can understand it easily. But trainer couldn't read it and sometimes didn't know what to speak next. This is not big problem because he had original version of material and we can tell. But this was not good for trainer's&nbsp;<span style="background-color: white; font-family: Arial, 'Arial New', 'ＭＳ Ｐ ゴシック', sans-serif; font-size: 13px;">cognitive load.</span></div><div><br /></div><h4>(2) We couldn't interpret jokes</h4><div>Trainer often said jokes because he want attendees to be relaxed. But joke is difficult to interpret. Sorry James :(</div><div><br /></div><h3>Try（What to improve）</h3><div><br /><h3>(1) Keep original text on material and add Japanese subtitle</h3></div><div>This is good for both of trainer and attendee. Kenji Hiranabe, interpreter of keynote, did this.</div><div><br /></div><h4>(2) Interpret jokes</h4><div>We need sens of humor? ummm :(</div></div></div><div><br /></div><h2>In the End</h2>Thank you Agile Japan organizer for giving me a chance to interpret. It was very good lesson for both of TDD and interpretation. This chance must improve my interpretation skill. It was good experience for my life :)<br /><br />Thank you Akiyuki-san, supervisor for translation. We did translation of material and interpretation at workshop. He gave me lots of advice. I could do it because he helped me.<br /><br />Thanks you James. My interpretation was not like professional interpreter. James helped me : ) I have to say thank him for his open mind for my proposal. <br /><br />If I will have next chance for interpretation, I will do better. I have confidence now :)0Want an opportunity for programming education? Join the global day of coderetreat!http://legobokueng.blogspot.com/2012/12/want-opportunity-for-programming.htmlEventProgrammingRSpecRubyTDDnoreply@blogger.com (yohei)Thu, 13 Dec 2012 06:46:32 PSTtag:blogger.com,1999:blog-8130227023372706902.post-4649327737083860277I join the "<a href="http://globalday.coderetreat.org/" target="_blank">Global Day of Coderetreat 2012</a>" on December 9th 2012. I also joined one in 2011. So, this was the second time for me to join it :)&nbsp;In this entry, I explain followings to you:<br /><br /><ul><li>What is Coderetreat?</li><li>What is the Global Day of Coderetreat?</li><li>How to maximize your educational effectiveness</li></ul><div><br /></div><h2>What is Coderetreat?</h2><div><br /></div><div>Coderetreat is a retreat for programmers. Most programmers need retreat because they always have to work for next delivery and they don't have enough time to learn basic skills such as programming and testing. The purpose of this event is to give them an&nbsp;opportunity to learn basic skills in a place where there is not delivery date.&nbsp;</div><div><br /></div><div>Characteristics of coderetreat are follows:</div><div><ul><li>We make program for&nbsp;<a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank">Conway's game of life</a>. It is a kind of simulation or artificial life as follows.</li></ul></div><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="http://2.bp.blogspot.com/-i2jWZjcxF6w/UMnNTBebIiI/AAAAAAAANMQ/pAjhxHchupQ/s1600/Gospers_glider_gun.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-i2jWZjcxF6w/UMnNTBebIiI/AAAAAAAANMQ/pAjhxHchupQ/s1600/Gospers_glider_gun.gif" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">A single Gosper's Glider Gun creating "gliders"</td></tr></tbody></table><div><ul><li>You have 6 pair programming sessions. Each session includes 45 minutes pair programming and 15 minutes retrospective. You change your partner each session.</li><li>You have to delete your code at the end of session. You write code from the scratch every time. This gives you a chance to try different way of design. Actually you have to think design of code differently because facilitator gives you design constraints each session.</li><li>You get a chance to learn object-oriented design, pair programming and TDD. Facilitator or other participants teach you by hands-on if you need it.&nbsp;</li></ul><ul><li>You can have good chance to learn new languages because your partner may know only languages that you are not&nbsp;familiar&nbsp;with. You may use it for the first time but you will make program with your partner's help. Actually I tried Ruby, Java, Scala and JavaScript despite I usually use C/C++ in my work.&nbsp;</li><li>&nbsp;Free lunch and sweets are provided by&nbsp;sponsors. Yeah! Here are sweets at Tokyo site.</li></ul></div></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-t_GF0aH9QUw/UMnSNL-VmKI/AAAAAAAANMg/I2iVLUsQuGM/s1600/cake.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-t_GF0aH9QUw/UMnSNL-VmKI/AAAAAAAANMg/I2iVLUsQuGM/s320/cake.jpg" width="320" /></a></div><div><br /></div><div><br /></div><div><h2>What is the Global Day of Coderetreat?</h2>This time was not just a "Coderetreat" but the "Global Day of Coderetreat" because it held in many countries. You can see <a href="http://coderetreat.org/events/event/search?q=Global+Day+of+Code+Retreat+2012" target="_blank">city list</a> on the official site. 56 cities? I am not sure how many countries hold but it was global event !</div><div><br /></div><div>We connected to India last year. We chat what was going on both site. I was very excited that we were doing same activity with global scale!&nbsp;</div><div><br /></div><h2>How to maximize your educational effectiveness</h2><div>You spend whole day for this event. You should make this event&nbsp;meaningful.</div><div><br /></div><div>But how to do it? I think that it is better to try different way, learn from everyone and broaden your eyes.&nbsp;</div><div><br /></div><div>Here are my activity list for this time.</div><div><br /></div><h3>1. Use different language and testing framework from usual one.</h3><div>I am embedded software engineer and I usually write C/C++ code. I sometimes write Visual Basic or Python code. I don't have&nbsp;opportunities to use other languages in my work but I am interested in other languages.</div><div><br /></div><div>For C/C++ programmer, sometimes other&nbsp;languages&nbsp;and frameworks&nbsp;have good features and concepts. Learning new language cultivate your programming style. But it is little bit difficult for us to start learning by ourself because we don't know where we go at first.&nbsp;So ask your partner about language is better way to learn.</div><div><br /></div><div>In my case, I had fun with Ruby and RSpec, testing framework for Ruby. You can write code with your intuition without deep understanding of language specification. That's really comfortable for&nbsp;beginners. And you can struct your test code by elements such as "description" and "context". Your test code will be easy to read.</div><div><br /></div><div>Features of Ruby and RSpec are quite new to me and quite different from C/C++ world. You can't everything of other languages but you may be able to bring essence into your work. Your work will change.</div><div><br /></div><h3>2. Design your code with different way as usual</h3><div>The purpose of this event is to give participants new experience. We should try little bit different way.&nbsp;</div><div><br /></div><div>For example, if you don't do modeling or object-oriented design during your work, you might design your code with array. But I recommend you to try object-oriented design. You might think:</div><div><ul><li>What kind of object do we need?&nbsp;</li><li>What responsibilities does each object have?</li></ul><div>Thinking about these questions make your design better.</div></div><div><br /></div><div>In my case, we tried different one. I used map and filter to overcome several constraints such as no if statements and no loop. With this idea, I could write shorter and smart code.</div><div><br /></div><h3>3. Try technical practice in ideal situation</h3><div>Coderetreat is not real job. Even if you don't complete, no one gets angry. You can try any practice as you want.</div><div><br /></div><div>For example, if you know TDD but you have never tried it, then try it in coderetreat. You will discover how it works.</div><div><br /></div><div>I tried double test loop that is introduced in "<a href="http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" target="_blank">Growing Object-Oriented Software, Guided by Tests</a>". In this practice, we write end-to-end acceptance test first and write code for inside module with TDD to pass acceptance test.</div><div><br /></div><div>I often see that many participants tend to focus on detail of components and end up with perfect components and incompletion of whole game. If you do this in your work, your project will collapse.</div><div><br /></div><div>If you write acceptance test for one scenario and write code with TDD to pass acceptance test, you get a system that works for certain&nbsp;scenario&nbsp;early. There is another benefit. You found considering points for architecture design early. You can avoid some risks in your project.</div><div><br /></div><h3>4. Share what your were interested in during retrospective</h3><div>At the end of each session, every pair do retrospective, wrote own thought about session on stickies and put them on the board to share your experience.</div><div><br /></div><div>Facilitators usually pick up topics to share but you can ask them to share your topics. You will receive many feedback from other participants.</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-7heSHllyhO0/UMnn5VcsyUI/AAAAAAAANMw/PRafolPisWM/s1600/retrospective.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-7heSHllyhO0/UMnn5VcsyUI/AAAAAAAANMw/PRafolPisWM/s320/retrospective.jpg" width="320" /></a></div><div><br /></div><div><br /></div><h3>5. Communicate with&nbsp;participants&nbsp;in other countries</h3><div>At this time, we have two tags for twitter. "#gdcr12" for global and "#gdcr12ja" for Japan. I tweeted for "#gdcr12" then @jbrains from Canada respond me quickly! It was really quicker response than I expected! It was very helpful.&nbsp;</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-6IgsbALUK5Q/UMnodYsC8aI/AAAAAAAANM4/mPjNM8DLrvc/s1600/tweet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="http://4.bp.blogspot.com/-6IgsbALUK5Q/UMnodYsC8aI/AAAAAAAANM4/mPjNM8DLrvc/s320/tweet.png" width="320" /></a></div><div><br /></div><div>Thanks to @jbrains and @haradakiro, I found the video that introduce "Verbs instead of Nouns". Byt there isn't much information about that :( I don't understand what happens with that activity yet.</div><div><br /></div><h2>Conclusion</h2><div>In this entry, I introduced coderetreat and how to maximize&nbsp;your educational effectiveness. This event is well structured and worth to join. If you want to get an&nbsp;opportunity&nbsp;to learn basic skills of programming and testing, this is good way for you:) Please join next time!</div><div></div><div></div><div><br /></div><div></div>0Book review: Test Driven Development for Embedded Chttp://legobokueng.blogspot.com/2012/10/book-review-test-driven-development-for.htmlembeddedTDDnoreply@blogger.com (yohei)Mon, 08 Oct 2012 15:48:07 PDTtag:blogger.com,1999:blog-8130227023372706902.post-1270251300963536669I wrote <a href="https://www.ogis-ri.co.jp/otc/hiroba/OoBook/tdd4ec/index.html">Japanese article</a> to introduce “<a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c">Test Driven Development for Embedded C</a>” for embedded software developers in Japan last month. This entry is English version of it.<br /><br />----------<br /><br />As you can see with the title, this is the book about Test Driven Development for embedded software with C language. The author, <a href="http://www.renaissancesoftware.net/blog/">James Grenning</a>, is training, coaching and consulting agile software development or TDD over the world. He is also the inventor of agile estimation technique “planning poker” and one of the authors of <a href="http://agilemanifesto.org/">agile manifesto</a>.<br /><br /><div><h2>Must read book for embedded software developer</h2><br />Recently Japanese TDD passionates like <a href="https://twitter.com/t_wada">@t_wada</a> are holding <a href="http://devtesting.jp/tddbc/">TDD boot camp</a> in major cities of Japan. This is an event for TDD beginners to have an exercise of TDD. People get together at one place, make pair for exercise and do TDD with specific problems.<br /><br />Thanks to them, we can have more chance to exercise TDD and people are becoming to discuss practical topic about TDD on their blog or social media. TDD is not majority in the industry yet but I am feeling TDD is becoming common technique for us.<br /><br />On the other hand, most of embedded software are left out of boom of TDD boot camp. They think that they have nothing is to do with TDD because every article on book or blog is written about enterprise or web system. They are things on other planets.<br /><br />This is a book for you, embedded software developers :) This book deals with typical example of embedded software and C/C++ testing framework and explain how to do TDD with very tiny step of carefully. It also can be good textbook for module design of C code.<br /><br /></div><div><h2>Why embedded software developer need TDD?</h2><br />Embedded software developer might think why they need TDD. The author answer the question in the chapter 5 “Embedded TDD Strategy” of the book. He explain the we can solve “the target hardware bottleneck” problem, which is common for embedded software development. <br /><br />The target hardware bottleneck is a problem that target hardware could be a bottleneck disturbs software testing. Generically, target hardware is different from host computer that is used to develop software. And we can have these situation:<br /><ul><li>The problems leads to delay or increasing of working hour for software testing</li><ul><li>Target hardware are not ready till the end of project</li><li>Target hardware is expensive and we can’t prepare enough number of target hardware&nbsp;</li><li>It takes long time to build and upload software to target hardware&nbsp;</li></ul><li>The problems leads to difficulties to find bugs</li><ul><li>It is difficult to identify where bugs are because the target hardware also have bugs in the beginning</li><li>Compiler for target hardware is different from one for host computer. Then we find unintentional behavior of software on the target hardware</li></ul></ul>To solve the target hardware bottleneck problem, the author recommend these approaches:<br /><ul><li>Ensure quality of software by TDD on host computer before testing on the target hardware</li><li>Do same tests on both of host computer and target hardware to find bug that are happend because of different between them.</li></ul><br />And the author recommends TDD cycle for embedded software development as follows: <br /><br /><div style="text-align: center;"><a href="http://2.bp.blogspot.com/-eK4mHZAlrZE/UHKM7I3yptI/AAAAAAAANKo/kAntTQOm4UM/s1600/micro_cycle.png"><img border="0" src="http://2.bp.blogspot.com/-eK4mHZAlrZE/UHKM7I3yptI/AAAAAAAANKo/kAntTQOm4UM/s320/micro_cycle.png" /></a></div><br />The book focuses on the stage 1 on the cycle. It doesn’t explain stage 2 to 5 in detail but you can find more information about step 5 on the author’s paper (PDF) “<a href="http://renaissancesoftware.net/files/articles/ESC-424Paper_Grenning-StoryTesting-v1r0.pdf">Scenario Testing with Executable Use Cases</a>”. <br /><br />I also write this cycle on <a href="http://legobokueng.blogspot.jp/2012/04/boost-quality-of-embedded-software.html">my blog entry</a>. <br /><br /></div><div><h2>How is the book organized</h2><br />The book consisted of three part.<br /><br />In the first part “Test Driven Development”, the author introduces the process of TDD when we develop LED device driver. He also introduces why embedded software developer need TDD, test cycle including TDD and testing framework for C, Unity and <a href="http://cpputest.org/">CppUTest</a>.<br /><br />The second part is about technique to replace dependant module to test with C. It is very difficult to replace module with C, the only ways we can do are link substitution, preprocessor substitution and function pointer substitution. It also explains C++ mocking library “<a href="http://www.cpputest.org/node/30">CppUMock</a>” to test complex interaction with dependent module. <br /><br />In the third part “Design and Continuous Improvement”, knowledge and technique to improve design continuously such as SOLID principle, test for legacy code and test patterns are introduced. If you are not familiar with object oriented design and programming, it is very difficult to understand. You need to read the books about object oriented design and programming first. <br /><br />Please refer to the full table of contents on <a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c">the official site</a>. <br /><br /><h2>How to read the book</h2><br /><h3>For those who wants to know characteristics of TDD for embedded software</h3><br />When I introduce the book to my coworker and he asked me “What is the difference between TDD for embedded and the others?” I think that basic points are same. For example, there is no difference between dependency to module and dependency to hardware.<br /><br />I think that the most biggest difference is language constraint. Comparing to object oriented language, you need more technique to make test doubles, which is module to replace dependent module. In order to understand the technique, please refer to the chapter 7 “Introducing Test Doubles”, the chapter 8 “Spying on the Production Code” and the chapter 9 “Runtime-Bound Test Doubles”.<br /><br />On the other hand, there is special bonus for embedded software developer. As I wrote before, we can solve the hardware bottleneck problem. Please refer to “Benefit for Embedded” at the chapter 1 and the chapter 5 “Embedded TDD Strategy”.<br /><br /></div><div><h3>For those who wants to try TDD with example</h3><div><br />To put TDD in practice, you need not only knowledge but technique. You must acquire technique by doing exercise. You can read the process to test and refactor your code for example of LED device driver in the chapter 3 “Starting a C Module” and the chapter 4 “Testing Your Way to Done”. &nbsp;Try them.</div><div><br /></div><div>Example in the chapter 3 and 4 is quite simple. You need test doubles in actual development. You can read about test doubles in the chapter 7 ”Introducing Test Doubles”, the chapter 8 ”Spying on the Production Code” and the chapter 9 “Runtime-Bound Test Doubles”.<br /><br /></div></div><h3>For those who wants to know better C module design</h3><br />TDD covers not only design and implement activity but also continuous improvement to better design by refactoring. You need to know what is better design to improve design of your software.<br /><br />The chapter 11 “SOLID, Flexible and Testable Designs” introduces better design principles and implementation with C. You can understand how to design low-coupling module design with C.<br /><br />There is also explanation to eliminate piles of if / switch-case statements by implementing polymorphism in the object oriented design concept with C. The code is tricky and it is very difficult to understand if you don’t understand object oriented design. In the case, you need to read object oriented software design book such as “<a href="http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445" target="_blank">Agile Software Development</a>” first.<br /><br /><br /><h2>How Japanese readers say about the book</h2><br />In conclusion, I introduce comments from the members of “Test Driven Development for Embedded C” studying group.<br /><br /><ul><li>It is very helpful to understand how TDD master think and do because every tiny step and design decisions are written at the beginning of the book. &nbsp;</li><li>I read the book and solve some exercises, then I could understand basic rhythm of TDD.&nbsp;</li><li>I was wondering how to apply object oriented design to C code before I read this book. Thanks to the book, I understood how to do it.</li><li>I think that it is very difficult to understand the book at first if the readers understand object oriented design and test. Example of C code is not enough for beginners.</li><li>This book is very good as index of modern software testing. It includes TDD, test for legacy code, SOLID principle and refactoring, xUnit Test Patterns. Every embedded software developer should read this!</li></ul><br />3noI wrote Japanese article to introduce “Test Driven Development for Embedded C” for embedded software developers in Japan last month. This entry is English version of it. ---------- As you can see with the title, this is the book about Test Driven Developmnoreply@blogger.com (yohei)I wrote Japanese article to introduce “Test Driven Development for Embedded C” for embedded software developers in Japan last month. This entry is English version of it. ---------- As you can see with the title, this is the book about Test Driven Development for embedded software with C language. The author, James Grenning, is training, coaching and consulting agile software development or TDD over the world. He is also the inventor of agile estimation technique “planning poker” and one of the authors of agile manifesto. Must read book for embedded software developer Recently Japanese TDD passionates like @t_wada are holding TDD boot camp in major cities of Japan. This is an event for TDD beginners to have an exercise of TDD. People get together at one place, make pair for exercise and do TDD with specific problems. Thanks to them, we can have more chance to exercise TDD and people are becoming to discuss practical topic about TDD on their blog or social media. TDD is not majority in the industry yet but I am feeling TDD is becoming common technique for us. On the other hand, most of embedded software are left out of boom of TDD boot camp. They think that they have nothing is to do with TDD because every article on book or blog is written about enterprise or web system. They are things on other planets. This is a book for you, embedded software developers :) This book deals with typical example of embedded software and C/C++ testing framework and explain how to do TDD with very tiny step of carefully. It also can be good textbook for module design of C code. Why embedded software developer need TDD? Embedded software developer might think why they need TDD. The author answer the question in the chapter 5 “Embedded TDD Strategy” of the book. He explain the we can solve “the target hardware bottleneck” problem, which is common for embedded software development. The target hardware bottleneck is a problem that target hardware could be a bottleneck disturbs software testing. Generically, target hardware is different from host computer that is used to develop software. And we can have these situation: The problems leads to delay or increasing of working hour for software testingTarget hardware are not ready till the end of projectTarget hardware is expensive and we can’t prepare enough number of target hardware&nbsp;It takes long time to build and upload software to target hardware&nbsp;The problems leads to difficulties to find bugsIt is difficult to identify where bugs are because the target hardware also have bugs in the beginningCompiler for target hardware is different from one for host computer. Then we find unintentional behavior of software on the target hardwareTo solve the target hardware bottleneck problem, the author recommend these approaches: Ensure quality of software by TDD on host computer before testing on the target hardwareDo same tests on both of host computer and target hardware to find bug that are happend because of different between them. And the author recommends TDD cycle for embedded software development as follows: The book focuses on the stage 1 on the cycle. It doesn’t explain stage 2 to 5 in detail but you can find more information about step 5 on the author’s paper (PDF) “Scenario Testing with Executable Use Cases”. I also write this cycle on my blog entry. How is the book organized The book consisted of three part. In the first part “Test Driven Development”, the author introduces the process of TDD when we develop LED device driver. He also introduces why embedded software developer need TDD, test cycle including TDD and testing framework for C, Unity and CppUTest. The second part is about technique to replace dependant module to test with C. It is very difficult to replace module with C, the only ways we can do are link substitution, preprocessor substitution and function pointer substitution. It also explains C++ mocking library “CppUMock” to test complex interaction with dependent module. In thembedded, TDDTest Driven Development for Embedded C: Introducing runtime-bounded test doubles and the mock objecthttp://legobokueng.blogspot.com/2012/07/tdd-for-embedded-c-introducing-runtime.htmlC++CppUTestembeddedTDDnoreply@blogger.com (yohei)Sat, 14 Jul 2012 01:32:44 PDTtag:blogger.com,1999:blog-8130227023372706902.post-8013729618019668515<br /><span style="background-color: white;">I had a meeting with reading group of "<a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c" target="_blank">Test Driven Development for Embedded C</a>" in Tokyo, Japan. We read the chapter 9 "Runtime-Bounded Test Doubles" and the chapter 10 "The Mock Object", then we discussed them. In this entry, I introduce the chapters and some topics from our discussion.</span><br /><br /><span style="background-color: #fff2cc; font-size: large;">The chapter 9 "Runtime-Bounded Test Doubles"</span><br /><br />When we implement product code with C, we have three ways to replace dependent module with test doubles. They are preprocessor substitution, link substitution and function pointer substitution.<br /><br />Link-time substitution, which is introduced in chapter 7 "Introducing Test Doubles", is not flexible because it can't be replaced at runtime. If you want to use product code once and use test doubles at other time, function pointer substitution, which is introduced at chapter 9, is effective way. <br /><br />Although function pointer substitution is very flexible, it has a side effect. Heavy usage of preprocessor or function pointer substitution reduces code readability. You should use them in a limited way.<br /><br />By the way, the author doesn't explain preprocessor substitution. He may doesn't like it because of side effect.<br /><br /><span style="background-color: #fff2cc;"><span style="font-size: large;">The chapter 10 "The Mock Object"</span></span><br /><br />The chapter 10 introduces the mock object, which is not so popular among embedded software engineers. The subject is a device driver for existent flash memory. The mock object is useful way to ensure quality of device driver before integrate it with hardware because:<br /><br /><ul><li><span style="background-color: white;">It is difficult to test complex interaction between software and hardware based on specific protocol with usual testing framework.</span></li><li><span style="background-color: white;">It may be impossible to test error case in real device.&nbsp;</span></li></ul><br />Most part of the chapter 10 focuses on how to implement the mock object in C. You can also know "<a href="http://www.cpputest.org/node/30" target="_blank">CppUMock</a>", which is C++ mocking library, and "<a href="http://sourceforge.net/projects/cmock/" target="_blank">CMock</a>", which is mock generation tool for C.<br /><br />I found that mock object is usually complicated. If you implement mock object in C by yourself, you must to test it thoroughly before you use it. Test may be unnecessary if a mocking library assure quality of mock object.<br /><br />You might think that making mock object is waste of time. But I think that it worth spending cost to make mock object and test with mock object. The more you standardize &nbsp;device I/O, the more effectiveness of test grow. You can ensure quality of device driver more and more before integrate it with hardware.<br /><br />At last we discussed why the mock object is popular among enterprise or web engineers but not among embedded engineers. Our conclusion is that mocking library with LL is very useful because LL has less constraint and mocking library is well maintained to use easily. On the other hand, library for C/C++ are still on the way to become useful.<br /><br />This is one of difficulties for embedded engineers. To gain strength from TDD, we need to prepare way to overcome language constraint.<br /><br />2Boost quality of embedded software early with Dual Target Testinghttp://legobokueng.blogspot.com/2012/04/boost-quality-of-embedded-software.htmlembeddedTDDnoreply@blogger.com (yohei)Mon, 30 Apr 2012 05:49:15 PDTtag:blogger.com,1999:blog-8130227023372706902.post-6769333318448375556<br />I held the <a href="http://atnd.org/events/26137" target="_blank">third monthly meeting</a> of "<a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c" target="_blank">Test Driven Development for Embedded C</a>" reading group in Tokyo.<br /><br />We read following two chapters then.<br /><ul><li>The fifth chapter "Embedded TDD Strategy"</li><ul><li>This chapters introduces "Dual Target Testing" which is important to do TDD for embedded software development</li></ul><li>The sixth chapter "Year, but..."</li><ul><li>This chapter introduces opposing views for adopting TDD and answers for them</li></ul></ul>In this entry, I explain what is dual target testing and why we need it.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">Concurrent development software and hardware makes embedded system development difficult</span><br /><br />Concurrent development of software and hardware is common in embedded system development. As I told in the entry "<a href="http://legobokueng.blogspot.jp/2012/03/is-tdd-one-of-solutions-for-difficulty.html" target="_blank">Is TDD one of the solutions for difficulty of concurrent development of software and hardware?</a>", concurrent development is one of difficulties in embedded system development. Bug whose cause are difficult to find often occurs because we move ahead while software and hardware are low quality.<br /><br />I give you an example of concurrent development. I often develop embedded software as follows.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-pQnN30y7DvY/T51SLy4S7bI/AAAAAAAAMuE/qAgqVoEPw5U/s1600/process.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="http://4.bp.blogspot.com/-pQnN30y7DvY/T51SLy4S7bI/AAAAAAAAMuE/qAgqVoEPw5U/s400/process.png" width="400" /></a></div><br /><ul><li>I divide development period into several iterations.</li><li>Each iteration has function scope.</li><li>At the end of the iteration, we integrate software and hardware to make prototype. We evaluate it.</li><li>I continue prototyping and create spec incrementally.</li></ul>I think this kind of prototyping is common in embedded system development.<br /><br />In this kind of prototyping, we have difficulties as follows.<br /><ul><li>I don't have hardware at the beginning.</li><li>I usually use minimum hardware to check booting OS.</li><li>I also start from checking operation with previous product</li></ul>After integration of hardware and software, QA team starts evaluation of prototype. They find lots of bugs. I recieved piles of bug reports and I start investigation of bug cause. This is very difficult task because quality of software and&nbsp;hardware is&nbsp;low then. Bugs are everywhere. Software engineers have to spend much time to prepare evidence to say software has no bugs.<br /><br />This work is not productive. To realize productive embedded system development, software engineers have to spend enormous effort boosting software quality before hardware is ready.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">Boost quality of embedded software early with Dual Target Testing</span><br /><br />What can we do to boost quality of embedded software before hardware is ready ? James Grenning, the author of Test-Driven Development for Embedded C, recommend Dual Target Testing. This is a technique to make test with both of target hardware and PC possible at the&nbsp;beginning.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-Vl0qKILnCCA/T51STCvLutI/AAAAAAAAMuM/xfdwzrx-044/s1600/micro_cycle.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="130" src="http://1.bp.blogspot.com/-Vl0qKILnCCA/T51STCvLutI/AAAAAAAAMuM/xfdwzrx-044/s400/micro_cycle.png" width="400" /></a></div><br />Here are key points.<br /><ul><li>We build high quality software with exhaustive unit test and&nbsp;refactoring&nbsp;on PC from the beginning. Then we move to &nbsp;unit test with eval hardware.</li><ul><li>This work reduce unproductive work like finding logical mistake with poor debug environment on eval hardware.</li></ul><li>Compiling for target processor and unit test on eval hardware and target hardware reduce bugs which causes are difference of development environment between host and target.</li></ul>We can check only with unit test scope but we can start smoothly becausse we get high quality software before we move to eval hardware.<br /><br />We don't need check logical mistake of module on eval hardware. Reducing unproductive work make us concentrate on spend enormous effort for advanced work.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">We need to write unit tests consistently for dual target testing</span><br /><br />We need to write many unit test code for dual target testing. This is more a time-consuming way than moving to eval hardware without tests.<br /><br />It is very easy to check with eval hardware without unit test but everything needs to be done manually. Keeping&nbsp;quality&nbsp;is very difficult if everyone commit lots of code. We spend much time to find cause of bugs.<br /><br />Writing unit tests for dual targeting test is very time-consuming way in the short term but it is very productive way in the long term because we can find mistake quickly. We reduce debug time and we can spend more advanced work.<br /><br />We will talk which style is good for us at the next meeting.<br /><br /><span style="background-color: #fff2cc; font-size: large;">How can we do dual target testing?</span><br /><br />I will explain detailed techninque for dual target testing next time. Stay tuned :)2Rarejob lesson logshttp://legobokueng.blogspot.com/2012/03/rarejob-lesson-logs.htmlEnglishRarejobnoreply@blogger.com (yohei)Thu, 22 Nov 2012 17:11:26 PSTtag:blogger.com,1999:blog-8130227023372706902.post-8500529080447282565<div class="MsoNormal"><span style="background-color: #fff2cc; font-size: large;">December 23, 2012</span><br />And I took article discussion. Today we discussed about this article.<a href="http://online.wsj.com/article/SB10000872396390443675404578059311445951162.html">http://online.wsj.com/article/SB10000872396390443675404578059311445951162.html</a><br /><br />Discussion points are follows.<br />·What are possible problems that countries may encounter wh<br />en dealing with each other?<br />·How can people ensure harmony between nations with different cultures, values, or religions?<br /><br />We usually have some problems with countries close to us. Japan has territory issues with China. Philippine has other issues with China. <br />I think that It is difficult to have harmony at political problem but we can do something at citizens level. Chinese people who have never been to Japan might think Japanese people are bad people but ones who live in Japan don't think like that because they knew what is reality. Reality is that most Japanese people are polite and kind. Once they visited Japan and knew reality, they will change his mind. Having chance to know each other is good way to cooperate each other.<br /><br /><span style="background-color: #fff2cc; font-size: large;">December 23, 2012</span></div><div class="MsoNormal">I took TOEFL interview test for the first time. I was asked to hear following question, prepare answer in 15 minutes and answer for in 45 minutes. It is very hard.<br /><br /><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, 'hiragino kaku gothic pro', meiryo, 'ms pgothic', sans-serif; line-height: 17.981481552124023px;">"Some families think that having a pet is important to provide enjoyment to the members. Others think that a pet would only be a burden at home. Which opinion do you agree with and why? Give specific details and examples in your answer"</span></div><div class="MsoNormal"><span style="color: #333333; font-family: lucida grande, tahoma, verdana, arial, hiragino kaku gothic pro, meiryo, ms pgothic, sans-serif; font-size: x-small;"><span style="line-height: 17.96666717529297px;"><br /></span></span><span style="background-color: #fff2cc; font-size: large;">March 26, 2012</span><br />Total 13.5 hours. I used conversation material for intermediate level today.<br />In today's lesson, my tutor said that her mom loves the movie 'Hachiko the Akita dog' so they call her pet "Hachiko". That is nice.<br />I asked my tutor "What is your most favorite food?" Her answer is chocolate. Why do every girls like chocolate? I don't understand why because I don't eat it often.<br /><br /><span style="background-color: #fff2cc; font-size: large;">March 18, 2012</span></div><div class="MsoNormal"><span lang="EN-US">Total 11.5 hours. I used conversation material for intermediate level today.<o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US">In today's lesson, we talked about my role in my family. It is to show my family outside of home. For example, I take them to overseas. I took them to Taiwan, Switzerland and Germany. Best city to visit is Zurich. I watched Italian opera with English subtitles. It was my first time to watch opera. So I was very impressed. My family is too.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US"><span style="background-color: #fff2cc; font-size: large;">March 17, 2012</span><o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US">Total 11.25 hours. I used conversation material for intermediate level today.<o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US">In English lesson, we talked about small family is better than big one. I don't think so. Big family is fun and you can learn social skill. You have to appeal to your parents in big family. That make you social person. In small family, you cannot get that experience.<o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US">But for my own family, I want to have small one. Raising many children costs very much in Tokyo. Two children are enough for me. My tutor has same opinion with me. She grew up in big family but she wants to have small family.<o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US"><br /></span></div>2The second monthly meeting of the "Test-Driven Development for Embedded C" book club in Tokyohttp://legobokueng.blogspot.com/2012/03/second-monthly-meeting-of-test-driven.htmlembeddedTDDnoreply@blogger.com (yohei)Sun, 18 Mar 2012 00:04:57 PDTtag:blogger.com,1999:blog-8130227023372706902.post-4285315375269119486<br /><div class="MsoNormal">The second meeting of "<a href="http://pragprog.com/book/jgade/test-driven-development-for-embedded-c" target="_blank">Test-DrivenDevelopment for Embedded C</a>" book club in Tokyo took place on March 4th.</div><div class="MsoNormal"><br /></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="background-color: #fff2cc;"><span style="font-size: large;"><span lang="EN-US">We read the three and fourth&nbsp;</span>chapter</span></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">At this time, we read the third chapter "Starting C Module" and the fourth chapter "Testing Your Way to Done". We had first TDD session during these chapters. We wrote test code and product code for LED driver then we refactored both of them.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">The third and fourth chapters are highlight of the first half of this book. If you start to read this book, I recommend you to try the example of these chapters by yourself.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">There are sample codes on my github repository.</span></div><div class="MsoNormal"></div><ul><li>Test code for LED driver</li><ul><li><a href="https://github.com/yohei1126/embeddedtdd/blob/master/unity/LedDriver/LedDriverTest.c" target="_blank">LedDriverTest.c</a></li></ul><li>Product code for LED driver</li><ul><li><a href="https://github.com/yohei1126/embeddedtdd/blob/master/src/LedDriver/LedDriver.c" target="_blank">LedDriver.c</a></li><li><a href="https://github.com/yohei1126/embeddedtdd/blob/master/include/LedDriver/LedDriver.h" target="_blank">LedDriver.h</a></li></ul></ul><br /><div class="MsoNormal"><span lang="EN-US"><span style="background-color: #fff2cc; font-size: large;"><br /></span></span></div><div class="MsoNormal"><span lang="EN-US"><span style="background-color: #fff2cc; font-size: large;">Always make code stable</span><o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">There are two very informative topics at this time.&nbsp;</span>First one is to make code stable. Author describes TDD work like this:</div><div class="MsoNormal"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-DP8l9-6FDws/T2WHDFrtY_I/AAAAAAAAMec/CpPoUuYtD5w/s1600/TDD_StateMachine.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="http://2.bp.blogspot.com/-DP8l9-6FDws/T2WHDFrtY_I/AAAAAAAAMec/CpPoUuYtD5w/s400/TDD_StateMachine.png" width="400" /></a></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">And I saw this diagram and I found like these:<o:p></o:p></span></div><div class="MsoNormal"><span lang="EN-US"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-WtfikCD5tA8/T2WHXWP8mZI/AAAAAAAAMek/8-tGWrBZCEc/s1600/%E3%82%B9%E3%83%86%E3%83%BC%E3%83%88%E3%83%9E%E3%82%B7%E3%83%B3%E5%9B%B30.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="http://3.bp.blogspot.com/-WtfikCD5tA8/T2WHXWP8mZI/AAAAAAAAMek/8-tGWrBZCEc/s400/%E3%82%B9%E3%83%86%E3%83%BC%E3%83%88%E3%83%9E%E3%82%B7%E3%83%B3%E5%9B%B30.png" width="400" /></a></div><div class="MsoNormal"></div><ul><li>There are two stable states of code, which are stable state that passed tests and one that don't pass.</li><li>TDD doesn't make another state of code.</li></ul><br /><div class="MsoNormal"><span lang="EN-US">In the stable state that passes tests, there are not refactored code and refactored code. This topic is well known for TDD new comers.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">The stable state that doesn't pass tests is a transient state. Compile error, link error, test failure. TDD makes this process obvious. TDD doesn't make unbalance state that passes tests but include incomplete implementation and mistakes.<o:p></o:p></span></div><div class="MsoNormal"><br /></div>You might think that you don't need to do such rigorous way. Of course, some people can implement perfect code at a time but most of us can't do it. We make mistakes. So we need way to find mistakes. <br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US"><span style="background-color: #fff2cc;"><span style="font-size: large;">Do not care about performance too much at first but care about readability</span></span><o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">Second topic is code readability. Here is informative description in the book.</span></div><blockquote class="tr_bq"><span lang="EN-US">don't let the performance factor outweigh improved design and readability unless there is proof the code is contributing to a specific performance problem.</span></blockquote><div class="MsoNormal"><span lang="EN-US">Author doesn't mean that performance is not important. We had same opinion. When we deal with problem on performance, we have to find performance bottleneck with profiler. If you put emphasis on performance and write unreadable code while you don't know where bottleneck is, maintenance time increase and have bad effect on costs.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">So here is better way: <o:p></o:p></span></div><div class="MsoNormal"></div><ul><li>Considering a way to meet consider requirement at architecture design phase</li><li>Finding performance bottleneck with profiler at the beginning of architecture implementation phase</li><li>Refactoring code so that each module becomes more readable</li></ul><br /><div class="MsoNormal"><span style="background-color: #fff2cc; font-size: large;"><br /></span></div><div class="MsoNormal"><span style="background-color: #fff2cc; font-size: large;">We talked about own attempt</span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">First topic is auto build and test with Eclipse. If you use this function, you can also do static analysis, code format and code coverage as follows. This is very easy.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">Second topic is '<a href="http://adlint.sourceforge.net/pmwiki/pmwiki.php?n=Main.HomePage?setlang=en" target="_blank">AdLint</a>'. This is new open source static code analysis tool. I talked my plan to introduce own environment. I want to show demo next time.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">Third topic is auto code formant with code formatting tool such as <a href="http://astyle.sourceforge.net/" target="_blank">Artistic Style</a>. You need to care when you use it on build process because it may make unintended code format. Manual execution may be better.<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US">Fourth topic is code coverage tool. '<a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_blank">lcov</a>' is good for gcc.<o:p></o:p></span></div><div class="MsoNormal"><br /><br /></div><div class="MsoNormal"><span lang="EN-US"><span style="background-color: #fff2cc; font-size: large;">What's next?</span><o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><span lang="EN-US"><a href="http://atnd.org/events/26137" target="_blank">Third meeting</a> will take place on April.<span style="font-family: 'ＭＳ 明朝', serif;">&nbsp;</span></span><span lang="EN-US">We will read the fifth chapter "Embedded TDD Strategy" and the sixth chapter "Yeah, but …". &nbsp;First one is good to adopt TDD to embedded system development. Second one gives us hints to recommend TDD to other people.&nbsp;<o:p></o:p></span></div>0Is TDD one of the solutions for difficulty of concurrent development of software and hardware?http://legobokueng.blogspot.com/2012/03/is-tdd-one-of-solutions-for-difficulty.htmlembeddedTDDnoreply@blogger.com (yohei)Fri, 16 Mar 2012 21:35:23 PDTtag:blogger.com,1999:blog-8130227023372706902.post-4228003903674371453In my 5 year experience of embedded software engineer, I became to think concurrent development of software and hardware is the biggest risk of embedded systems. I thinks TDD is one of the solutions for the problem. So I held a<a href="http://legobokueng.blogspot.com/2012/02/book-club-of-test-driven-development.html" target="_blank">&nbsp;book club</a> of&nbsp;"<a href="http://www.amazon.com/gp/product/193435662X/ref=as_li_tf_tl?ie=UTF8&amp;tag=legoboku-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=193435662X">Test Driven Development for Embedded C (Pragmatic Programmers)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=legoboku-20&amp;l=as2&amp;o=1&amp;a=193435662X" style="border-bottom-style: none !important; border-color: initial !important; border-image: initial !important; border-left-style: none !important; border-right-style: none !important; border-top-style: none !important; border-width: initial !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important;" width="1" />"&nbsp;in Tokyo. Here is my thought on how we fight with difficulty of&nbsp; concurrent&nbsp;development of software and hardware.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">Writing code for uncompleted hardware is so hard : (</span><br /><br />General process of embedded software development is as follows:<br /><ol><li>Developing software on own computer</li><li>Debugging on an evaluation board</li><li>Testing on a target hardware</li></ol>At the first step, we don't have the target hardware and have to write code for imaginary hardware that we have never seen. After we got the evaluation board, which is the second step, we try to debug on it to find bugs.<br /><br />Most of engineers that I have met try to debugging on an evaluation board as quickly as possible, so they tend not to care about testability for unit test. As a result, we get high coupling code.<br /><br />At the time, we have to advance the development with several risks as follows:<br /><ul><li>Own computer, evaluation board and target hardware have a little bit different library and compiler.</li><li>The evaluation board is bad in quality at the beginning of the development.</li><li>There are many mistakes in logic of code</li><li>Software engineer has to resolve underlying discrepancy in specification at the end of development.</li><li>etc.</li></ul>Problems occur someday. They make debugging time longer and distinguishing cause of bugs more difficult.<br /><br /><i style="background-color: #f3f3f3;">If we do agile software development for embedded software system, this will be a bottleneck.</i><br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">Dual-Target Testing</span><br /><br />For this problem, the author of "<a href="http://www.amazon.com/gp/product/193435662X/ref=as_li_tf_tl?ie=UTF8&amp;tag=legoboku-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=193435662X">Test Driven Development for Embedded C (Pragmatic Programmers)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=legoboku-20&amp;l=as2&amp;o=1&amp;a=193435662X" style="border: none !important; margin: 0px !important;" width="1" />" recommend hardware-independent software design and unit test on both of own computer and evaluation board from the beginning. This is called "Dual-Target Testing". If we do it from the beginning, we can eliminate bugs and make test easier.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">What do we need for Dual-Target Tesing</span><br /><br />At first, we need software design techniques to make software more testable. That is discussed in the books like "<a href="http://www.amazon.com/gp/product/0321146530/ref=as_li_tf_tl?ie=UTF8&amp;tag=legoboku-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0321146530">Test Driven Development: By Example</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=legoboku-20&amp;l=as2&amp;o=1&amp;a=0321146530" style="border: none !important; margin: 0px !important;" width="1" />" written by Kent-Beck or "<a href="http://www.amazon.com/gp/product/0131177052/ref=as_li_tf_tl?ie=UTF8&amp;tag=legoboku-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0131177052">Working Effectively with Legacy Code</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=legoboku-20&amp;l=as2&amp;o=1&amp;a=0131177052" style="border: none !important; margin: 0px !important;" width="1" />" written by Michael Feathers.<br /><br />Second, we need cooperation with hardware engineers for low layer software development. For example, in the book of "Test-Driven Development for Embedded C ", there is a scene that software engineer and hardware engineer are discussing about design of interface between software and hardware so that software engineer can decide design of Test Double.<br /><br /><br /><span style="background-color: #fff2cc; font-size: large;">What "Test-Driven Development for Embedded C" is doing for this?</span><br /><br />There are some code examples in my github. There is <a href="https://github.com/yohei1126/embeddedtdd/blob/master/src/LedDriver/LedDriver.c" target="_blank">product code</a> and <a href="https://github.com/yohei1126/embeddedtdd/blob/master/unity/LedDriver/LedDriverTest.c" target="_blank">test code</a> for LED driver.<br /><br />Key point of this example is a dependency injection at a constructor. Passing writing port address to constructor makes software independent with hardware. We can do unit test on both of own computer and the evaluation board.<br /><br />This driver has writing port only. State of LED driver is stored at variable ledsImage once, then write to the port. This was an issue that software engineer and hardware engineer discussed in the book.<br /><br />You might think that this example is quite simple and there are more difficult examples in real world. I think basic idea is the same as this example, which is interface design between software and hardware and low coupling software design against hardware and other software modules.<br /><br />I will held <a href="http://atnd.org/events/26137" target="_blank">the third monthly meeting</a> of "Test Driven Development for Embedded C" book club in Tokyo and see this problem deeply : )<br /><br />0The book club of "Test Driven Development for Embedded C" started in Tokyo, Japanhttp://legobokueng.blogspot.com/2012/02/book-club-of-test-driven-development.htmlbookCppUTestembeddedTDDunitynoreply@blogger.com (yohei)Tue, 07 Feb 2012 04:29:05 PSTtag:blogger.com,1999:blog-8130227023372706902.post-3985144525492314009<br />The book club started today : )<br /><br />Core members of the book club met at "TDD Boot Camp Tokyo for C++" in 2011. This was the event that embedded or game engineers got together and had a TDD practice.<br /><br />At that time, I wrote my position paper like this: "I want to learn TDD for embedded software, so I want to hold a book club of Test Driven Development for Embedded C. Why don't you join? " To my delight, two engineers said to me that they would join. After I called for participants of this book club on Twitter, 10 engineers joined! That was how we started.<br /><br /><span style="background-color: #fff2cc;"><span style="font-size: large;">What is motivation of participants?</span></span><br /><br />Participants are embedded software engineers of MFP, medical devices, communication devices, home electronics and etc. We have common point. We have legacy code, code without tests, in our projects and have a hard time of debugging. This is unpredictable activity.<br /><br />To reduce time of debugging, to discovery bugs rapidly, we are paying attention to TDD.<br /><br /><span style="background-color: #fff2cc;"><span style="font-size: large;">What we read today</span></span><br /><br />Today we read the first three chapters.<br /><br />The first chapter&nbsp;"Test Driven Development"&nbsp;introduces what is TDD, purpose of TDD and benefits of TDD.<br /><br />TDD is one of design techniques, so I can say that I do TDD to improve software design. But the biggest purpose of TDD is to prevent from bugs by getting quick feedback of test results and find mistake rapidly.<br /><br />The second chapter&nbsp;"Test Driving Tools and Conventions"&nbsp;introduces Unity for C and CppUTest for C/C++ as testing frameworks that were introduced in this book.<br /><br />CppUTest has a function to add tests into test suite automatically. This is very good for TDD.&nbsp;And it was developed with old function of C++ so that old compiles can compile it.<br /><br />Unity doesn't have a function to add tests automatically but there is ruby script to do it. It is very convenient.<br /><br />The third chapter&nbsp;"Starting a C Module "&nbsp;introduces the steps of TDD. We try practical example, LED driver. In this chapter, we can learn embedded software version of Dependency Injection. That is to put physical address of LED driver at runtime. With this way, we can separate software from hardware and we can get benefit to test without hardware.<br /><br /><span style="background-color: #fff2cc;"><span style="font-size: large;">What we didn't understand</span></span><br /><br />We didn't understand following two points.<br /><br />The first point. Can we design like this LED Driver example in real project? This example is OK because it is so simple. But in real project, dependency of hardware is so complicated. Changing physical address affects other hardware in some way. So we don't design like this.<br /><br />Maybe, we can test only where we want to test without representing complicated hardware interaction. (I don't know how to do it)<br /><br />Or, we don't test bottom of embedded software but focus on upper layer, which is hardware abstraction layer. That is easier to test than bottom layer. In this way, we can't test everything but we can reduce debugging time.<br /><br />The second point is how we test mass of legacy code. If we need too much time before starting TDD, we lose motivation. To do TDD for real project, we need way to reduce initial cost and introduce TDD incrementally. The 13th chapter may introduce how to fight against legacy code. In near future, we can learn how to do it : )<br /><br /><span style="background-color: #fff2cc;"><span style="font-size: large;">How I felt after first time</span></span><br /><br />We found that we have so many unknowns this time but we felt joyful that we got together at this book club. I want to say thank you to organizer of "TDD Boot Camp Tokyo for C++" and Mr. James W. Grenning. the author of Test Driven Development for Embedded C.<br /><br />My job is to make the place that participants can learn a lot and enjoy : )<br /><br />1How to compile googletest with gcc and CMake on Mac OS X SnowLeopardhttp://legobokueng.blogspot.com/2011/09/how-to-compile-googletest-with-gcc-and.htmlC++cmakeg++gccgoogletestMacOSnoreply@blogger.com (yohei)Sat, 18 Feb 2012 21:24:33 PSTtag:blogger.com,1999:blog-8130227023372706902.post-7547736714588452484I often found the way with Visual Studio C++ or XCode on web but I don't use them on my laptop. So I researched the way without IDE.<br /><br /><span class="Apple-style-span" style="font-size: large;"><b><u>My settings</u></b></span><br /><ul><li>Mac OS X 10.6.8（Snow Leopard）</li><li>&nbsp;gcc 4.5.4</li><li>cmake 2.8.5</li></ul>According to googletest's <a href="http://code.google.com/p/googletest/source/browse/trunk/README">README</a>, you need more than 2.6.4 of cmake but the version of gcc is not clear.<br /><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 18px; line-height: 24px;"></span><br /><div><b><u><span class="Apple-style-span" style="font-size: medium;">Process</span></u></b></div><div><ol><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Get source code of google test from svn repository</li><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Build googletest with cmake</li><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Create source file that has main function</li><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Create test code</li><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Build test code with g++</li><li style="margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;">Run the test</li></ol></div><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 18px; line-height: 24px;"><b><u>(1) Get source code of google test from svn repository</u></b></span><br /><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"></span><br />Place the source where you want.<br /><pre class="brush: shell">svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn<br /></pre><div><br /></div><b><u>(2) Build googletest with cmake</u></b><br />Make a directory that cmake runs, which is good for anywhere. &nbsp;{GTEST_DIR} is where theres is googletest. It is success when you get libgtest.a and libgtest_main.a after build. <br /><div><br /></div><pre class="brush: shell">mkdir mybuild<br />cd mybuild<br />cmake ${GTEST_DIR}<br />make<br /></pre><br /><b><u>(3) Create source file that has main function</u></b><br /><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px;"></span><br />Create source file that has main function. You can find sample as below link.<span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px;"></span><br /><div style="line-height: 22px;"><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px;"><a href="http://code.google.com/p/googletest/source/browse/trunk/src/gtest_main.cc" style="color: #2288bb; text-decoration: none;">http://code.google.com/p/googletest/source/browse/trunk/src/gtest_main.cc</a></span></div><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px;"></span><br />You have to call below functions in main function.<br /><ul><li>testing::InitGoogleTest(&amp;argc, argv);&nbsp;</li><li>RUN_ALL_TESTS();</li></ul><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px;"></span><br /><pre class="brush: cpp">#include &lt;iostream&gt;<br />#include "gtest/gtest.h"<br /><br />GTEST_API_ int main(int argc, char **argv) {<br /> std::cout &lt;&lt; "Running main() from testmain.cc\n";<br /><br /> testing::InitGoogleTest(&amp;argc, argv);<br /> return RUN_ALL_TESTS();<br />}<br /></pre><b><u>(4) Craeate test code</u></b><br /><pre class="brush: cpp">#include "gtest/gtest.h"<br /><br />TEST(firstTest, abs)<br />{<br /> EXPECT_EQ(1, abs( -1 ));<br /> EXPECT_EQ(1, abs( 1 ));<br />}<br /></pre><div><br /></div><b><u>(5) Build test code with g++</u></b><br /><div>You have to add the directory where there is googletest's header file into include path. You also have to build test code with static library of google test that you made at (2).</div><div><br /></div><div>As below, testmain.cc is a file that has main function and mytest.cc is a file that has test code.<span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"></span><br /><div><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"><br /></span></div><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"></span><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"></span><br /> <pre class="brush: shell"><br />g++ -I{GTEST_DIR}/include testmain.cc mytest.cc libgtest.a libgtest_main.a -o mytes<br /></pre> <span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"></span><br /><span class="Apple-style-span" style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 16px; line-height: 22px;"></span><b><u>(6) Run the test</u></b></div><div><span class="Apple-style-span" style="background-color: white;">Run the test. It is success if you see the test result as below. </span><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"></span><br /><div style="background-color: white; font-size: 16px; line-height: 22px;"><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><br /></span></div><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"></span><br /><div class="separator" style="background-color: white; clear: both; font-size: 16px; line-height: 22px; text-align: center;"><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><a href="http://3.bp.blogspot.com/-SSEapF4fBYo/TnkbOA9bW2I/AAAAAAAAMQE/YeSqdJpfBZI/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882011-09-20+23.07.41%25EF%25BC%2589.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="112" src="http://3.bp.blogspot.com/-SSEapF4fBYo/TnkbOA9bW2I/AAAAAAAAMQE/YeSqdJpfBZI/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882011-09-20+23.07.41%25EF%25BC%2589.png" width="320" /></a></span></div><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"></span><br /><div style="background-color: white; font-size: 16px; line-height: 22px;"><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><br /></span></div><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"></span></div>0auto_ptr and shared_ptr for resource managementhttp://legobokueng.blogspot.com/2011/09/autoptr-and-sharedptr-for-resource.htmlC++EffectiveC++TIPSnoreply@blogger.com (yohei)Sat, 25 Feb 2012 14:58:54 PSTtag:blogger.com,1999:blog-8130227023372706902.post-2220737165461881640<br />Resource management is common troublesome issue for C/C++ programmer. If you don't free a resource that you acquire, you will run out of resource some day.<br /><br /><a href="http://aristeia.com/">Scott Meyers</a>, the author of <a href="http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876">Effective C++</a>, recommended RAII(Resource Acquisition Is Initialization) for resource management. There are several ways to do it but simple way is to use auto_ptr and shared_ptr if your concern is about memory.<br /><br />Give you a couple of example.<br /><br />In this example, an error occurs before you delete an object that you acquirer, so resource leak happens. So you have to care about somebody except you because he can write a code that resource leak happens.<br /><br /><pre class="brush: cpp">Investment* createInvestment() {<br /> return new Investment;<br />}<br /><br />// an example of memory leak <br />void f1(){<br /> std::cout &lt;&lt; "f1" &lt;&lt; std::endl;<br /> try {<br /> Investment *pInv = createInvestment();<br /><br /> //If some one write code that can throws error, <br /> //destructor of Investment may not be called. <br /> throw 1;<br /><br /> delete pInv;<br /> } catch(...) {<br /> std::cout &lt;&lt; "catch" &lt;&lt; std::endl;<br /> }<br />}<br /></pre><br />In this example, I used auto_ptr for resource management. Now you don't need to care about resource. When the control flow leaves the scope, auto_ptr frees a pointer.<br /><br /><pre class="brush: cpp">//an example of auto_ptr <br />void f2(){<br /> std::cout &lt;&lt; "f2" &lt;&lt; std::endl;<br /><br /> try {<br /> //If you pass a pointer to auto_ptr, <br /> //auto_ptr frees it when the control flow leaves the scope. <br /> std::auto_ptr<investment> pInv(createInvestment());<br /> throw 1;<br /> } catch (...) {<br /> std::cout &lt;&lt; "catch" &lt;&lt; std::endl;<br /> }<br />}<br /></investment></pre><br />auto_ptr has several limitation. For example several auto_ptr cannot contain the same pointer. So you cannot put auto_ptr into STL container because STL container assume that every object can copy.<br /><br /><pre class="brush: cpp">void f3(){<br /> std::cout &lt;&lt; "f3" &lt;&lt; std::endl;<br /> //several auto_ptr cannot contain the same pointer. <br /> //If you copy auto_ptr, then the source becomes null pointer and <br /> //the destination can contain the pointer. <br /> Investment* pInv1 = createInvestment();<br /> std::auto_ptr<investment> pInv2(pInv1);<br /> std::auto_ptr<investment> pInv3(pInv2);<br />}<br /></investment></investment></pre><br />If you need to contain the same pointer with several auto_ptr, you should use shared_ptr in Boost Libraries. But shared_ptr has limitation. You cannot use it for an array.<br /><br /><pre class="brush: cpp">void f4(){<br /> //several shared_ptr objects can have the same pointer. <br /> boost::shared_ptr<investment> pInv1(createInvestment());<br /> boost::shared_ptr<investment> pInv2(pInv1);<br /><br /> //If every shared_ptr objects are freed, then the pointer <br /> //that they have also freed. <br />}<br /></investment></investment></pre><br /><br />Here is a sample code for this entry.<br /><a href="https://github.com/yohei1126/effectivecpp/blob/master/chap3/term13/Investment.cpp">https://github.com/yohei1126/effectivecpp/blob/master/chap3/term13/Investment.cpp</a><br /><br />There are other ways for resource management. I will write it some day :)<br /><div><br /></div>0One liner is a good way to do some smaller jobs in your lifehttp://legobokueng.blogspot.com/2011/09/one-liner-is-good-way-to-do-some.htmlOneLinerPerlProgrammingTIPSUNIXnoreply@blogger.com (yohei)Sat, 25 Feb 2012 15:00:14 PSTtag:blogger.com,1999:blog-8130227023372706902.post-7420164322054828977<br />Perl one liner is a good way to do some smaller jobs in daily life like renaming a file name or showing a file list.<br /><br />You may think that you can do it by writing a script or a program. But one of the advantages of one liner is that you can combine it with other command like UNIX pipe and filter.<br /><br />Here is an example of Perl one liner. You can pick up source files and header files for C/C++ language. It is not so difficult.<br /><br /><pre class="brush: shell">perl -MFile::Find -e 'find(sub {print "$File::Find::name\n" if $File::Find::name =~ /\.(c|cpp|h)$/ }, ".")'</pre><br />You may say that you want to write other language. It is OK. You can use any LL but you may have some limitation in older OS. For example, I am using Open VMS, which is OS by HP, and I can use only Perl in LL. It is good to learn basic of other language for you.<br /><br />I hope you will write some one liner in your work :)<br /><div><br /></div>0Best Cow Line (POJ 3617)http://legobokueng.blogspot.com/2011/09/best-cow-line-poj-3617.htmlAlgorithmC++noreply@blogger.com (yohei)Mon, 05 Sep 2011 01:14:39 PDTtag:blogger.com,1999:blog-8130227023372706902.post-1152759101507418588You actually can solve <a href="http://poj.org/problem?id=3617">the problem No. 3617</a> in POJ, Peking University Judge Online, with the greedy algorithm.<br /><br />The author of "<a href="http://www.amazon.co.jp/dp/4839931992">Programming contest challenge book</a>" says that the greedy algorithm is effective for a problem that deal with&nbsp;dictionally&nbsp;order.<br /><br />Here is more simple description of POJ 3617.<br /><br />- - - - -<br /><br /><br /><b><u>Description:</u></b><br />You have a string S that length is N and make a string T that length is N. At the beginning, length of S is zero. You can do either operation from below:<br /><br />&nbsp;- delete the first character of S and add it into the end of T<br />&nbsp;- delete the last character of S and add it into the end of T<br /><br />Make T as small as in dictionary order.<br /><br /><b><u>Constraint:</u></b><br />1 &lt;= N &lt;= 2000<br />string s can contain small alphabet.<br /><br /><b><u>Sample Input:</u></b><br />N = 6<br />S = "ABCDBCB"<br /><br /><b><u>Sample Output:</u></b><br />ABCBCD<br /><br /><b><u>My Solution:</u></b><br /><a href="https://github.com/yohei1126/pccb/blob/master/beginner/search/GreedyAlgorithm/BestCowLine/BestCowLine.cpp">https://github.com/yohei1126/pccb/blob/master/beginner/search/GreedyAlgorithm/BestCowLine/BestCowLine.cpp</a><br /><br />0nonadult