One week wearing a Moto 360 and Fitbit – Part Two

In the first part of this blog, I made a comparison between the major three apps associated with Moto 360 and Fitbit. In this part, I am comparing the data collected from those devices and mentioning which one I preferred.

Data comparison

I extracted the data collected from the two devices during this week and displayed a line chart for each dashboard (Number of Steps, Active Minutes, Calories Burnt and Distance Covered). Monday through Thursday, my activity was low because it only included going to work. On Friday and Saturday, it went a bit higher as I was walking around the city. And finally, on Sunday, I deliberately went for a 30 minutes run.

The charts below clearly show that both devices operate differently. In the case of ‘Active Minutes’ and ‘Calories Burnt’, Fitbit reported numbers 30 and 8 percent higher than the Moto360. Whereas for ‘Steps’ and ‘Distance’, Moto360 was higher by 7 and 15 percent respectively.

Here are the charts

Number of Steps


Active Minutes


Calories Burnt


Distance Covered



Obviously, one of those devices is reporting wrong values, or let’s say inaccurate ones! To know which, we need to understand in details each’s mechanism and then benchmark both and compare the results. I partially tried to do that in this blog. I did a simple benchmark by wearing both at the same time, although there might be a more accurate way but that was the easiest being an end user. I also read a lot about how Fitbit works (check this article), but couldn’t find anything on Moto360. That is why I decided not to include any summary of this mechanism in the blog.

I Chose the Moto360

In my opinion, Moto360 has all the functionalities Fitbit has except for three: sports compatibility (I won’t take the risk of playing squash with my Moto360!), sleep monitor and floor counter. On the other hand, since Fitbit HR is mainly an activity tracker, it lacks the major features of Moto360. Being a Smart Watch which means full integration with the apps on your phone. And, a better design, no one can argue that the Moto360 has a better look!

After a couple of months of wearing the Fitbit, it would be very easy to predict what it will be logging by the end of the day. So, unless you are a sports professional (you might then consider a more sophisticated activity tracker), the Fitbit would be more of an extra gadget on your wrist when wearing a SmartWatch at the same time.

For me, choosing between a smart watch that does everything and an activity tracking device was easy!


One week wearing a Moto 360 and Fitbit – Part One

In my previous post, I mentioned that I will be wearing the Moto360 (2nd gen) together with the Fitbit HR to make a comparison between the two devices. I did that for one full week, Monday to Sunday. And to have accurate results, I made sure to have both of them on at the same time.

I will divide my feedback and comparison into two blogs. In this part, I will be comparing the major three mobile apps associated with those devices (Google FitMotoBody, and Fitbit). Those apps are used to track, monitor and display the daily, weekly and monthly analysis of your activity.

Moto 360

Google Fit

It is Google’s default fitness tracking app, all the fitness data Google collects from you through any of its devices will be visible through this mobile app or the web interface. The app is installed by default on all Android devices, so whether you like it or not it will be there!

Supported Features:

  1. The default window displays Today’s totals (see image above)
  2. Collects data from the watch using MotoBody
  3. Displays six dashboards (Active Time, Distance, Calories, Steps, Weight and Heart Rate)
  4. You can quickly switch between dashboards
  5. Provides an easy way to manually log activities
  6. Tracks multiple activities (Walking, Running, Biking, Squash, Basketball, etc.)
  7. The activities are broken down to short activities (i.e. short walking intervals)
  8. Short activities are associated with some interesting details such as location, average pace, steps, etc. (left image below).
  9. Some dashboards display multiple activities on the same line chart graph, where each activity is a represented by a color (right image below).
  10. Data is also available on the web

Missing Features:  

  1. Still unstable! It took me many tries to be able to generate the dashboards
  2. It doesn’t display the totals on the top of the weekly dashboard
  3. Sleep and Floors dashboards
  4. The UI can be improved.


On the other hand, MotoBody is the app developed by Motorola for its wear devices. It is essential to have it installed to get the best experience of the Moto360. Unfortunately, I found that it lacks some features.


