2013-05-06

Tanita Segmental Body Composition Scale BC-545N

Experiences with the FitBit Aria and the Withings WS-50 Smart Body Analyzer showed me that I don't need a scale with
  • Wi-Fi capabilities
  • Air quality measurement
  • iPhone app
  • Web dashboard.
What I really need is a reliable device based on scientific and medical knowledge supporting me in understanding my body composition - this is how I got to the third and final choice, the Tanita BC-545N

You don't have to set it up either via Bluetooth or Wi-Fi, because it only stores data in its memory. Thus to make graphs and over-time analysis you'll have to enter data manually either on their site called WeightCheckers or simply into a spreadsheet (this is how I do it). But, in order to understand all the metrics provided by the device you need 1-2 minutes anyway and that's sufficient to do the typing.

With these measurements you can set a correct focus for you (and up to 4 further persons with automatic recognition):
  • Weight
  • Body Fat %
  • Body Fat Healthy Range Indicator
  • Total Body Water %
  • Muscle Mass
  • Physique Rating
  • Bone Mineral Mass
  • Basal Metabolic Rate
  • Metabolic Age
  • Body Mass Index
  • Visceral Fat
  • Visceral Fat Healthy Range Indicator
  • 5 Segmental Fat Readings (trunk, right and left arms and legs)
  • 5 Segmental Muscle Readings (trunk, right and left arms and legs).
I'm satisfied with this product after a few days of usage and can only recommend it.

2013-04-18

Fitbit Aria

