December 14, 2009

Simpler Java asynch IO with JBoss Netty

Filed under: cool, education, groovy, java, mina, netty, tip — michaelangela @ 3:57 am

I don’t know what this will look like since I am using Scribfire which doesn’t like to deal with code very well… that should be a standard disclaimer on this site! I try to clean it up as best I can within a short timeframe though. 🙂

I recently wrote about some Java libraries/code that would simplify asynch socket communication. I hadn’t looked far enough! Looking for references on Groovy asynch programming I came across this:

ojug meeting tue oct 20th — grails and/or netty : Omaha Java Users Group

Netty has been getting some press as a potential successor to Apache’s Mina asynchronous I/O framework for building low-level custom protocols. E.g. previously I’ve used Mina to talk binary to a card processing system.

And checking in to MINA and Netty yielded some nice info. There is a great little tutorial on writing a simple server in MINA 2. But the simple Netty TelnetClient example was exactly what I was looking for. Specifically:

TelnetClient xref

TelnetClientHandler handler = new TelnetClientHandler();
bootstrap.setPipelineFactory(new TelnetPipelineFactory(handler));

For those more experienced with Java, I hadn’t seen a simpler way to assign what is essentially an event handler. The code I had seen before required using slots and keys or other bits that seemed a bit more verbose than needed. But then again that could be simply because of my inexperience in the language at this point. Seeing this immediately made sense coming from AS3. It’s not a closure like in AS3 where each event gets a method call of some sort, named or anonymous, but just a class that handles the events.

TelnetClientHandler xref

