Tuesday 21 January 2014

My C# (Unity3D) Assert()/Log() signature combines Conditional and pre-processor

Someone queried my logging method signature in a patch I offered recently so I thought I'd share the technique and explanation.  Forewarnings:

  • it's C# (WHAT?! When did I switch? Explanation to come, I guess!)
  • it's for performance (so sacrifices some immediate clarity to that mistress).


#if !DEBUG
    [System.Diagnostics.Conditional("UNITY_EDITOR")]
#endif
    public static void Assert(bool comparison, string messageFmt, params System.Object[] args) { ... }
    // also used on logging


An explanation in two parts, (1) the Conditional and (2) how the #if interacts with it.

Thursday 24 May 2012

HeliDartris begun

New idea for a game (because you can never have too many projects on the go!)  Working title is HeliTetris -- play tetris-like line making game using the winch under a helicopter, probably coupled with gravitational sensor data on phones and tablets. How hard could it be? :-)

Decided to try prototyping/writing it in Google's new Dart language.  I'd heard of this several months back but 2 weeks back, my interest was galvanized by the Dart hackathon!  I went along and we had a stab at a multi-player PacMan clone.  Not a bad effort given we wrote everything from scratch and hadn't touched Dart before then!  (1 guy had written a little and I read the docs on the 30m train journey in!)  My conclusion: Dart has great potential.  More approachable than Scala -- my other favourite "I hope this is the future" language.

Anyway, Seth Ladd had mentioned there was a Box2D port (via the Java port) so what better platform to prototype/write in for cross-platform productivity?

