Tuesday, May 1, 2012

Tip for using Sencha Touch DataView setData() with inline data


Watch out for this gotcha when using Sencha Touch 2.0 DataView with inline data.  DataView.setData() does not swap out existing data.  Instead it appends to the data.  So this code:

var view = Ext.create('Ext.DataView', {
 fullscreen: true,
 store: {
  fields: ['name', 'salary'],
  data: [
   {name: 'Maxine', salary: 200000},
   {name: 'Minnie', salary: 10000}
  ]
 },
 itemTpl: '{name} makes {salary}'
});
view.setData([
 {name: 'Maxine', salary: 200000},
 {name: 'Minnie', salary: 10000},
 {name: 'Me', salary: 999999}
]);


...will end up with 5 records instead of 3.  =(  Strikes me as a bug.

Luckily the fix/work-around is simple.  Call getStore() first:

view.getStore().setData([
...

Friday, June 17, 2011

Wednesday, March 2, 2011

Need BlackBerry 4.5 Simulator to start with app-param JvmDebugLocks enabled?

For some reason when running the BlackBerry 4.5 simulator (downloaded just a couple months ago), you may have some trouble setting app-param JvmDebugLocks that enables debugging of locks for concurrency.  JvmDebugLocks is a nice feature, because it detects interlocks among other things.  Well, if you add the text "/app-param=JvmDebugLocks" in your simulator startup script (such as defaultSimulator.bat), unfortunately the simulator may not start.  It will give a JVM error and complain about net_rim_font_system.cod in the simulator log file (such as 8300.xml-(YYYY-MM-DD).log).  Note that I'm not referring to the BlackBerry solution described here about specifying a language for your simulator, because recent simulators should come already with a valid language entry.  Instead, Platform.alx seems to have missing font files specified.  Open Platform.alx and change net_rim_font_system.cod to net_rim_font_latin_truetype.cod everywhere in the file.  That is assuming you're using a Latin font; otherwise change it to whichever file you want to use from your Java subfolder of simulator.  Start the simulator again and you should be good to go.

Tuesday, January 25, 2011

Nuggets of Testing Wisdom from Kent Beck on Software Engineering Radio

I really like this interview on Software Engineering Radio with Kent Beck by Martin Lippert: Episode 167: The History of JUnit and the Future of Testing with Kent Beck".  A few good tidbits:

  • Testing at different levels: In response to a question about the development of BDD (behavioral driven testing) in response to his TDD (test driven development), he mentions the importance of testing at different levels of code, from unit tests to behavioral or acceptance tests, suggesting that BDD is entirely compatible with and perhaps a refinement of TDD.
  • Flexibility and trade-offs: He recommends considering the cost or appropriateness of testing under different circumstances, an idea that again applies to testing at different levels.  Exploratory coding should probably not require a TDD approach, because short-term costs in exploratory coding are important.  I would argue this notion applies to creative processes in general -- brainstorming activities are more about volume than perfection.
  • Stories and DRY: He says of DRY (the principle don't repeat yourself), "I don't subscribe to [it] for test code because I want my tests to read like a story."  The story theme runs throughout the interview.

Friday, January 14, 2011

IOException with RecordStoreNotOpenException on RmsStorage.save() after RmsStorage.deleteAll()

If you see java.io.IOException caused by javax.microedition.rms.RecordStoreNotOpenException thrown while executing a save() in your J2ME Polish app, running for example in the Java ME emulator or also on real devices (BlackBerry, etc.), then you may be encountering the following problem.  Check if you have called deleteAll() previously.  RmsStorage (improperly, it seems) closes out the underlying record store when it performs a deleteAll(), so that subsequent calls to save() do not work.  If you do want to use deleteAll() to clear an old RmsStorage instance, the only solution I know of is to use a different instance after clearing the old one.

Tuesday, April 13, 2010

Why prioritize regression testing? A doctor-patient analogy.

You go to the doctor for your annual checkup, and she asks, “so, what changes have you noticed in the past week?”

“Oh, I don’t know,” you reply, “in the past week, not much, really.”

“I bet a couple of things changed,” says the doctor, “such as your hair and nails probably grew a little. I bet you ate some food too.”

“Uh, I suppose,” you reply.

“Well, if that’s it, then I’ll just run a quick test to make sure your new hair and cuticles are in order, and I’ll send you on your way,” she says.

“Huh?,” you ask, “is that it? Shouldn’t you measure my weight or check my blood pressure or run some other basic tests like that, since this is my annual checkup and all?”

“But essentially only your hair and nails have changed recently,” she responds, “so that’s all I’m going to look at. Or if you like, I can trigger your gag reflex and take a look at your last meal as well.”

“Um, no thank you.”

“There, all done. Your hair and nails appear in order. See, that was easy. Since you have no insurance, that will be $250. I’ll see you again next year.”

“But, but,” you protest…
Copyright 2011 by William Cain