public void messageReceived(

ChannelHandlerContext ctx, MessageEvent e) {
// Print out the line received from the server.


Sweet and simple. Once that’s assigned you can go into your “do forever” loop and do the writing that needs to interact with the server.
TelnetClient xref

// Read commands from the stdin.
ChannelFuture lastWriteFuture = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (;;) {

String line = in.readLine();
if (line == null) {


// Sends the received line to the server.
lastWriteFuture = channel.write(line + ‘\n’);

// If user typed the ‘bye’ command, wait until the server closes
// the connection.
if (line.toLowerCase().equals(“bye”)) {




Even without Groovy this is really straightforward. I guess a Groovy implementation of Netty would reduce all of this to like 3 lines of code? Heh. 🙂


December 11, 2009

On the road to becoming a software architect

Filed under: dev, education — michaelangela @ 1:56 pm

I can write components, tie them to data with an MVC model and get things done without any guidance except “this is what it needs to do”. A recent post details recommended programming books. I’m in on the first one, Code Complete 2nd Edition, at section 3.5: Architecture Prerequisite. The book is mostly about construction so it doesn’t delve deeply into architecture but it’s an area I want to develop in. The questions being laid out in this section and the previous one (Requirements Prerequisite) are hitting the issues I have had to fight when things aren’t clear from the beginning. This is extremely helpful for me even when not architecting huge projects.

I have one coming up where the client wants a flat XML file to manage all data instead of a backend database. It will be quite a bit of data as I understand it, not having seen it. I have a better idea now of what to ask when I do set eyes on it for the first time (hopefully soon…).

Recommended programming books in the queue

Filed under: dev, education — michaelangela @ 5:10 am

I can’t find the site that brought me here. The first one, Code Complete Second Edition, reading now, is quite eye opening and written for someone just like me: the self taught developer. My major in college was East Asian Language and Culture with Japanese as the language of choice. I have forgotten most of the Japanese I learned and instead speak Chinese now. Go figure! The language learning process fascinated me though and I think that helped prep me for a career in development. So when my type was included in the “who this book is for” that really caught my eye.

The next one down, The Pragmatic Programmer, has been on my “want to read” list for a while ever since I heard about the Pragmatic Bookshelf and got some goodies on iPhone development there.

And with #3, Structure and Interpretation of Computer Programs, being available freely online, I can’t pass that up! 🙂

What is the single most influential book every programmer should read? – Stack Overflow

If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be?

I expect this list to be varied and to cover a wide range of things. For me, the book would be Code Complete. After reading that book, I was able to get out of the immediate task mindset and begin to think about the bigger picture, quality and maintainability.

Suggest your programming books

December 10, 2009

Java async communication tools tips and tricks… well only 2

Filed under: education, java — michaelangela @ 1:34 pm

Java async communication is no simple matter and these posts highlight the issues as well as provide some solutions. The NIO tutorial is close to what I want but the callback API may bring in the simplicity I desire. I’ve been dusting off the Java portion of my memory and digging in a bit.

Rox Java NIO Tutorial

This tutorial is intended to collect together my own experiences using the Java NIO libraries and the dozens of hints, tips, suggestions and caveats that litter the Internet. When I wrote Rox all of the useful information existed as just that: hints, tips, suggestions and caveats on a handful of forums. This tutorial actually only covers using NIO for asynchronous networking (non-blocking sockets), and not the NIO libraries in all their glory. When I use the term NIO in this tutorial I’m taking liberties and only talking about the non-blocking IO part of the API.

tech: Java : A callback API for epoll(), building on top of Java NIO

I just finished the first draft of the Java callback API that allows you to do asynchronous socket communication using the scalable epoll() mechanism of Linux. This is built on top of Java NIO, so it will take advantage of the best underlying network mechanism the OS has to offer. In Linux 2.6 + /FreeBSD this will likely be epoll().


The Java NIO api can certainly be used for this purpose. But using that API is somewhat difficult and there are various caveats you have to guard against. You need to understand the Selector class, SelectionKey class, InterestOps class, SocketChannel class and their interplay. You need to know the logic for canceling SelectionKeys and setting InterestOps appropriately. And you need to understand the cryptic ByteBuffer class and its variants, possibly how the ByteArrayOutputStream works as well. You need to figure out how to use these classes to store the data separately for each connection, keeping in mind that the data will likely arrive mixed. You also should not call select if all sockets have been completely read, or select() will block – which means you will have to keep track of pending hosts.

December 7, 2009

The source of my early Java knowledge

Filed under: education, java — michaelangela @ 12:14 pm

Once upon a time I worked for Lucent. I worked with a lot of great people there and had a good time there actually except for the fact that I wanted to telecommute… except I don’t think that term was popular yet. But among the other good things that happened there, I got a chance to learn Java. And somewhere in that course, Bruce Eckel’s name came up and the resources for the class I took might have been based on his materials as well.

At any rate it is now time for a refresher. 🙂 Java has come a long way since then. Not to mention the computers. I think at  that time my work laptop was around 130MHz beast! But I’d have to ask to confirm that. 🙂

Note: all links to mindview.net are not working as it seems to be down. mindviewinc.com links work fine though.

Bruce Eckel’s Free Electronic Books

These are electronic books in HTML on C++ and Java, along with the source code. The HTML books are fully indexed, use Frames for easy navigation through the chapters, and have color syntax highlighting on all the source-code listings. Each HTML download contains an entire book and source code in a single zipped file.

AS3 Design Patterns

Filed under: a3s, design patterns, education — michaelangela @ 12:12 pm

Following up on the recent find of PHP Design Patterns, here is a talk from the very resourceful London Flash Platform Users Group. There is a PDF included but it’s more of a general overview. I hope to get through this presentation soon. Template and reactor I haven’t used and MVc (as opposed to MVC) is a variation I wasn’t aware of.

London Flash Platform User Group » Blog Archive » Practical Design Patterns for ActionScript 3.0

Decorator; reactor; model view controller; model view presenter; model view little c; template; and reactor. These are just a few of the standard design patterns. There are hundreds out there and it is easy to feel a little lost. I hope to explain some of these patterns and their uses, along with their benefits and cost of use.

[update] There is a book on Actionscript 3 Design Patterns with a companion website. There you can find the aptly titled ActionScript 3.0 Design Pattern Starter Kit. Nice.

Robotlegs framework and programming to an interface

Filed under: as3, cool, education, frameworks, puremvc, robotlegs — michaelangela @ 8:03 am

Actual code samples makes things make so much sense. And this is a great example of the (new to me) Robotlegs framework. I really like what I see. The following post has the same small app in several different frameworks.

Robotlegs example project with source

Any comparison of frameworks wouldn’t be complete without Robotlegs. I included Robotlegs in my session at LFPUG recently, but didn’t post the example project here because the framework was in a state of flux. Robotlegs is now settling down as it approaches its imminent 1.0 release, and the MVCS implementation in it is unlikely to change further, so here’s my example.

For this Robotlegs example I’ve used exactly the same project as in the previous examples for other frameworks. Robotlegs is not prescriptive about your application’s architecture, but it does include a default MVCS implementation for those that wish to use it. I’ve used that default implementation here.

Working with this kind of code outside of some sort of IDE or at least a well known convention could be a little baffling. For example, for this project, small though it is, sets the feeds with interfaces and not the actual feeds. This goes along with the principle of “Program to an interface, not an implementation” which is good and flexible. But to a newbie it might a bit confusing. (See here for a discussion about extending AS3 using interfaces, or rather the difficulties in doing so.)

FlexBuilder is a great IDE for AS3, granted there aren’t many. And for those with far more experience in more mature languages like Java with its plethora of incredible tools, it really pales in comparison. But it’s a far cry better than the Flash AS editors! I bring that up because I often learn code by the awesome Command+click (Ctrl+click on a PC?) to jump to the definition of a variable or a class. Opening up Flexcaster.mxml shows a context “FlexcasterContext” and a MainView. I was completely new to IoC programming with its dependency injection. So I didn’t know at that time that a context is a term commonly used in IoC. But I knew it’s an MVC framework so I figured the code I was looking for wasn’t in the view. 🙂

Clicking on the FlexcasterContext brought it up which showed where the magic happens: how everything is connected. Of note though are these two lines:

injector.mapClass( IFeedsService, OpmlFeedsService );
injector.mapClass( IFeedService, RssFeedService );

This lets me know that wherever I see IFeedsService it’s actually using OpmlFeedsService, and the same for RssFeedService and IFeedService. Through the rest of the code you won’t see any reference to OpmtFeedsService or RssFeedService. This context is the only place I would see where the connection is made. The author actually brings this issue up in a different version that also uses IoC but instead of events, it uses Signals.

All in all I think it worked out rather well. There may even be a potential future in an architecture like this. I do fear the explosion of interfaces and injection rules may make the approach unwieldy for a large project, but perhaps multiple DI configuration classes, a clear package structure and disciplined developers is all that’s required. I welcome your opinions on this.

There is more discussion there. Of course the immediate benefit of programming to an interface is that swapping out a class is a one line change instead of refactoring all affected code. Making mock data objects for the model while testing is a great example of that. It could instead be

injector.mapClass( IFeedsService, TestOpmlFeedsService );<br />

when doing tests which simply returns a preset array of data.

Overall I have to say I like the conciseness of the code. Even little things like having classes instantiated as a Singleton is cool.

injector.mapSingleton( FlexcasterModel );

The FlexcasterModel is just a class but the framework itself handles the instantiation via injection. Saying


makes sure you only have one and when it is injected, only the one instance already created is passed in. As the robotlegs site says, this helps prevent the boilerplate code. I look forward to trying out the framework. I enjoyed using PureMVC once I wrapped my head around it but this, perhaps because of the conciseness, took far less time to grasp.

Enjoyable PHP tutorials?

Filed under: education, php — michaelangela @ 6:46 am

I haven’t had time to look at this yet but from the comments it seems people really do enjoy this set of tutorials. 🙂 I’ll pass it on to anyone I know that’s just learning but I’ll try to take a look to learn how to breakdown PHP concepts into plain English.

PHP 101: PHP For the Absolute Beginner

This area is intended for everyone new to PHP. It opens with a series of informal, entertaining tutorials written by Vikram Vaswani, founder and CEO of Melonfire. These tutorials build on a previously-published 5-part series which has now been updated and extended to embrace PHP 5, making parts of it suitable for those of you who already have worked with PHP 4 in the past.

If you came here to learn about elementary PHP 4 or basic PHP 5, this is for you. Enjoy!

PHP Design Patterns

Filed under: education, php — michaelangela @ 6:43 am

And examples. Their a Java version at the site as well. Very helpful to get a hands-on grasp of what these concepts are. I have used Factories, Singletons, Facades, Composition, Commands, Mediators, Iterators, Observers, State, and some others BUT I haven’t always known I was doing so or what it was I was actually doing. This kind of reference helps clear those things up.

PHP Design Patterns – FluffyCat.com

June 26, 2008

Free DNS report tools

Filed under: cool, dns, education, tip, tool — michaelangela @ 6:38 pm

Excellent comparison and info on free DNS reporting tools which come in handy when DNS is doing what it shouldn’t… at least not what you think it should! In the end I used intoDNS, CheckDNS.net, and pingability.

Free DNS Report alternatives

Everyone that runs a web server or even a site needs to run a DNS
check from time to time. For a long time I have been a happy user of a
site DNSstuff.com. But couple of months ago they started charging for their main check called DNSReport.

For few queries a month I’m not willing to subscribe for $80 a year, and I’m certainly not alone.

I have done some research and tried to find alternatives. Here are the
results with ratings, where 10/10 is what DNSReport gave us.

June 15, 2008

Enums, Objects and the joys of being typesafe

Filed under: as2, as3, education, flex, tip — michaelangela @ 1:51 pm

I like autocomplete. I also like it when the compiler (or IDE) tells me I am doing something wrong BEFORE I compile. Flexbuilder is my AS3 compiler of choice. Although FlashDevelop 3 has come a really long way. It’s PC only though. 😦

Anyway, just did some reading about Enums in AS2. This bit of reading below came courtesy of a link here about creating typesafe enums in AS3. I really like this. I particularly like the idea of the “Month” class given in the comments on the page below. In addition to being typesafe, by attaching an ordinal to each value, you can compare your values. So in that case Month.JAN would be less than Month.MARCH. (There is also a discussion about “SCREAMING_CAPS” that was enlightening. I digress…)

blog-j: Symbolizing, Coding, Objectifying, Processing » Code. Code. Code.

I’m in the middle of reading Code Complete, Second Edition by Steve McConnell
(a book which I can’t recommend highly enough). One of the key points
of the book is that just because your language doesn’t natively support
a certain implementation ideal (for example, private field members or
classes), you should work around those limitations by ‘programming into the language, not in the language.’ One example he gives of this is Enumerated types.

The definition of an Enumerated type is this: “A list of named
values used as the range of a particular attribute type. For example,
Color = {Red, Green, Blue} (source).”

This can be useful in limiting possible values for a methods
arguments (and more). For example, by using an Enumeration of
SearchTypes, you can ensure that the searchType argument falls into the
valid values for a SearchType.

Enums, Objects and the joys of being typesafe

Filed under: as2, as3, education, flex, tip — michaelangela @ 5:16 am

I like autocomplete. I also like it when the compiler (or IDE) tells me I am doing something wrong BEFORE I compile. Flexbuilder is my AS3 compiler of choice. Although FlashDevelop 3 has come a really long way. It’s PC only though. 😦

Anyway, just did some reading about Enums in AS2. This bit of reading below came courtesy of a link here about creating typesafe enums in AS3. I really like this. I particularly like the idea of the “Month” class given in the comments on the page below. In addition to being typesafe, by attaching an ordinal to each value, you can compare your values. So in that case Month.JAN would be less than Month.MARCH. (There is also a discussion about “SCREAMING_CAPS” that was enlightening. I digress…)

blog-j: Symbolizing, Coding, Objectifying, Processing » Code. Code. Code.

I’m in the middle of reading Code Complete, Second Edition by Steve McConnell
(a book which I can’t recommend highly enough). One of the key points
of the book is that just because your language doesn’t natively support
a certain implementation ideal (for example, private field members or
classes), you should work around those limitations by ‘programming into the language, not in the language.’ One example he gives of this is Enumerated types.

The definition of an Enumerated type is this: “A list of named
values used as the range of a particular attribute type. For example,
Color = {Red, Green, Blue} (source).”

This can be useful in limiting possible values for a methods
arguments (and more). For example, by using an Enumeration of
SearchTypes, you can ensure that the searchType argument falls into the
valid values for a SearchType.

April 17, 2008

Flex, MVC, Cairngorm and Universal Mind Extensions

Filed under: cairngorm, cool, dev, education, flex, mvc, tip — michaelangela @ 8:08 pm

This podcast with Thomas Burleson probably has the best description of MVC with Flex, why to use Cairngorm, challenges of using Cairngorm, why to use the universal mind extensions, the problem of view locators and how to work with those, etc. Good stuff. I wish there was a transcript of this.

UMEvent, UMCommand, Callbacks, and other goodies galore. Cairngorm is really, really good. It’s very lightweight. This just takes it further. Now I just need to understand how to use them. 🙂 But that’ll come later.

Another interesting bit is about the centralized error handling… oh good stuff.

Hmm… webservice is far slower than remote objects. And if they fail,
they can fail silently. Ah, that’s WSDL services. Interesting stuff.

Sequences in Cairngorm is quite different than sequences in UM Cairngorm… wow… nice stuff. It’s giving you quite a bit of flexibility: firing sequence of events and commands.

Another bit about refactoring is mentioned, i.e. every use case in Cairngorm has a command/event. It’s definitely workable but it can get tedious. The UM extensions help with that as well.

Download the file and listen to it with Quicktime Player and bump the speed up to like 175% to save some time. 🙂

The Flex Show: The Flex Show – Episode 41: Universal Mind Cairngorm Extensions w/ Thomas Burleson

April 16, 2008

More on MVC

Filed under: dev, education, flex, mvc — michaelangela @ 4:31 am

Going to have to do some more reading here later… Joes’ article “An architectural blueprint for Flex applications” was probably the first thing I tried to chew through to understand MVC, Cairngorm, and “separating concerns” while building an app in Flex. Model adapters and view mediators look like something I have been wrapping my head around. And so… more reading here later. 🙂

joeberkovitz.com » The MVCS Architecture and ReviewTube Example Application

Use of Model Adapters. Very often, the raw information in a Model is not what a View needs to show, and using Flex data bindings to drive the View from the Model becomes extremely awkward. …snip… In such situations, and even in simpler ones, it’s often better to build a special “model adapter” that both exposes this modified view of the underlying Model, and which also listens to change events from that model, dispatching change events of its own when its “adapted” properties change in response.

Use of View Mediators. Another important pattern not illustrated by ReviewTube is the use of Mediators, in which View/View and Controller/View interactions are handled by separate objects that “decouple” these objects from knowledge of each other. …snip… Another type of example is one in which a View is fairly generic in nature and some intermediate processing of its events is required to figure out how and when to invoke the proper Controller operations based on user interaction with that View.

April 14, 2008

Flex form: indicating a required element

Filed under: cool, education, flex, tip — michaelangela @ 9:16 pm

Customize the indicator on a Flex form to show a form item is required.

Changing a Flex FormItem container’s indicator skin at Flex Examples

The following example shows how you can change the FormItem container’s indicator skin which appears when the form item’s required property is set to true.

April 11, 2008

Cairngorm factories for xml in and VO out

Filed under: as3, dev, education, flex, tip — michaelangela @ 5:56 pm

I’ve linked to this article before but I wanted to bring up another point now. I have a good xml data set that is becoming the local store for a chunk of a UI. But because it is xml, it doesn’t update the way it should. I need to try to implement this xml &amp;amp;amp;amp;gt; VO approach, which could yield objects that properly emit data change events. Then the UI can bind more directly which would be very nice.

Flex and Flash Developer – Jesse Warden dot Kizz-ohm » Blog Archive » Cairngorm vs. Joe Berkovitz’s MVCS

It also implies, too, that Factories won’t go away. Neither Cairngorm, nor JB’s MVCS technically have the Factory pattern, but I use it in every single project I do now. Typically this is “throw some XML in, get a ValueObject out”, or JSON, and vice-versa. These are used in Cairngorm’s Delegates, or JB’s MVCS Services. Having a Factory create a nice client side version of our VO’s is very useful, encapsulated, and you end up with easier to read Delegate / Service classes.

To do this though would require something like a hash map. Actionscript 3 doesn’t have it. But some developers have made different versions. I am leaning towards this MultiMap Class though:

H1DD3N.R350URC3 » ActionScript 3 MultiMap Class

Recently I needed a HashMap for a project to map key/value pairs but in
that particular case the Map required to map not just one but several
values to a key. I could have used an array or object to store the
values in and map that one but in practice it turned out that accessing
the map looked rather messy. It would be much more elegant to have a
map to that multiple values can be mapped directly. After some
investigation (strangely even Java seems not to have a MultiMap
included) I came up with writing my own MultiMap class, so here it is!

The MultiMap is heavily based on Michael Baczynski’s HashTable class but I modified it to my requirements and added a couple of additional methods for luxury.

But the updated HashMap is apparently bindable which is what I want. I don’t think the MultiMap is bindable

Eric Feminella: Solutions Architect, Rich Internet Applications » Blog Archive » AS3 HashMap for Flex 2

Additional explanation: The code above is basically the same HashMap, but it is bindable. You will need it i.e. if you want bind GUI components to the HashMap.

Ah yes I see it now. The HashMap implements an IMap which returns an IList when you call getEntries. And that IList has a collectionChange event “Dispatched when the List has been updated in some way”. Flex collections tend to do that which is good for binding.

Actionscript sprintf

Filed under: cool, dev, education, tip, tool — michaelangela @ 5:39 pm

I like python and the ability to do variable substitutions. In AS3 you have to do… well see the example below. Alas, this is for AS2, not AS3.

sprintf : Downloads : Nate Cook

Formatted strings are a real convenience—one that is sorely missing
from the Flash Actionscript library. This adds in the sprintf
functionality, which lets you reduce something like this:

var m,d;var myDate = new Date();

m = myDate.getMonth() + 1;if (m < 10)    m = '0' + m;

d = myDate.getDate();if (d < 10)    d = '0' + d;

trace(m + '-' + d + '-' + myDate.getFullYear());// traces out: 02-14-2004

into basically a single line of code:

var myDate = new Date();
Sprintf.trace('%02d-%02d-%4d',myDate.getMonth() + 1, myDate.getDate(),myDate.getFullYear()));// traces out: 02-14-2004

Ah! But! Someone did kindly make an AS3 version.

Sprintf for AS3?

AS2 and AS3 are similar, but incompatible. You’d have to spend some time tweaking the AS2 version you have to get it to compile in AS3, so just try Manish’s AS3 version instead: http://tasmania.globat.com/~mannu.info/flex/sprintf.as

But… the link is dead… there is mention of an ASToolBox on the web but I don’t know which version that works with. Ah… hmm… just a sec… nope… dead links… how about this? Bingo. OK so there it is.

But another one also turned up in the search for “actionscript 3 printf”. This could be very useful!

printf-as3 – Google Code

Inspired by python’s print and strtime.

This is really a simple project. Inside the rep, souce, docs and examples.

Some basic usage:

import br.com.stimuli.string.printf;// objects are substitued in the other they appear

printf("This is an %s lybrary for creating %s", "Actioscript 3.0", "strings");// outputs: "This is an Actioscript 3.0 lybrary for creating strings";// you can also format numbers:

printf("You can also display numbers like PI: %f, and format them to a fixed precision, such as PI with 3 decimal places %.3f", Math.PI, Math.PI);// outputs: " You can also display numbers like PI: 3.141592653589793, and format them to a fixed precision, such as PI with 3 decimal places 3.142"// Instead of positional (the order of arguments to print f, you can also use propertie of an object):var userInfo : Object = {"name": "Arthur Debert","email": "arthur@stimuli.com.br","website":"http://www.stimuli.com.br/","ocupation": "developer"}

printf("My name is %(name)s and I am a %(ocupation)s. You can read more on my personal %(website)s, or reach me through my %(email)s", userInfo);// outputs: "My name is Arthur Debert and I am a developer. You can read more on my personal http://www.stimuli.com.br/, or reach me through my arthur@stimuli.com.br"// you can also use date parts:var date : Date = new Date();printf("Today is %d/%m/%Y", date, date, date)

For a full list of available formaters see : http://stimuli.com.br:8080/media/projects/printf-as3/docs/printf/as/package-detail.html

Universal Mind Cairngorm Extensions

Filed under: cairngorm, cool, dev, education, flex, mvc — michaelangela @ 4:18 pm

There are several issues I have had when developing with Cairngorm. It gets better with time as you work around the issues, but you have to “work around them”, as opposed to working within the system constraints. The constraints are good. They give form and function. But there are some headaches… certainly no offense to the Cairngorm developers as it is a phenomenal piece when you think about what went into it.

Well, others agree that there is room for improvement. And this bit from Universal Mind may help with a lot of those things. Good stuff coming.

flexcairngorm – Google Code

Universal Mind has extended the
“classic” Adobe 2.2.x Cairngorm version to provide many productivity
and maintenance enhancements. Those extensions have now been
open-sourced – with BSD licensing – to the Flex and Flash developer

The Cairngorm Extensions are summarized below. Each link will provide details and examples of the specific extension:

  1. Events
    • Built-in support to transport responders for direct view or business logic callbacks.
    • Implementation of AnnounceFaultEvent to allow business logic to centralize error reporting and logging.
    • Implementation of EventGenerator to allow developers to automate dispatching of sequences of events.
    • Events now should self-dispatch… for direct deliver to the business/controller layer.

2) View Notification

  • Built-in framework support to allow views to request direct notifications when buisness events respond.

3) FrontControllers

  • SubControllers are available so modules implemented with
    sub-MVC and dynamically aggregated and used within a global MVC
  • Improved error checking
  • Ability to easily register a Function callback for any business event

4) Command Implementation

  • Base class implementation
  • Enhancements to support aggregation of event-business logic within a single Command class.
  • Support for the optional view notifications
  • Best practice to deprecate Command sequencing