Supported Features:

  1. Fully integrated with the watch (watch screenshots above)
  2. It has dashboards for Active Minutes, Steps, Calories and Running
  3. It has a good UI that makes it a user-friendly app
  4. The default dashboard displays the data for Heart Activity, Steps, and Calories in the same window
  5. Easily swipe between daily and weekly dashboard
  6. The detailed weekly dashboards have two types of charts (line and bar)
  7. Compares the data from current week with the previous one (gray line image below)
  8. The weekly dashboard displays the total and daily average on the top

Missing Features:

  1. Dashboards for Distance, HeartRate, Sleep
  2. It only shows the daily average, so you will not be able to view your hourly activity
  3. It limits the exercises to Steps and Running
  4. There is no web interface.


You can find tens of apps integrated with the Fitbit device. But I think the official one developed by Fitbit is good enough that you won’t need to check any other, at least, I didn’t.


Supported :

  1. Its default window is the daily dashboard displaying all information the device collects (Heart Rate, Active Minutes, Steps, Sleep, etc.)
  2. The daily detailed dashboards display your hourly progress
  3. The weekly dashboard shows the total and daily average on the top
  4. Tracks multiple exercises:
    1. Allows users to start manually outdoor activities (run, walk or hike)
    2. Associates exercises with a map, calories, time and average heart rate
    3. Manually log previous exercises
    4. The latest update automatically tracks six types of activities (walk, run, outdoor bike, elliptical, sport and aerobic workout)
  5. Provides helpful and motivating features such as rewarding badges when exceeding a certain limit
  6. Allows you to connect and compares status with Facebook friends
  7. A customizable web interface

Missing Features:

  1. Requires many user actions to move between the dashboards
  2. Although it displays the hourly activities, it doesn’t show short activities like the Google Fit.
  3. Google Fit supports more exercises

Next Blog

In my next blog, I will be comparing the data collected during that week and explaining why I preferred the Moto 360 over the Fitbit.


Moto 360 (2nd gen)

Last week, I received a package from Amazon containing my new smart watch (Moto 360 2nd gen). Purchasing a smartwatch was on my mind since Google released the 1st generation of the Moto 360 back in September 2014, but I kept on waiting. Two months ago I started comparing reviews of the available Android wears; the competition was mainly between Huawei Watch and Moto 360 2nd gen. I chose the later for one reason only, the diameter size! I thought the 42mm diameter would be a bit small!

Brown vs. Black

Initially, I wanted to buy the black watch (bezel, case and band) that would have looked like this:


But I didn’t manage to do that due to unavailability on Amazon-FR, and since I don’t live in the U.S, it becomes harder to have it shipped from the Motorolla website. So I ended up buying the silver watch with a brown leather band (check featured image). Well, it didn’t turn out to be a bad thing after all! The combination of silver and brown color looks elegant and beautiful, plus, you can easily buy and change those bands later.

My Review

I bought the watch because I want to get into the field of Android development (phone & wear), so, I will be leaving my detailed reviews for later blogs after digging into its details.

Moto 360 vs. Fitbit HR

Almost a year ago, I bought the Fitbit HR to track my activity. I used to wear it on my right hand with my Tissot watch on the left, well that looked ridiculous!! 🙂 Now, the Moto 360 will replace both devices. But before taking the Fitbit off, I will be comparing the data collected from both devices since they both has some smart features in common. That will be the content of my next blog!


My First Audible Experience

The featured image is a screen shot of the last chapter of “Soft Skills: The software developer’s life manual” on Audible. It was an indication that I had just finished my first audible book!! Honestly, I never thought I would be listening to books; it always sounded weird to me.

It all started a couple of weeks ago when Philippe suggested that I listen to this book in parallel to the other books I am reading (The Power of Full Engagement and Refactoring: Improving the Design of Existing Code). Knowing Philippe, it has to be worth a try if it something he is suggesting 🙂 After our discussion, I directly logged-in to my Amazon account and noticed that I had two free Audible books!! It was a matter of minutes to have both the book and the Audible application downloaded on my phone.

My Feedback

