Dec 4, 2007

Maybe a candidate for Mono.Rocks

Answering a thread on XmlNodeList manipulation on the list I came with this answer and (untested) Mono.Rocks candidate:

As a fan of generics I would create a helper class (based on Robert Jordan code):


public class XmlNodeListHelper
{
public static List CopyNodeList(XmlNodeList list)
{
List copy = new List();

foreach (XmlNode node in list)
copy.Add (node);
return copy;
}

public static void RemoveNodes(XmlNodeList list)
{
foreach (XmlNode node in CopyNodeList(list))
node.ParentNode.RemoveChild(node);
}
}


And so the code in question would become just:


XmlNodeListHelper.RemoveNodes(xDoc.SelectNodes("//comment()"));


When using the latest compilers it could be made into a Mono.Rocks helper like:


public class XmlNodeListHelper
{
public static List CopyAsList(this XmlNodeList list)
{
List copy = new List();

foreach (XmlNode node in list)
copy.Add (node);

return copy;
}

public static void RemoveNodes(this XmlNodeList list)
{
foreach (XmlNode node in list.CopyAsList())
node.ParentNode.RemoveChild(node);
}
}


And then usage would be even simpler


Doc.SelectNodes("//comment()").RemoveNodes();

Nov 21, 2007

New Commons.GetOptions release

I decided to re-relicense Commons GetOptions as BSD, and also started the work on supporting translation in the less intrusive (most backwards-compatible) form possible. I'm posting a tarball including the library binary, for those without mono or monodevelop to build from the fonts. See it at http://groups.google.com/group/managedcommons

Jun 22, 2007

About approaching Complex UIs development

Commenting on Hammett's Complex UIs post:

I think the repeated maxim "put yourself in your user's shoes", is very hard to try to accomplish in practice, for some reasons.

But for complex functionality I think two reasons are foremost:

  1. You really may not know enough of your users everyday tasks related with it, and how they are used to deal with it, but as you are being paid to develop something new, probably they aren't happy with it anyway, and they are waiting for you to come with some breakthrough, so they are only the best sources to gather "hints" on what should be designed, but not the "reference" for it. So as some have said, you need to cross those hints with ideas from other realms. This mindset is hard to come by, or develop: to keep your mind open to many influences/ideas and look out for the 'hidden' connections that could be explored to come up with an innovative solution.
  2. Complex UIs need to be simplified, and that means putting most important features in front of the user's nose (or mouse pointer), and hiding what can be guessed by the code. But here the problem is if you have a single user it is somewhat simple to figure out, what it really NEED to do, and find some good guesses from usage stats, but normally you are faced with a variety of users, maybe approaching your UI with different needs, so you'd end up with an 'averaged' solution that's dissatisfies more than satisfies most of your users. Cloning the UI in per-user-profile fine-tuned simplifications yields better results, but navigation and maintenance become harder. Another approach is to make the UI adaptive and then customizable, first keeping more frequently/recently used things on the 'top' and allowing the user to pin/unpin things and defining default values and such.
In short both issues compound to this conclusion: Good complex UI/functionality design isn't the thing you can expect to be able to do (even after intensively training yourself) in minutes/hours, it just takes more time and more than that some inner peace to be able to "imagine" the solution.

Jun 14, 2007

My first patch to Castle (MonoRail in truth)

http://support.castleproject.org//browse/MR-270 is my first contribution to Castle Project.

The Jira Issue Tracking system for Castle looks to be experiencing some problems now.

Basically I'm wrapping an exception in an outer scope and throwing the new exception that captures more information for easing debug (the resourceName for the template NVelocity is trying to process).

Hope it helps

May 7, 2007

Monoman joins Castle Stronghold

I'm now working at Castle Stronghold, the company Project Castle's creator Hammett (Hamilton Verissimo), founded to provide support, consultancy, customizations for organizations that choose to use Project Castle marvelous technology.