5) Delegate Implementation

  • Base class implementation
  • Support for easy queue of delegate calls
  • Improved support for WebService use and WSDL errors
  • Best practice to allow easy data transformations
  • Best practice to hide multiple server calls

6) ServiceLocator

  • Configure services (RDS) at runtime
  • Configure timeouts of HTTPService and WebService

April 10, 2008

Simple XML creation with Python

Filed under: cool, dev, education, python, tip, tool, web2py — michaelangela @ 10:39 pm

I was so happy when I first found Amara. It was the easiest thing I had seen for creating XML with Python. It’s quite serious stuff because it can probably handle just about anything you throw at it. Then I heard about the wonderful web2py project. One of it’s beautiful aspects is XML generation, or any tag type of thing actually. Some of that discussion is here. Thing of beauty. I wanted to use web2py but because of time restraints, my current project will continue to use Django, which definitely isn’t a bad thing. I just understand web2py more intuitively. I thought about using the TAG but I didn’t want the extra database hit when importing TAG from the gluon.html library. 😦

So I decided to search for python simple xml thinking of PHP’s SimpleXML. Results with DOM, SAX or elementtree… or anything like that… automatically disqualified. Amara was better for me than those. Then I saw pyfo…

pyfo – Easy XML Generation from Python

This package was developed by Luke Arno for Central Piedmont Community College in response to dissatisfaction with available alternatives for quickly generating XML. Concatenating strings is ugly and error-prone, using OO APIs for XML is heavy and overkill for generating simple XML output.