After having sent back the Withings WS-50 scale (for details read my previous blog entry http://www.andrashatvani.com/2013/04/withings-ws-50-smart-body-analyzer.html) I decided to try the Fitbit Aria.
Here I provide a very short comparison with the WS-50 and a conclusion, too.

Advantages:

  • Cheaper by € 40
  • Doesn't need a smartphone for the setup/scale assignment, because it will be done via the Mac/PC
Disadvantages

  • You must buy a premium account for € 44,99/year to be able to access all the fitness-reports 
  • No air quality measurement
  • No heart rate measurement.
I've already started the return process of this device, too…

2013-04-07

Withings WS-50 Smart Body Analyzer

I was one of the first few who ordered this device: http://www.withings.com/en/bodyanalyzer and I'd like to share my experiences and problems I encountered.


Experiences

I keep the device in the bedroom as it is suggested by Withings and (opposed to their recommendation) I weigh myself each and every day.
  • Body weight: The records show a daily variation of 2-3 kg, but as far as I know this is normal for a me-sized human.
  • Fat and lean mass: I can't really judge, whether the values are correct, but I have to assume, since I want to keep the device. 
  • Heart rate: It requires discipline to ensure identical breathing and other preconditions; for me it will take a few more days…
  • Air quality (CO2): The device analyzes the air every half an hour and submits the values upon each scaling or every 12 hours. It really helps to improve my ventilation habits.
  • Data synchronization: The data shows up immediately after the scaling has been completed. 
  • Scale display: Crystal clear and pleasant white-on-black.
  • Usage by non-registered users: The data can be assigned to a user to be created.

Issues

  • The scale couldn't connect to my 1st gen. Time Capsule (5 years old)  which was set to the radio mode "802.11n (5GHz only)". I had to set the radio mode to 802.11n 2.4GHz, to make it work, but this is a performance degradation resulting in half of the bandwidth as on 5GHz.
  • The web dashboard doesn't yet fully support the device
Heart rate and air quality metrics are missing
  • Assigning the scale to a further user account results in going through the whole setup process again.
  • The scale suddenly started to measure unbelievably high CO2 values, where blue is around 50 ppm and brown is around 65.500 ppm (would be normally a very dangerous concentration)
Invalid measurement data
  • The scale measured −4,5% fat mass reduction in just two days - also impossible.
These issues force me not to recommend the scale as I'm thinking about returning it, because I don't trust it anymore…


2012-03-22

Refactoring and the Visitor pattern 2. (Spring)

After showing how to decouple subtypes indirectly coupled to a base type via the Visitor pattern in the first part of this writing I demonstrate something more sophisticated.

In the same system another usage of the Visitor pattern impeded the refactoring: In the last of a chain of six singleton Spring collaborators a visitor has been used to accomplish a certain task by visiting the current instance of the blackboard subtype which has been presented in the previous post.
public class CollaboratorUsingVisitor {
  ...
  public void useVisitor(BlackBoardBaseType blackBoard) {
    ...
    TaskAccomplishingVisitor visitor = new TaskAccomplishingVisitor();
    blackBoard.accept(visitor);
    Result result = visitor.getResult();
    ...
  }
  ...
}

public class TaskAccomplishingVisitor implements BlackBoardVisitor {

  private Result result;

  public void visit(BlackBoardSubType1 blackBoardSubType) { ... }
  ...
  public void visit(BlackBoardSubTypeN blackBoardSubType) { ... }

  public Result getResult() { return result; }

}
It can be seen that on every call of the method useVisitor() a new instance of the visitor is created. Since I needed to extract the whole collaborator chain, too, I needed to abstract this visitor from the blackboard subtypes as well. But in order to achieve this a special case collaboration had to be implemented: Singleton collaborator using prototype visitor. It is not very widespread, at least according to the systems which I've seen so far, but definitely a clean solution, because Spring supports lookup-method injection since version 1.x.
There was an additional step to get in a state where the this kind of injection could be applied: Extract an interface specifying the method returning the computed result.
After finishing the refactoring this is how the Java code looked like:

public abstract class CollaboratorUsingVisitor {
  ...
  public void useVisitor(BlackBoardBaseType blackBoard) {
    ...
    TaskAccomplishingVisitor visitor = createVisitor();
    blackBoard.accept(visitor);
    Result result = visitor.getResult();
    ...
  }

  public abstract TaskAccomplishingVisitor createVisitor();
  ...
}

public class ExistingTaskAccomplishingVisitor implements BlackBoardVisitor, TaskAccomplishingVisitor {

  private Result result;

  public void visit(BlackBoardSubType1 blackBoardSubType) { ... }
  ...
  public void visit(BlackBoardSubTypeN blackBoardSubType) { ... }

  public Result getResult() { return result; }
}

public class NewTaskAccomplishingVisitor implements TaskAccomplishingVisitor {
  public Result getResult() { return new Result(); }
}
And this is a snippet of the Spring XML configuration holding the bean definitions for the old and the new module:













In case of the new visitor in the new module there were no requirements regarding what result to deliver, therefore if was completely sufficient to return just a dummy result. With this whole change the collaborator chain could be abstracted and duplicated without having to extract the blackboard subtypes.

2012-03-21

Refactoring and the Visitor pattern 1.

I like the Visitor pattern as one tool for embracing the Open-Closed Principle.
In one of my clients' project I faced two situations where it almost prevented refactoring and since I think the two cases are interesting and important enough I'll demonstrate them in two blog posts.

My roles in the project were development lead, architect and coach and with these responsibilities I tried to improve both, the system's structure and architecture as much as possible. One structural issue was that all subtypes of a generic and central abstract type implementing the blackboard architectural pattern were put in the same module. This lead to a confusing and complicated hierarchy consisting of more than 100 packages and more than 1.000 classes.
I didn't want to let that module grow further for obvious reasons, so I decided to create two new modules: One for the new subtype and another one for components and classes commonly used by the old and the new module. This is why I have extracted the blackboard base type into the commons module and had to deal with the Visitor pattern.
The code was similar to the following:
public abstract class BlackBoardBaseType {
  ...
  public abstract void accept(BlackBoardVisitor visitor);
}

public interface BlackBoardVisitor {

  visit(BlackBoardSubType1 blackBoardSubType);
  ...
  visit(BlackBoardSubTypeN blackBoardSubType);
}

public class BlackBoardSubType1 extends BlackBoardBaseType {
  ...
  public void accept(BlackBoardVisitor visitor) {
    visitor.visit(this);
  }
}

public class BlackBoardSubTypeN extends BlackBoardBaseType {
  ...
  public void accept(BlackBoardVisitor visitor) {
    visitor.visit(this);
  }
}

So if I just would have taken the base type without modification, then I should have extracted all its subtypes, too, because of the visitor. Therefore an extra step was necessary, namely the abstraction of the visitor from the concrete subtypes, what I have solved by introducing an empty (in other uses marker) interface.
public abstract class BlackBoardBaseType {
  ...
  public abstract void accept(EmptyBlackBoardVisitor visitor);
}

public interface EmptyBlackBoardVisitor {
}

public interface BlackBoardVisitor extends EmptyBlackBoardVisitor {

  visit(BlackBoardSubType1 blackBoardSubType);
  ...
  visit(BlackBoardSubTypeN blackBoardSubType);
}

public class BlackBoardSubType1 extends BlackBoardBaseType {
  ...
  public void accept(EmptyBlackBoardVisitor visitor) {
    visitor.visit(this);
  }
}

public class BlackBoardSubTypeN extends BlackBoardBaseType {
  ...
  public void accept(EmptyBlackBoardVisitor visitor) {
    visitor.visit(this);
  }
}

By doing so there was no indirect dependency of the base type on the sub types via the visitor anymore and I could extract it and also implement the new subtype.

2012-03-05

Disable overriding of Spring beans in web applications

I came across this issue when I was working on a client's project which utilizes Spring for wiring dependencies. A new module in the project used the same web services as another one, so it was pretty easy for my junior co-workers to assign already used component names, thus introducing system-wide heavy failures.Although the usage of prefixes theoretically solves the issue, in practice there is no protection for overriding beans if you use a Spring container with the default setting.
Changing such settings is no problem in applications where you have the control of instantiating the container, but it is cumbersome in case of web applications using Spring's ContextLoaderListener for booting the container. Namely, this ServletContextListener takes care of the creation of the appropriate ContextLoader, which in turn constructs the ConfigurableWebApplicationContext whose properties can be adjusted.
So the following steps are required to disable bean definition overriding in a web app:
It would be much better and natural to support a servlet context parameter (such as contextConfigLocation) for setting this essential behavior. 

2012-01-27

JRebel for free and a bug

I've been using JRebel at a client's site for several months by now and I'm very pleased with it. So I decided to use it for my private projects, too. The prices aren't that high, but then I discovered, that ZeroTurnaround offers it just for the price of one tweet or wall message per month. I think this is a great opportunity for them to gain customers by letting them enjoying the advantages of the tool at no charge for an unlimited period of time. Check it out at https://social.jrebel.com/ .

The reason for my increased interest was the following bug which I discovered yesterday and wanted the developers to know that it exists, so I posted a message in their forum with the following description:


The following scenario caused JRebel and thus also the container to hang:

Project structure:
master
|_ module1 - contains Mapping.hbm.xml
|_ module2 - also contains a Mapping.hbm.xml


Renaming one of the mapping files solved the issue, whose cause was very hard to find.
Multiple identical Spring configuration file names are in contrast no problem.


Build system: Maven 3
Container: JBoss 4.2.3
JRebel version: 4.5.4
Hibernate version: 3.3
Java version: 1.6.29
OS: Windows 7

I'm curious, whether and when they react and how they will handle the issue.

UPDATE: Just only a few hours after this post has been submitted it got comments from two developers of ZeroTurnaround - this is what I call excellent service!