It turned out I was wrong. It was an exciting and enjoyable experience and here is why:

  1. It is more accessible than reading books. Unlike reading a hard copy of book, you can play Audible at almost any time and place (while driving, jogging, onboard a plane, etc.)
  2. It is unlikely to be exhausted to listen. I was on a night flight back home, after spending the first thirty minutes of the flight reading a book I reached a point where I wasn’t able to digest the words anymore. So I switched to my phone and started listening to the book, I was surprised that the remaining two hours of the flight passed quickly. It was then that I noticed that even if you are too tired to read you still can listen and learn.
  3. You can finish books faster. The above two points have a significant role in speeding up the process. I managed to finish this book in 15 days; it might not be a great timing, but it is definitely faster than reading the book.
  4. Audible is a great application. I haven’t explored each and every feature of this tool yet, but I think it is a great one for the following reasons:
    • You can quickly add bookmarks with notes if needed
    • Synchronization between the web and phone applications makes it easy to switch between the two
    • It motivates the listener by rewarding badges and suggesting bragging about it on social media
    • It has an excellent playback system especially when you get interrupted by a phone call or notification
  5. Soft Skills was a good selection. Probably the book I picked to be my first audible experience helped to build this positive feedback. The book itself is excellent, and a must read for all developers. The narrator, as well, being the author added a unique taste by improvising and sharing his personal experience from outside the book.

I highly advise anyone to give Audible a try. Personally, now am looking for the next book to listen to! Any suggestions? 🙂

How to reference Ruby-JMeter from Java project?


Apache JMeter is an open-source Java application that allows you to design, build and run performance tests. It is an excellent tool and currently we are using it to analyze our software’s performance. But being a graphical tool, after building a couple of tests you will notice that most of the test steps were repeated each time. It becomes frustrating and a waste of time and here is when Ruby-JMeter comes to the rescue!!! Ruby-JMeter is a tool that allows you to write your JMeter test plan in Ruby and then convert it to a JMX file. Since it is an open-source project, you have the flexibility of extending it and customizing it to fit your needs.

How can this tutorial benefit you?l

The purpose of this tutorial is to show how to integrate ruby-jmeter within a Java project. We are using this integration in an in-house Java based benchmark framework that dynamically reads and executes JMX files. Another way to benefit from this tutorial is if you want to reference any of the RubyGems from your application. Ruby-jmeter is one of the gems hosted on RubyGems, thus, you can follow the steps defined in the 2nd part of the tutorial to reference other gems.

Tutorial Structure

I have divided this tutorial into three sections. The first one shows how to execute ruby scripts directly from Java; the second section shows how to ruby ruby-jmeter scripts from Java. Whereas the last section is dedicated from some refactoring of our test class.

Executing Ruby Scripts

1. Maven Dependency

One of the possible options to run Ruby from Java is by using JRuby.
Since we are writing a maven project, then we need to add JRuby dependency in our pom. To do that we just add the following dependency to the dependencies section of our pom.Xml file.


2. RubyExecutor

Now we can reference JRuby in our code, so let us start by adding a new java file “RubyExecutor” to our project. In this class, we will add a static method that takes the full path of the ruby script as a parameter.

Below is the code for the method:

public class RubyExecutor {
    public static void run(String rubyFile) throws FileNotFoundException, ScriptException {
         final ScriptEngine scriptEngine = new JRubyEngineFactory().getScriptEngine();
         final FileReader rubyFileReader = new FileReader(rubyFilePath);

The first line initializes an instance of JRubyEngine.
The third line just calls the eval method that is responsible for executing the ruby code in the JRubyEngine.

3. Testing our code

The best way to assert our code is working as we want, is by writing JUnit tests. In this case, we can add a new test class under “src/test/java”.
For simplicity, we will make our ruby code generate a new file at the end of its execution. This generated file has the same filename but with “jmx” as an extension.
Based on that we should make our test call the method and assert that a new file has been added.
First we should start by writing a simple ruby script in the test-resources folder.


  1. Add a new folder “src/test/resources/RubyExecutor”
  2. Add a new ruby file “simpleCode.rb” under that folder
  3. Add the following code to the Ruby script. This code creates a new empty file with the name “simpleCode.jmx”
`'target/test-classes/RubyExecutor/simpleCode.jmx', "w+")`

Now we can write our test class that should look like this:

public class RubyExecutorTest {
    public void
    it_should_generate_a_file_from_ruby_code() throws IOException, ScriptException {
       final String rubyFile = this.getClass().getResource("/RubyExecutor/simpleCode.rb").getFile();;
       final File expectedFile = new File(rubyFile.replace("rb", "jmx"));

The test asks the RubyExecutor to execute the ruby script named “simpleCode.rb” (the one we created in previous steps) and asserts that the file “simpleCode.jmx” has been created.
Now let us try to run the test using maven command. To do so run the below command from the directory “jruby-jmeter-integration”

mvn clean install

The tests should be green, and we should get the following success message:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:17 min

We should also notice that the file “simpleCode.jmx” has been created under “target/test-classes/RubyExecutor/”
Note: I use the library org.fest.assertions.Assertions, thus make sure you have added it to your dependencies in maven.

Executing Ruby-JMeter Scripts

Now that we are capable of executing Ruby scripts from our project, we will work on running ruby-jmeter scripts.

1. Ruby-JMeter

As stated earlier, ruby-jmeter is a tool that allows you to define your jmeter test-plan in Ruby code. The tool provides methods for most of the JMeter controllers, thus, it is a matter of calling the right method with the right parameters. Upon execution, the tool will generate a JMX file from the Ruby code.
I’m not going to dig into details on how it works, for more details you can have a look at some examples available on project’s workspace on GitHub

Now it is time to write a simple test plan with ruby-jmeter.


  1. Add a new ruby script “src/test/resources/RubyExecutor/simpleJmx.rb”
  2. Add the following code to the Ruby script:
require 'rubygems'
require 'ruby-jmeter'   
test do
  threads count: 1, rampup: 0, loops: 1, scheduler: false do
    beanshell_sampler query:'"********Hello World********");'
end.jmx(file: 'target/test-classes/RubyExecutor/simpleJmx.jmx')

This ruby code will do the following:

  1. Create a new test plan
  2. Add a new “Thread Group” with a single thread and single loop count
  3. Adds a BeanShellSampler as a child of the thread group to print “********Hello World********”
  4. Saves the test-plan in the file simpleJmx.jmx

The generated JMX file should look like this:


2. Ruby-JMeter within our maven project

Now we know exactly what our code should do; what are its input and output. So, it would be great if we write a JUnit test to check if our code has indeed generated a JMX file from the Ruby script we wrote in the previous section.
So our test should execute the ruby script and is expected to generate the respective JMX file (“target/test-classes/RubyExecutor/simpleJmx.jmx”) at the end of the execution.
Based on this, we can add a new test to

public void
it_should_generate_a_jmx_file_from_ruby_code() throws IOException, ScriptException {
 final String rubyFile = this.getClass().getResource("/RubyExecutor/simpleJmx.rb").getFile();;
 final File expectedFile = new File(rubyFile.replace("rb", "jmx"));

Let us give it a try:

mvn clean install

Unfortunately if fails:

LoadError: no such file to load -- ruby-jmeter
    require at org/jruby/
    require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
        <top> at <script>:2
    Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.657 sec <<< FAILURE!
    it_should_generate_a_jmx_file_from_ruby_code(RubyExecutorTest)  Time elapsed: 11.446 sec  <<< ERROR!
    javax.script.ScriptException: org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- ruby-jmeter
        at org.jruby.embed.jsr223.JRubyEngine.wrapException(
        at org.jruby.embed.jsr223.JRubyEngine.eval(
        at org.jruby.embed.jsr223.JRubyEngine.eval(

The exception is telling us that it couldn’t execute ruby-jmeter. Maven wasn’t able to locate the ruby-jmeter libraries as we haven’t referenced it yet in any of our code.
To fix this problem, we will have to add more dependencies to our pom file!

3. Ruby-Gems Dependency

RubyGems is a repository hosting Ruby community’s gems. Once referenced, Maven will access this repository to sync the required ruby libraries locally to your project.
In our case we are using the ruby-jmeter gems to add dependency on that we should modify our pom file as follows:

1.  Add repository: This will be used by maven to download the gems from the specified URL


2.  Add dependency on ruby-jmeter


3.  Add build step


4.  Rerun maven:

mvn clean install

Now we should get a “Build Success.”

 T E S T S
Running RubyExecutorTest
I, [2015-12-23T17:27:19.643000 #7564]  INFO -- : Test plan saved to: target/test-classes/RubyExecutor/simpleJmx.jmx
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.278 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ java-ruby-jmeter-integration ---
[INFO] Building jar: D:\Dev\java\workspace\GitHub\sample-projects\jruby-jmeter-integration\target\java-ruby-jmeter-integration-1.0-SNAPSHOT.jar
[INFO] --- maven-install-plugin:2.4:install (default-install) @ java-ruby-jmeter-integration ---
[INFO] Installing D:\Dev\java\workspace\GitHub\sample-projects\jruby-jmeter-integration\target\java-ruby-jmeter-integration-1.0-SNAPSHOT.jar to D:\Dev\maven_repo\aatwi\github\java-ruby-jmeter-integration\1.0-SNAPSHOT\java-ruby-jmeter-integration-1.0-SNAPSHOT.jar
[INFO] Installing D:\Dev\java\workspace\GitHub\sample-projects\jruby-jmeter-integration\pom.xml to D:\Dev\maven_repo\aatwi\github\java-ruby-jmeter-integration\1.0-SNAPSHOT\java-ruby-jmeter-integration-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------

Code Refactoring

The last part of this tutorial is to do some code refactoring to our test class. Although it isn’t essential here, it became a habit for me!!
If we look at our current code, we can notice that there is some code duplication in the two tests.
One thing we can do here is extracting the method “assertJmxFileExists” to remove this duplication.
Our new method will take the responsibility of calling and asserting the generation of the JMX file.
The code below shows the difference before and after refactoring.
Before Refactoring:

public void
it_should_generate_a_file_from_ruby_code() throws IOException, ScriptException {
    final String rubyFile = this.getClass().getResource("/RubyExecutor/simpleCode.rb").getFile();;
    final File expectedFile = new File(rubyFile.replace("rb", "jmx"));

public void
it_should_generate_a_jmx_file_from_ruby_code() throws IOException, ScriptException {
    final String rubyFile = this.getClass().getResource("/RubyExecutor/simpleJmx.rb").getFile();;
    final File expectedFile = new File(rubyFile.replace("rb", "jmx"));

After Refactoring:

public void
it_should_generate_a_file_from_ruby_code() throws IOException, ScriptException {

public void
it_should_generate_a_jmx_file_from_ruby_code() throws IOException, ScriptException {

private void assertJmxFileExists(final String rubyScript) throws IOException, ScriptException {
    final String rubyFile = this.getClass().getResource("/RubyExecutor/" + rubyScript).getFile();;
    final File expectedJmxFile = new File(rubyFile.replace("rb", "jmx"));

We can do more refactoring, but I think it is not worth at this point. The code is simple and can be easily read and understood.
Finally, rerun maven to make sure that nothing was broken with this refactoring.


Let’s make the tests green

Two weeks ago we started running coding dojo sessions at our offices in Beirut, the first sessions we had so far were much better than what we expected. In this article, I will be sharing my experience (as the one running those sessions) starting from the preparation and ending by the feedback on those sessions.


What is CodingDojo?

CodingDojo is a meeting where a group of people gets together to solve a programming challenge following TDD. We select those challenges from several online sites like Google Code Jam and Cyber Dojo.
Each dojo session is planned to take 2 hours including a 15-minute retrospective at the end and is scheduled once every week.  
All the participants are contributors, as we rotate on the driver (one who is coding) every 5 minutes. Thus, it is important to limit the number of participants per session to a maximum of 8
We carefully chose the session timings to be during lunchtime from 12:00 to 14:00 in order not to interrupt participants’ usual tasks. 
Finally, it is important to note that the participation to those sessions is not restricted to specific teams, rather anyone regardless of their programming expertise is welcome to join. After all, codingdojo is a place where we take knowledge sharing to the extreme. 


From Paris to Beirut 


It started almost 2 years ago as an activity within our team members only, but 8 months ago it was changed to involve interested people from other teams (in Paris only) as well. By the end of each session a 15-minute retrospective was held, during which we have always received positive feedback from the participants. For them, it was a chance to learn how to write code following TDD, learn new programming languages and techniques and enjoy a teamwork spirit to solve a programming challenge.  
We decided to leverage on the experience we gained in Paris and start similar sessions in Beirut. At that point, we had no clue on the participation level or its success rate but it was a risk we were willing to take. 





The first step of the preparation was to contact the HR team asking them for sponsorship as such an activity involves communication and involvement of many teams. We had a meeting with them, explained what codingdojo is and what is expected from those sessions; as expected, they were very supportive to such an initiative. They granted us their sponsorship and offered their help in global communication, coordination with the administration to provide lunch for participants and whenever needed later. 

Second came the technical preparation for better running and managing such an activity. Writing code following TDD became a habit as I have been doing that for more than a year and a half (since I joined my new team). But still I decided to practice more by solving some challenges outside working hours.
For me managing such sessions was the main challenge and a new experience. For that, I started attending (via Visio conference) the sessions managed by Philippe (my teammate in Paris). During which, I tried to benefit from Philippe’s experience and save tips and advice he provided. Finally, we also agreed with Antoine (my teammate in Paris) to visit Beirut and assist me in running the first two sessions.



After setting the start date to be on Wednesday, July 15, 2015, we sent a communication email to all Beirut employees announcing the kick-off of codingdojo and opening the door for registration. In less than one day, more than 30 participants were registered. That was a surprise!!! We weren’t expecting that many participants, especially that many of them were not developers. Since running a single session with 30 participants was impossible, we decided to divide the participants into 4 groups/sessions over the following 4 weeks.


First Two Sessions 

For the first 2 sessions, Antoine and I prepared very well by selecting and solving the problems ahead of time. Despite that, we made sure not to impose our solution, rather we tried to have an open discussion and agree with the rest on the next tests to write.

The first 30 minutes of both sessions were the hardest. Almost all participants were not familiar with the concept of writing the test before the code that is why we made sure to be the first 2 to drive the code and when someone was coding you would hear us saying “That is correct, but you forgot to write the test!” when others were coding. After that, things started to go smoother! Participants got acquainted with the concept and were aware when they missed the tests.  

For us, the first two sessions were great and much better than what we expected. We expected to have someone trying to control keyboard or dictating his solution. On the contrary, everyone respected the 5-minute limit they had. They were all sharing the solution with others. 
It was clear to us, from the feedback (listed below) we got from participants during the retrospective, that they enjoyed their time and are willing to attend future sessions:

  • Nice, good experience; you learn from others 
  • Nice technique to learn when trying to write the first test and nice way to think incrementally
  • It is hard to do it alone; it is easier with a group 
  • I am not a developer and not familiar to Java, but it was good to see the mindset of the developers
  • Nice to meet people from other teams
  • Nice practice because you are enforced to follow a convention; taught us new best practices 
  • I like the idea of refactoring; the complex code was refactored into couple lines of code that made it more readable 
  • TDD is a bit slow; the pros are the interaction between each other 

My Feedback

Running those sessions is not an easy task, it requires a lot of effort before and during each session. Before any session, the leader should prepare the right environment for the participants. During the session, the leader should always be focused on what the driver is writing and at the same time listen to suggestion proposed by others and answer the questions raised.
Despite that, it is a great experience from which you learn and gain a lot.
Later in coming sessions we might be introducing some new challenges like increasing the problem complexity or trying new programming languages. I hope that people will remain motivated and enthusiastic to attend the coming sessions!

P.S: The code we write during those sessions will be committed to this GitHub repository.