No kidding!

In [16]: from pyfo import pyfo

In [17]: a=(‘test’,(‘test’,’more stuff’,{‘cool’:’beans’}))

In [18]: pyfo(a)
Out[18]: u'<test><test cool=”beans”>more stuff</test></test>’

In [19]: print pyfo(a, pretty=True, prolog=True)
<?xml version=”1.0″ encoding=”utf-8″?>
<test cool=”beans”>more stuff</test>

Does it get any easier than that?!

Extract .bz2 on Linux

Filed under: cool, education, linux, one-liner, tip, tool — michaelangela @ 8:37 pm

I am updating some python libs on my webfaction host. The python easy_setup isn’t working for this particular bit though which is unusual. It’s the first time it didn’t work. The reason? It seems it chokes on .bz2 archives. The one in particular is python-dateutil. Fortunately a quick wget later and it’s downloaded. On OS X, .bz2 archives are handled natively. I didn’t know how to do that on Linux though but this post had the answer. In this case I needed the tar xjvf variant. A later poster noted that years later it was still a useful post. This is now even later and still useful. 🙂

how do i extract .bz2 – Linux Forums

If it’s .tar.bz2, then you can use

tar xjvf cornbread.tar.bz2

to extract it all at once. If it’s just .bz2, then use

bunzip2 spankythefish.bz2