New things to learn (InversionOfControl in practice, ActiveRecord in practice, MonoRail's MVC in practice, and so on).

Back to using VS.NET (Eclipse and MonoDevelop key combinations doesn't work in there, pity) and the Windows Command Prompt (how many times I've typed ls or cat or grep, to no avail, so far?...Lots of times).

But I've been designing/coding for the last 30 years, and I still like it, and still like to learn, more and more, so it's kind of energizing for me to tackle this new endeavor.

Hope I can help the company and its clients while I'm there, and I hope to also be helping the FOSS ecosystem, in the end.

Engines started!!!

Apr 14, 2007

Of Robots, mp3 and Ogg

Today I went to a robotics fair, here in São Paulo, as my 6 years old son just LOVES robots.


For him, even seeing an enormous soldering robot (a big mechanical red arm) drawing a Betty Boop character on a sheet of paper clamped to a flip chart, is something really marvelous.


Obviously, the Lego NXT robot kit was the thing that made he throw a "Can you help me buy that (finance), daddy?" look, which I have to counter with some fast math on how it would take him nearly two years without any money just to pay me the cost of such a 'toy' (I give him US$ 5,00/week, and with import taxes such kit would cost over US$ 550,00, here).


Anyway, after walking all around the booths, seeing the competitions, and son on, we were walking back to where I parked my car (half-a-mile away, under a torrid sun), and I remembered the other high cost 'toy' he wanted to buy, just yesterday, and iPod (or at least some mp3 player), and I was foolish to propose him why we wouldn't project an hybrid walking-robot/mp3-player, so that it would follow him around the house (or at least walk-around) playing some tunes.


Yeah, I really have a BIG mouth... Only because lately, I've been programming PICs, ARMs and such other embeddedable things...


Nevertheless, coming back home I researched a bit (Google, of course) and found some robot projects, but none really in the way may son would like. Yet I've found some interesting pieces:


First, I found the OpenServo project, what could make for cheaper servos to give precise movement capabilities to the robot (http://www.openservo.com/).


Another interesting site, full of kits is http://www.eidusa.com/Electronics_Kits.htm

Then I've stumbled on the always interesting Make Magazine, what do I find there? An open-source mp3-player hardware module, the Daisy MP3 Player. But as someone commented in the associated Step-By-Step Tutorial (in another site) for this kit, it is a little too bulky and costs too much just to play mp3 files.


Warning: the 'open-sourcedness' of such projects is acquired by the fact that they have the decoder in hardware (some specialized DSP-based chip) and you are already paying the royalties for the MP3 patents, when you buy the chip.


Someone pointed me, in the same stream of comments, to a really small mp3-player project. the MintyMp3 player (http://web.media.mit.edu/~ladyada/make/minty/index.html) housed on an Altoids Peppermints box.


This is a truly interesting project, and hast come to plug some curious extras like an FM transmitter, to allow to play on your car stereo...


Well to put some limit on this babbling, all of that is nice, and ok, but hey, I'm a Linux user/dev and all my music is in the Ogg format (and I want to keep it that way), so I needed to find if such chips could help play ogg files, instead of mp3. Some of them, specially some more recent ones (the ones used in those projects are some 3 to 5 years old), are Multiformat, but that really means MultiProprietaryFormats (MP3/WMA/AAC), some chips in the Micronas line even come with builtin DRM features (argh!!!).


But at the end I've found something really, really interesting and recent. From Finland (again) comes a full Ogg Player on a chip, courtesy of the fine engineers at VLSI Solutions (http://www.vlsi.fi/vs1000/vs1000.shtml).


The VS1000, is a complete solution, you just add the Oscillator Crystal, some NAND-Flash memory, an AAA battery, some buttons and connectors (USB/earphones) and voilá, you have fully working very small Ogg Player.


In truth it does a bit too much for my needs, but you can hook into the DSP code to change bits a little (for example, the default ROM behaves as a Storage Device [stop playing musics] when connect in and USB port, and I would like to be able to control things with the robot microcontroller (possibly an ATMEL ARM, like in the Lego NXT, or maybe some of the bigger PICs).


Well lots of things to play with... in my mind at least.

Mar 11, 2007

Switch User in Fedora Core 6 (UPDATED)

After viewing Wade's post on OpenSuse, I decided to try it on my Fedora Core 6, and it also works.
Thanks Wade.

The good question, that naturally comes from it, is:

Why there isn't a checkbox for this on the screensaver preferences dialog?

UPDATE:

Because, for Fedora at least, it doesn't quite work the way you expect it to (the WinXP Home way):

1 - It only gives me the opportunity to switch to a different user when asking the password to come back from the screen saver (No 'System' menu entry for switching instead of logging-out is available)
2 - In that screen saver dialog, you can click a button show another one where you can choose another user, but the user id gets asked again as it falls down to the same session manager screen as you would have after a logout.

Even my, then, 5 year-old boy could switch to his account on my WinXP machine, nearly two years ago, but he can't still deal with switching/logging-in in my Fedora machine.

I hope all distros will get user-friendly user switching (and I hope some freedesktop standard will make all of them work the same way) in the near future, but so far Fedora is truly lagging behind.

MonoBlog now shows up in Monologue

Now that I've found that blogspot/blogger also serve rss feeds (in addition to the default atom ones) as needed by monologue's agregator, I'll switch back here for continuing my 'sparse' posting in English.

My old theSpoke blog is being deactivated.

Feb 12, 2007

I decidedly need to write documentation for my projects

See this email exchange I had earlier today:

Mono.GetOptions: howto?


FROM: Piercarlo Slavazza

Hi Rafael,

I'm considering usgin Mono.GetOptions for my .net project, and I would
like to know where I can find some documentation or at least some sample
code where to "quickly" figure out how to use the library - of course I
already googled around but I wasn't able to find any good snippets.

Another question: what's license applies to Mono.GetOptions?

Thanks you.
Regards,


FROM: Rafael Teixeira

The last question I'll answer first: the license is BSD/MIT, what
means mainly just use it and be happy.

There is a sample app in the sources (mcat), that show many of
Mono.GetOptions resources.

But It's my fault that little documentation is available.

Some (unfleshed) class documentation is here
http://www.go-mono.com/docs/index.aspx?tlink=0@N%3aMono.GetOptions

Many mono tools also use Mono.GetOptions, but the project that drove
its development is the now defunct mbas (his successor vbnc doesn't
use it).

The main gist is that you do things declaratively. Example:

public class MyOptions : Options {

[Option("Do some important thing", 'i')]
public bool important;

...
}

After calling the option processing in your main method, your instance
of MyOptions, will have 'important' set to true if the command line
have an argument like

/i or /important

Deriving from Options (which isn't mandatory means you already inherit
a help command that generates automatically a help screen with all the
options you've declared.

I'm quite sure the Mono-list archives has some more extensive
explanation I gave some time (years) ago about the subject. Sorry but
I'm in a hurry now.

Thanks for evaluating the use o Mono.GetOptions.

I should point out that I'm starting to work on a better version to be
called Commons.GetOptions, but I now just have the early planning
being cooked (see this blog)

Have fun,

Jan 9, 2007

Commons.GetOptions the sucessor to Mono.GetOptions

I'll start Commons.GetOptions outside of Mono, and just keep Mono.GetOptions 1.0 stable (only security fixes) inside Mono svn. That would help with stability requirements for Mono colliding with the desire for innovation/improvements on GetOptions.

I'll post details as I progress with it. But some of the ideas I already have are:

  1. to make it I18n-friendly (either gettext and resources, by defining/using localization providers and matching tools)
  2. drop the multiple constructor overloads for the attributes, in favor of the supported syntax for field initialization by name
  3. refactoring into a layered design, that should allow for imperative definition of option sets, besides the declarative form currently supported
  4. subcommands support
  5. easier runtime addition of options
  6. a tool to compile a DSL (Domain Specific Language) to binary optionsets classes and/or generate (cia codedom) partial classes sources in any language that have correct codedom support installed.
  7. a GTK# GUI tool (also wrapped as a MD plugin) to write the above DSL (some call it a graphical DSL)
  8. A WinForms component/editor to define/generate/use the DSL
  9. Full Monodoc/VSNET Documentation
  10. Sample code also in Boo, VB.NET and Java(IKVM)

Nevertheless suggestions are welcome.