(My opinion: JavaScript is just frustratingly badly tooled -- once you get above a certain project size, it sits the un-fun-dark-side of hackyness.  Even when kept well structured (which it doesn't help you with), it just becomes more and more work (*1).  Dart's optional strong-typing means decent toolability (like Java and Scala).  Let's see how it bears out in practise, though!)

*1: Perhaps it's time for "Big H Notation" which represents how developer headache scales with increases in size of project.  Yeah, it could be described as how complexity scales, but let's face it, we don't mind some complexity without the headache!  What would you propose for different languages?  Hm, this feels like a Twitter/G+ question!

Anyway, for a bit of a change, I decided to both (a) try the Pomodoro technique and (b) keep a development blog.  Let me know what you think -- good and 'suggested changes' ;-)

15:00 start on Linux
15:10 IDE installed
15:15 box2d library found and downloaded (cloned from Google Code Git).
15:20 still trying to run demos
15:30 Don't use Dart Editor integrated webserver, use file path:
file:///home/username/Dev/Dart/Libs/dartbox2d/demos/demos.html?demo=BallCage
15:34 Discovered bug in library for all demos "UnsupportedOperationException: Cannot add to a non-extendable array":
Exception: UnsupportedOperationException: Cannot add to a non-extendable array
 Stack Trace:  0. Function: 'ObjectArray.add' url: 'bootstrap_impl' line:125 col:5
  1. Function: 'BroadPhase._bufferMove@3b3cfbc8' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/lib/collision/broadphase/BroadPhase.dart' line:215 col:58
  2. Function: 'BroadPhase.createProxy' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/lib/collision/broadphase/BroadPhase.dart' line:71 col:16
  3. Function: 'Fixture.createProxy' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/lib/dynamics/Fixture.dart' line:96 col:35
  4. Function: 'Body.createFixture' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/lib/dynamics/Body.dart' line:189 col:26
  5. Function: 'Body.createFixtureFromShape' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/lib/dynamics/Body.dart' line:221 col:25
  6. Function: 'BlobTest.initialize' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/demos/BlobTest.dart' line:47 col:36
  7. Function: 'BlobTest.main' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/demos/BlobTest.dart' line:29 col:20
  8. Function: '::main' url: 'file:///home/username/Dev/Dart/Libs/dartbox2d/demos/BlobTest.dart' line:101 col:16
(started trying to debug. Why doesn't the debugger breakpoint in this library!? Hm, investigate more later.  print() it is for now = bletch!  15:39 no typeof!?  Ah, reflection still in development.  Workaround?  print("List?: "+ moveBuffer is List) can't be right?!)
15:50 Bug found -- new List(SIZE) is a fixed-length list!  Is that expected by 2d author?
15:55 DartBox2D authors haven't stuck to Java Box2D form here -- looks like they relied on List being dynamic.
16:02 Decided to try switching to dynamically-sized list.
16:10 Better.  Now different error to do with requestAnimationFrame() having extra param.  Luckily, hit this before.  Scratch param! 5 of this same error -- removed all.
         Man, this new IDE version performs terribly on compile!!!  Quick Google doesn't show obvious bug about this.  Maybe check later?
16:12 Woohoo, works.  Time for a commit?  Not done with Google Code Git before!
16:47 Cloned, committed, learnt Google Code Git, pushed, e-mailed group.

1 pomodoro?

17:19 Blog written.  Hope you enjoyed as much as I did!

Saturday 15 October 2011

Android validation (decompilation) tools

So Jenkins is building and archiving lovely APKs with timestamps in versionName!  People are testing directly out of DropBox.  Got a bug report but need to see which APK it came from!
Goal: Extract human-readable versionName from APK.
Two-liner answer after the break!

Friday 12 August 2011

Eclipse Mylyn / Bugzilla "resolution required" UX buglet

Eclipse Mylyn / Bugzilla error...
Submit failed: resolution required:  A valid resolution is required to mark bugs as RESOLVED.
... requires specific steps to avoid.  TL;DR solution and notes after the break.

Monday 8 August 2011

Using a Linux android emulator server

Situation: You have a fast lots-of-memory Linux desktop box (perhaps remote) to run your Android emulators on and a desktop machine running your IDE.  How best to debug remotely?
SSH port-forwarding instructions for Windows (and others) after the break.

Monday 13 June 2011

Eclipse eUML2 plugin installation problem and solution

Got red herring errors below when trying to install Soyatec's excellent UML Eclipse plugin eUML2.  Found real answer in the Soyatec forums here -- install GMF (Graphical Modelling Framework) first.
Worked a treat. Errors after the break.

Saturday 23 April 2011

Bug: SoapUI fails to add REST Test Method to Test Case when using Resource solely to share parameters

[Duplicated from my EviWare/SoapUI forum post here.]

Using SoapUI 3.6.1, I ran into same problem as listed here viewtopic.php?f=2&t=4462&start=15 (which I named this topic after).
I downloaded the 3.6.2 nightly and retried. No fix.
OOI, by opening the project XML in Eclipse, I can see that despite throwing the same error, if I save, the new testStep does appear in the XML. I've tried "Resolve" (no errors), loading and reloading, restarting SoapUI. No help.
Below are more details of the problem some more and a workaround ...

SoapUI aide memoire and groovy scripting (on RTM)

A braindump (not a tutorial) on SoapUI including use of Groovy to script parameter generation!
To whet pre-jump appetites, the SoapUI primary structure:
  • Project - houses...
    • Methods - Create these including parameters that need populating later (I'm doing REST atm)
    • TestSuite - One can only script within a test suite/case so we'll need one
      • TestCases -  one for each separable chunks of work.
        Lots of choices but I've mostly used...
        • GroovyScript - code to generate values (like hashes)
        • PropertyTranfer - Used to copy values between scripts and calls' parameters (REST calls, etc)
        • Test Request (REST/SOAP/HTTP/JDBC/AMF!) to make actual calls
    • Setup Script and TearDown Script can be placed on TestSuite, TestCase, etc to also house the scripting.  (but I've generally found scripts more handy.)
    • Project-wide utility methods can only be defined with a SoapUI Pro license (IIUC).  Without this, I've ended-up with some copy-and-paste re-use :-(  Shame there's no sliding scale from Community to Pro!
Full details after the break and please note this post's a WIP -- perhaps forever!  ('90s webpage, anyone? ;-) )

Thursday 21 April 2011

Tacking to pick up the Droid trade wind

Well, wow a lot's happened since that last post.  My Father died (yep, "To lose one parent, Mr. Worthing, may be regarded as a misfortune. To lose both looks like carelessness."), decided to re-evaluate life and left Malden Labs.  I had a great time there; learned, saw and did lots; met a tonne of interesting people and wouldn't have missed it for anything.  However, I always fancied being master and commander of my own boat so am taking The Good Ship UGS (my half-comically, half-seriously named company) to sea.  Initially with some Android app and game writing but we'll see which way the wind blows.  Android appeals since I've been Java programming since '96 and the current current at last seems strong enough to carry us to promised lands (and/or cities of gold).  To top it off, as an ideas person, I'm slightly sickened by the slew of recent business successes that are depressingly (or reassuringly) similar to previous ideas.  (I'm sure this isn't unusual but that doesn't make it less sickening ;-) )

So starting simple and trying to focus on failing fast with delicious early feedback, first projects will be a 2D casual game using AndEngine and a personal-itch scratching Android RememberTheMilk Sharer utility (surely it's not that hard to catch the SEND intent, offer to store to RTM with some processing to tidy-up common content.)

Never fear, our regular yak programming will continue (even more so now since I won't be posting on internal blogs and wikis!) but maybe there'll even be some non-yak content!  Ok, time for a calming lie down ;-)

Sunday 30 January 2011

update-alternatives and the Chrome takeover quash

Finally got round to understanding Ubuntu's /etc/alternatives a little more after installing Chrome made it my default browser!?  More details after the jump (another first!) but briefly:
  • List all alternative-able things:
    sudo update-alternatives --get-selections
  • Choose which browser:
    (these present menu to select from)
    sudo update-alternatives --config x-www-browser
    sudo update-alternatives --config gnome-www-browser