Hope this helps.

Update: I was installing Amara which I have been using for some XML handling. Installing it for python 2.5 on my host prompted the install of python-dateutil as a dependency. That didn’t happen on the Mac as I did it just now. Interesting. Also installing python-dateutil on the Mac went without a hitch. It recognized the archive type and just brought it in no problem. It probably has to do with bz2 support on the system then? But the tar xjvf can handle it on the host so something somewhere isn’t checking the file type. Interesting.

April 8, 2008

Local subversion on 1and1

Filed under: 1and1, automation, cool, dev, eclipse, education, svn, tip, tool, webfaction — michaelangela @ 4:15 am

1and1 had an update. Good. It broke subversion. Bad. 😦 After a short fight with subversion 1.4.6 (which didn’t work) I thought about using 1.4.5. Fortunately that’s pretty straightforward and… it works! So here are the commands for that. I develop on Eclipse using a JumpBox Trac/Subversion server locally. Changes to my Django app and Flex app are stored there. Then I can pull it from outside over ssh. Very helpful. Well… 1and1 is only file hosting. Webfaction hosts the fun stuff.

cd ~/some/src/directory
wget http://subversion.tigris.org/downloads/subversion-1.4.5.tar.gz

wget http://subversion.tigris.org/downloads/subversion-deps-1.4.5.tar.gz
tar xvfz subversion-1.4.5.tar.gz
tar xvfz subversion-deps-1.4.5.tar.gz
cd subversion-1.4.5
./configure --prefix=$HOME
make install

April 5, 2008

Building Flexlib from SVN source to get openEnd and closeEnd events for WindowShade

Filed under: component, cool, dev, eclipse, education, flex, mac, subclipse, svn, tip, tool — michaelangela @ 12:20 am

Short version: You must provide a path to the manifest.xml file in order for ant to find it! For example:

&amp;amp;amp;lt;arg line="-namespace http://code.google.com/p/flexlib/ /path/to/manifest.xml" /&amp;amp;amp;gt;

Long version: I didn’t know that… thought it makes total sense in hindsight.

I am using the very nifty WindowShade from the life-saving (OK that’s a bit melodramatic…) FlexLib library. However, I wanted to be notified of open and close events. I heard somewhere (can’t find where now) that those events have been added into the SVN for FlexLib. I didn’t want to have to do a checkout and copy those files over and update it everytime the FlexLib SVN code updated… not fun. Fortunately there is a note in the FlexLib Wiki about creating a FlexBuildProject from the svn tree. This got interesting. I never build a SWC before and it certainly makes it a lot easier.

I decided to take the plunge.

I previously installed ant and all the other goodies (like subclipse) from previous project development, including my still-not-quite successful compilation of the Cairngen project for Cairngorm. (On a mac. That’s another story.)

Anyway, after fiddling with the build.xml file and the build.&amp;amp;amp;lt;your platform here&amp;amp;amp;gt;.properties file, it wouldn’t compile. compc complained about not being able to open the manifest.xml file. So very close. Then after a bit of digging, this note popped up.

Talk:Flex Ant Tasks – Adobe Labs

&amp;amp;amp;lt;namespace uri="http://www.company.com/2007/mxml" manifest="${CustomFlexLibrarySource.dir}/customFlexLibrary-manifest.xml"/&amp;amp;amp;gt;

That actually still provided that user with an error which is unfortunate. It’s also unfortunate I don’t know how to help in that situation. 😦 However the bit about providing a full path to the manifest.xml file was the tip I needed. And so, the flexlib.swc file has been created. A quick hit with the SVN update command followed by another build will keep it current. Gotta like that. Of course I need to test it and make sure I built it right, i.e. it works… 🙂

There is an option for running tests for the build as well. Well… let’s see…Run as &amp;amp;amp;gt; Ant Build… add compile tests… test… OK… trying…working…working… doh! Gotta uncomment the the flashPlayerDebug.exe line. Doh! It can’t execute Flash Player.app. Gotta set the path to /path/to/Adobe Flex Builder 3 Plug-in/Player/mac/Flash Player.app/Contents/MacOS/Flash Player instead.

What ho! It worked! Other than some deprecation warnings it worked. Cool.

update…Building the examples and everything else works without a hitch now as well. And yes I have the new openEnd, closeEnd and other properties I was looking for in WindowShade. However I got the “unable to export SWC oem”. I haven’t found a solution for it yet. I saw this:

I think I’ll start using this set up for many other libraries…

[flexcoders] Re: Compiling problems

First of all, I rebuild the workspace using the instructions (I did 
not see it before:( ) like FlexBuilder -clean -vmargs -Xmx512m.

Furthermore, it remained the problem of the connection for my swc.
After reading all debug instructions, I saw that the cause was the
history management. I disable it and it works.

But why the history management caused an error during execution (no
modification made to the swc) ?????

But that’s about actual Flex projects and not just a library project. More study on this later. (Hey, it’s Friday night after all! Time for a break! :-p ) But it’s working as needed so far… *finger’s crossed* Oh yes, the compile tests did pass so that’s a good sign.

April 4, 2008

Computed properties and binding

Filed under: dev, education, flex, mvc, tip — michaelangela @ 4:46 am

This is also something I’ll have to take a look at later.

Computed properties and binding « FLEXYGEN

Updating views in response to model changes is a snap with Flex data binding.
A model property is set to be [Bindable] and and a view property is set to an expression in curly braces that refers to that property. &amp;lt;snip&amp;gt;

Flex implements this by dispatching a PropertyChangedEvent when “description” changes, but by implementing implicit getter and setter functions, one can customize the event. In the MVC sample I wrote, which I hope to post one of these days, I stumbled upon the following idiom, where several bindable properties are based on a single value changing.

Cairngorm, Flex and MVC

Filed under: cairngorm, dev, education, flex, mvc — michaelangela @ 4:43 am

Cairngorm helps when you’re wanting to know how to structure things. There are other options, especially as you start actually understanding the language. 🙂 PureMVC is an alternate framework. Then Flexygen has a simple MVC sample… without using Cairngorm. It’s not that Cairngorm is bad! It’s the de facto standard framework for Flex (right now at least). But sometimes it feels like you’re fighting it a bit… at least for those who are still learning like me. These are just some things to keep in mind.

Up next is Practical Patterns in Flex which also offers another possibility. I’ll have to look at it in more detail to understand it more though… I’ll save that for another day!

joeberkovitz.com » MAX 2007 in Barcelona: Talk Materials Online

A presentation called Practical Patterns in Flex, which I adapted from Jim Echmalian’s
talk at 360Flex earlier this year. This features a brand new take on
the Model-View-Controller-Service architecture, and highlights the use
of specific design patterns to remedy problems of encapsulating
responsibility, dealing with asynchronous operations, and gaining
access to the “right” controller without using messy singletons. I put
together a working sample application in source code form that accompanies the talk.

April 3, 2008

Using Degrafa for customizable data visualization

Filed under: component, cool, dev, education, flex — michaelangela @ 3:58 am

You have to see it to appreciate it. I especially like the capacity indicator “distribution ala itunes/ipod”, and the shape renderer. So sweet!

Degrafa &amp; Data Visualization

While syncing in iTunes I was looking at the indication
of how my media was distributed across my iPhone and realized that same
visualization could be duplicated using Degrafa. I used a series of
different colored RegularRectangles, some VerticalLineRepeaters for the
inset markings that dynamically change count depending on the size,
some other Rectangles for highlights and shadows, and a
RoundedRectangle to mask the area. I also through in a ComplexFill
composed of a Solid, Bitmap and Blend fill to create the colored plaid
effect. This was really easy to do with binding to change the width,
capacity bars, inset marks and colors.

Older Posts »

Create a free website or blog at WordPress.com.