Andy Czerwonka http://www.andyczerwonka.com late night musings on programming, technology, food, business... pretty much anything I feel like writing about posterous.com Thu, 09 Feb 2012 13:32:00 -0800 Picking a web technology isn't as easy as it used to be... http://www.andyczerwonka.com/picking-a-web-technology-isnt-as-easy-as-it-u-45228 http://www.andyczerwonka.com/picking-a-web-technology-isnt-as-easy-as-it-u-45228

I find myself in a bit of a conundrum. I'm building a new, modern, web-based application and not only do I have to pick a technology, I have to pick an architecture. I think it is fair to say that these days its a tough choice because we have more options than we did even 5 years ago.

First things first, I've made the decision that Scala will be the server-side language. I have my reasons, and this is not a Scala versus XYZ post - that choice has been made. I've also sucummed to the fact that we're on the web, in the cloud, so I'm not even going to try and get away from Javascript.  Maybe I will with CoffeeScript, but I will be writing Browser-hosted code.

Now, assuming Scala, most people would probably jump to either Play! or Lift. Probably Play! given it's endorsement from Typesafe, but I think I have another more important question that needs answering first. What's the architecture? If I want a very rich client, do I really need more than a simple stateless service layer based on the fact that we'll have a tonne of Javascript anyway? I'm not sure it'll be a single-page webapp, but is something like BlueEyes potentially the right choice? Lift and Play! are much more heavyweight in that they take on much more responsibility. They generate the HTML and for these frameworks, the browser is pretty dumb. Things like routing, validation, Ajax and Comet support are all server-side concerns. Because the browser is more capable today, rich, interactive features are normally implemented by generating and injecting Javascript from the server.

My question boils down to this. Do I go with a traditional Lift/Play! framework where the server takes on both the client and server responsibility or do I go with a rich client + REST-style service layer where the client takes a more prominent role in the application? An architecture where the client deals with routing, validation, binding, etc. I'm seeing frameworks like KnockOut.js, Sammy.js, Sproutcore, Backbone.js,... I'm not going to list them all but suffice to say that they all take on some of these framework features from a client-side perspective.

If I choose Play!, am I giving up some of that rich UI? What about situations where I want to provide service API's for integration/mashup/mobile purposes? How would Play! help me here? Clearly BlueEyes plays well here. I think I need a service layer regardless.

If I choose BlueEyes, what does my client code look like? How many of these Javascript-based frameworks do I need to give me what I need? I still want most of my business-logic in my service layer, but routing, binding.. all that UI stuff would be a concern of the client.

So many choices... I'd love to hear your thoughts.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Fri, 09 Dec 2011 13:36:00 -0800 Hibernate Best Practices http://www.andyczerwonka.com/hibernate-best-practices http://www.andyczerwonka.com/hibernate-best-practices

Delete_key1

I'd love to just delete it, but it has managed to entangle itself throughout my entire application! Dammit!

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Mon, 14 Nov 2011 12:26:00 -0800 Back in Poland? http://www.andyczerwonka.com/back-in-poland http://www.andyczerwonka.com/back-in-poland

Nah... Just kidding. I'm in Reading, UK again this week.

Today's "find a place for dinner" mission needed a little more thought given last night's disaster with Mexican cuisine. Because my hindsight is ever so powerful, I was able to assess my mistake simply by making the observation that the Mexican community is mostly non-existant here, at least from where I'm sitting. It should have been obvious that the chances of finding a great Mexican restaurant were slim.

Armed with that knowledge and the fact that I've run into more Polish people that I can count, I quickly came to the conclusion that Polish cuisine might be a good bet. Google helped out and suggested I try Gospoda. Gospoda sits in the middle of what looks to be a run-down Polish community, one that reminds me of Chicago's "Polska dzielnica". What I do remember about the Polish community in Chicago was the great food and hospitality. Would Gospoda up my record to .500?

Menu

My Polish is still good enough to read this menu, but after a discussion with a guy at the bar (half English, half Polish), I realized that they serve much more than what you see here.

Flaczki

Best Flaczki I've had in a long time, maybe ever.  Sorry Mom.

Dinner

The Schabowy Kotlet was also great, but I'm not ready to give it the top prize.

All-in-all, a much better effort tonight. Some may be offended by the cash-only service, but me being a Pole myself I know that there isn't one on the planet that likes to pay taxes.

Tomorrow is my last night I'll have to do Indian.  You can't come to the UK and not have Indian food, that much I know. .667 is a good record for three days work.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Mon, 19 Sep 2011 12:20:00 -0700 Hello Wokingham Berkshire http://www.andyczerwonka.com/hello-wokingham http://www.andyczerwonka.com/hello-wokingham

Wokingham
Or should I say 'Ello!!!

I'm staying in Wokingham, Berkshire, commuting to Reading everyday to work with a client.  I flew in yesterday and haven't really been funcitonal until now given the jetlag and such.  I finally feel about 70%. Another day and I'll be 100%.

Wokingham is really small, but I've got everything I need. It has very interesting architecture, where 17th century buildings don't look out of place. There are many pubs, one on just about every corner, sometimes two or three.  I'm not really a beer drinker, but I'll visit a pub or two before I leave to be sure.  I'm thankful that everything is in walking distance, because if I were to drive a car around here there is no way I'd survive.  Just walking down the street is dangerous. As I cross the street I look left when I should be looking right.  I'd better figure that out soon.

Off to Reading tomorrow.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Thu, 28 Apr 2011 13:29:00 -0700 Scala IDE Beta 2 Seems to Work! http://www.andyczerwonka.com/51145868 http://www.andyczerwonka.com/51145868

In the last year or so I've been working to Scala. Initally when I came across Scala, there was an Eclipse plug-in that was supposed to be the development environment for Scala. Back then, I tried it and it worked, but only for very trivial cases. It was in its infancy. Surprisingly, as the language matured, the IDE seemed move in the wrong direction, progressively getting worse and worse. In fact, the last time I remember taking it for a spin, I couldn't even create an empty Scala project. Nothing worked. I since then have been working with emacs ENSIME and sbt. I've been satisfied with that environment, but I'm always wanting more.

A few (maybe a dozen or so) months have passed since I've looked at the Eclipse environment for Scala, so I figured I'd give it a try today.

I downloaded a fresh copy of Helios, installed the plugin and off I went.  Very surprisingly, it worked.  Well, the following file did.

It's a trivial example to be sure, but this much code never worked for me in any of the previous releases. This is fantastic news, because one of the things that will help with Scala adoption, and particularily in adoption from Java developers who are already on the JVM, is a development environment that the community is comfortable with.

Kudos to the Scala IDE team.

Here's the code from the demo if you want to try it yourself.

package euler

import scala.actors.Actor
import Actor._

object Euler011 extends Actor {

  type Matrix = Seq[Seq[Int]]
  case class CalculateMaxRequest(matrix: Matrix, from: Actor)
  case class CalculateMaxReply(matrix: Matrix, max: Int)

  var count = 0

  def execute() {
    val input = "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 " +
                "08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 " +
                "62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 " +
                "13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 " +
                "37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 " +
                "28 66 33 13 80 24 47 32 60 99 03 45 02 44 75 33 53 78 36 " +
                "84 20 35 17 12 50 32 98 81 28 64 23 67 10 26 38 40 67 59 " +
                "54 70 66 18 38 64 70 67 26 20 68 02 62 12 20 95 63 94 39 " +
                "63 08 40 91 66 49 94 21 24 55 58 05 66 73 99 26 97 17 78 " +
                "78 96 83 14 88 34 89 63 72 21 36 23 09 75 00 76 44 20 45 " +
                "35 14 00 61 33 97 34 31 33 95 78 17 53 28 22 75 31 67 15 " + 
                "94 03 80 04 62 16 14 09 53 56 92 16 39 05 42 96 35 31 47 " + 
                "55 58 88 24 00 17 54 24 36 29 85 57 86 56 00 48 35 71 89 " + 
                "07 05 44 44 37 44 60 21 58 51 54 17 58 19 80 81 68 05 94 " + 
                "47 69 28 73 92 13 86 52 17 77 04 89 55 40 04 52 08 83 97 " + 
                "35 99 16 07 97 57 32 16 26 26 79 33 27 98 66 88 36 68 87 " + 
                "57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69 04 42 16 " + 
                "73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36 20 69 " + 
                "36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16 20 " + 
                "73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54 " + 
                "01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 " + 
                "48"
    val intArray = input split " " map (_.toInt) toList
    val array2D = (intArray grouped 20 toList)
    val sliced = array2D.map(row => row.sliding(4, 1).toList).sliding(4, 1).toList
    val matrices: List[Matrix] = sliced flatMap (_.transpose)
    count = matrices.size
    println("We have " + count + " matrices to process, each using an actor")
    for (matrix <- matrices) {
      val calculator = new MaxProductCalculator
      calculator.start()
      calculator ! CalculateMaxRequest(matrix, this)
    }
  }

  var max = 0
  override def act() = loop {
    react {
      case CalculateMaxReply(matrix, maxProduct) =>
        max = if (maxProduct > max) maxProduct else max
        count -= 1
        if (count == 0) {
          println("Found it.  The answer is " + max)
          exit()
        }
    }
  }

  class MaxProductCalculator extends Actor {
    override def act() = loop {
      react {
        case CalculateMaxRequest(matrix, actor) =>
          actor ! CalculateMaxReply(matrix, calculateMax(matrix))
          exit()
      }
    }

    def calculateMax(matrix: Matrix) = {

      def calculateDiagonals(matrix: Matrix) = {
        var leftTotal = 1
        var rightTotal = 1
        val end = matrix.size - 1
        for (i <- 0 to end) {
          leftTotal = leftTotal * matrix(i)(i)
          rightTotal = rightTotal * matrix(end - i)(i)
        }
        (leftTotal, rightTotal)
      }

      val horizontal = matrix.map(_ product).max
      val vertical = matrix.transpose.map(_ product).max
      val (left, right) = calculateDiagonals(matrix)
      val products = horizontal :: vertical :: left :: right :: Nil
      products max
    }

  }

}

object Runner extends Application {
  Euler011.start
  Euler011.execute
}

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Mon, 21 Mar 2011 21:46:00 -0700 Dear TELUS http://www.andyczerwonka.com/2011/03/dear-telus.html http://www.andyczerwonka.com/2011/03/dear-telus.html
March 21, 2010

TELUS Client Care
PO Box 7575
Vancouver, BC
V6B 8N9

To Whom it May Concern,

I wanted to write this letter to express my extreme frustration and disappointment with TELUS. I have been a long-time customer, 20 years of phone services plus High-Speed Business Internet services since the day they were introduced.

On Thursday March 17 2011, I decided to move from Bell's TV Satellite service to TELUS' Optik TV service. I spent 90 minutes on the phone with a very friendly customer services representative and completed the order, signing up for a three-year contract for Internet + Optic TV. As I was putting in the order, I cancelled my Business Internet service to make room for the new services.  The order was scheduled to be completed today, March 21st, at 8:00am.  The Internet service was turned off as scheduled, Monday morning around 9:00am.  We were told it'd probably be very close to 8:00am because we were the first appointment, so I booked the morning off from work to be home during the installation. 8:00am Monday morning arrived and nobody. We waited until 10:00am, then we called TELUS. The CSR told us to be patient and that it shouldn't be too long now. Two hours later, I called again. This time, the CSR decided he'd investigate by calling dispatch to find out what's going on. To his surprise and mine, the order was not sent to an installer. The CSR said that we had been given high priority and someone would be coming to install the service "within an hour or two". I called my office and booked the rest of the day off.  Two hours later, at 2:30 pm, the same CSR called to inform us that there had been a mistake with our order and nobody was able to help us today. The order would have to be rescheduled for the next available time, Friday March 25th.  Really?  Wow.

I took the day off work, had my working Internet turned off, and now I'm basically told to reschedule five days later. Obviously, that is not acceptable. The lack of competence that TELUS continues to show is remarkable. TELUS should thank its "lucky stars" that the CRTC is in place to protect TELUS' membership in a duopoly, essentially guaranteeing revenue. In a competitive market, I'm sure it wouldn't survive. It's unfortunate that there is no real competition and that my only other choice is Shaw, who I'm sure is similarly incompetent.

Maybe one day I'll be lucky enough to own a business where being incompetent is profitable.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Fri, 12 Nov 2010 17:32:00 -0800 Lesson in Canadian Geography http://www.andyczerwonka.com/2010/11/lesson-in-canadian-geography.html http://www.andyczerwonka.com/2010/11/lesson-in-canadian-geography.html

I live in Calgary.  I'm clearly not a master in geodesy, but I'm pretty sure Mississauga is not somewhere between Richmond and Calgary.  Canada Post rocks.  

Wtf

And we're wondering where our tax dollars go...

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Tue, 01 Jun 2010 00:09:00 -0700 Jamie Oliver's TED Prize wish: Teach every child about food | Video on TED.com http://www.andyczerwonka.com/jamie-olivers-ted-prize-wish-teach-every-chil-atxAH http://www.andyczerwonka.com/jamie-olivers-ted-prize-wish-teach-every-chil-atxAH Jamie Oliver's TED Prize wish: Teach every child about food | Video on TED.com

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Fri, 26 Feb 2010 13:09:00 -0800 Know When to Stop http://www.andyczerwonka.com/know-when-to-stop http://www.andyczerwonka.com/know-when-to-stop I get myself into these situations once in a while where I get really excited about a particular problem and end up with a mess as the solution.  Here's my workflow.
  1. Think about it.
  2. Sketch out a solution.
  3. Code towards my solution.
  4. Refactor (go to step 1)
Somewhere in that loop I go from 4 to 3 to 4 to 3 a bunch of times and when I come up for air I have a complete mess.  Ideas pop into my head quickly and I seem to go down strange paths here and there. Before I know it my code is littered with random design thoughts that don't hang together in any way.

STOP!!!

... git here we come ...

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Thu, 10 Dec 2009 00:32:00 -0800 xargs == awesome http://www.andyczerwonka.com/2009/12/xargs-awesome.html http://www.andyczerwonka.com/2009/12/xargs-awesome.html
find . -name *.java | xargs -n1 -I@ touch -c @

For those times when commands like touch won't take stdin.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Wed, 25 Mar 2009 16:57:00 -0700 EclipseCon 2009 - Days 2 & 3 http://www.andyczerwonka.com/2009/03/eclipsecon-2009-e4.html http://www.andyczerwonka.com/2009/03/eclipsecon-2009-e4.html

I've gone to quite a few sessions over the last two days. Cloud Computing, UI Showcase, Nebula, SOA... there's so much good stuff to see. Some are great, some are not so great. In most cases the speakers are rushing because they're running out of time. There's no time to ask questions during the sessions, which wouldn't be so horrible if I weren't myself rushing to the next session, not allowing me to catch them for a quick Q&A. Maybe these sessions were designed that way? :-)

About a third or the talks I've gone to are about e4. That's code for "Eclipse 4.0" for those of us who don't know the lingo. This is a really hard topic for me. Let's see, where do we start?

"Schizophrenia is a psychiatric diagnosis that describes a mental illness characterized by impairments in the perception or expression of reality, most commonly manifesting as auditory hallucinations, paranoid or bizarre delusions or disorganized speech and thinking in the context of significant social or occupational dysfunction."

Hmnn... "...impairments in the perception or expression of reality...". Given that definition, either the speakers have it or I have it. One minute I get it, thinking, "hey, you're bang on", and the next I'm thinking "what? are you insane?".

The Sane Side of Our Schizophrenia

I may not be on side with the approach to the problem, but the use cases driving the solution make sense - at least to me they do.

Java 6

A small point in the grand scheme of things but nevertheless worth mentioning. They're not stuck to Java 1.4 anymore. I've seen the code. It's undeniably not 1.4 compatible. Finally. Fantastic.

The Modeled UI - Declarative User Interfaces

I definitely like the idea. The model approach is trying to lower the bar when it comes to entering the world of Eclipse-based development. Build an EMF model, hook up a framework-supplied renderer, and off you go. It's how we should be building UI's anyway. The only reason we don't work this way today is because its an extremely hard problem to solve well. It's been tried before. This all feels very VisuageAge Smalltalk to me. I don't want to discourage the research, but let's not ignore those learning's or we;ll repeat the mistakes. What will most likely evolve out of e4 is a hybrid approach, where parts of your UI will made up of the EMF models plus renderers and parts will be made up of "do it the old way" code. When I try an visualize what that would look like, I find myself getting back to where I am today. Inconsistency come to mind. Isn't API inconsistency the root of this barrier-to-entry that this very solution is trying to break down? RCP development has a steep learning curve because it makes me learn 10 separate and inconsistent frameworks to do it well. Platform, SWT, JFace, GEF, Preferences, Memento... to name a few. I don't know - I'm just asking the question. Think about it... is this really going to make it easier? How am I going to build an EMF model that allows me to add that third-party widget library that's built on Swing and integrate its selection mechanism with the Workbench across two independent threads? I'll tell you how. It's not. But guess what? I do exactly that in my product today, which is built on the 3.x stack. It wasn't easy to be sure, but I'm able to do it. Please don't take that away from me.

Another key will be tool support. Dear e4 Committers: If you take away our refactoring tools, we won't use it. We've proven that in the past. Until the refactoring tools address the code in plugin.xml, then we're not going to put our stuff in plugin.xml. Luckily enough many of the PDE's refactorings do look in there today. Let's just maintain a good level of support for whatever new XML files are introduced.

In the end, the "model + renderer" approach makes a lot of sense to me. As developers we definitely spend too much time solving UI problems instead of business problems. This is a step in solving that problem. Saying that, I'm not betting my next business strategy on the Summer of 2010. I do see this working for the trivial CRUD applications out there, but not for the more complex. But you guys are smarter than me, so I look forward to it. There is value here if you can pull it off - a tonne of it. I'll be watching closely.

The "Not So Sane" Side

SWT Browser Edition

This makes me feel like we're trying to commercialize some mad scientist's experiment in human cloning. Just because you can doesn't mean you should. It's definitely interesting to build a cross-compiler from Java to ActionScript, but I need someone to help me with the use case. Everyone is talking about bringing the IDE to the web. What for? I don't get it. Please someone, give me one use case that isn't simply about some wow factor. There was a lot of "Oooohhhh.. ahhhhhhhh" when the RCP Photo application demo was shown running inside the Adobe-powered browser. I too think that's very cool. But show that same demo to your boss see if you get the same reaction. I'm not sure you will. Is the desktop deployment model really that broken? Why does everyone want to run their friggin applications in their browser? Or do they?

CSS Styling

This was also introduced as a "someone had some time on their hands and thought it'd be cool if..." kinda thing. This gets a "thumbs down" because every time I look at a CSS file I quickly turn away in fear of turning to stone. Maybe I'm just scared that someday I'm going to wake up and my "to do" list is going to have a "fix screen layout" and its all in CSS. What do I do know? The Idiots Guide to Assember - here we come.

In my not-so-humble opinion, CSS is as bad an implementation of a good idea as I've seen.

At least its optional.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Tue, 24 Mar 2009 13:59:00 -0700 EclipseCon 2009 - Day 1 http://www.andyczerwonka.com/2009/03/eclipsecon-2009-day-1_24.html http://www.andyczerwonka.com/2009/03/eclipsecon-2009-day-1_24.html

It was definitely time to visit EclipseCon. I've been using Eclipse RCP for almost four years now, so I feel like if I'm going to visit a technical conference this year, this is the one. Well... now that I think about it, there are probably others I'd like to visit too, but I'm here now so I'll write about this one.

This Place Just Oozes Passion

I spent a lot of time here eight years ago, commuting between San Mateo and Calgary on a weekly basis for over a year. It's nice to come back to the seems-like-recession-proof Bay Area for technical inspiration. It, like no other place I know of, absolutely oozes passion for technology - primarily software technology. There was a breakfast/registration this morning and it seemed like everyone was giddily running around like a bunch of crazed schoolgirls waiting in line for the premier of Twilight. Honestly? I'd like to take some of that passion home with me and spread it around.

Ya-Who?

As I walk down the street, within one hour I inadvertently find the homes of many of the technology companies we've come to love and hate. Cisco, Citrix, AMD, Intel, WebEx, Oracle, Sun... err... IBM, Yahoo, etc. Seems like they're all here... all within a few square kilometers. Speaking of Yahoo, their campus still has an incredibly large footprint. It seems to go on and on. Blocks and blocks of buildings, floral gardens, manicured courtyards, etc. I bet they hire three gardeners for every programmer. Every second car in the parking lot is BMW - although maybe they're 1999 vintage, purchased when the now 30-somethings where hired as up-and-coming 20-somethings looking to take over the world. Who knows. What the hell does Yahoo do anyway? I thought they disappeared when Google came along. I stopped using them - didn't you? Guess not.

Mac's Everywhere

Another thing I'm noticing is the disproportionate number of MacBook versus Windowz machines. I'd say it's at least 2:1 in favour of the Mac's. The table I'm sitting at now is 4:1. There's the odd Linux guy back there, but from what I can tell you're only using a PC because you didn't have to pay for it. What's interesting to me is that a lot of the committers are using OSX too. Maybe now that 3.5 runs native on OSX, everyone feels like the the Mac is now ready for Eclipse. Not sure. As a more-than-casual Mac user myself, I can tell you that Eclipse runs great on Windows and okay on OSX. Saying that, I haven't been using 3.5 for very long and the SWT folks spent basically all of 3.5 porting the Carbon code to Cocoa. Maybe I'm in for a pleasant surprise.

Morning Session - Binding, Commands & Common Navigator Framework

Binding - The Better of Two Evils

Anything to get rid of that boilerplate we have to write just to get our models in sync with our UI. It's such a trivial problem that just begs for a declarative solution. I must say, I think the Eclipse guys are going down the right path. I find the same two problems, over and over, with most declarative solutions in this UI binding space. Firstly, most solutions take away control when it comes to the timing/event that drives the binding. You lose to fine grained control you need in rich-client UI's. Secondly, bindings only work with a specific handful of widgets. I'm happy to say that there's a decent answer to both of these problems.

For problem #1, the framework allows us to specify the event.

DataBindingContext dbc = new DataBindingContext();
ISWTObservableValue ui = SWTObservables.observeText(myTextWidget, SWT.Modify);
IObservableValue model = BeansObservables.observeDetailValue(myModel, "body", String.class);
dbc.bindValue(ui, model);


Most of you are going to look at this code and cringe. At least I hope you will. I'll give you the benefit of the doubt and assume you're going to say that this is a terrible way to express a binding because reflecting into a Bean to get its property value exposes you to a bunch of runtime errors where an alternative solution would allow compile-time error checking. Well you're partly right. The problem is not the framework, it's Java. I don't see my way clear to an alternative solution. If you do, please share. Now if this were Scala, where I'm allowed to pass methods as parameters for example, I see a completely different approach that is both declarative and type safe. But that's another topic for another day. That day is probably right around the corner because its been bugging me for a while.

For problem #2, just roll your own. The binding is pure API, supported by a bunch of helpers all over the place. There are built-in solutions for the most common elements: fields (text, date, boolean, etc), lists, tables and trees. They even provide a solution to the common Master-Details problem. But, if your use case calls for a new UI component that isn't covered, just write your own. I haven't tried this yet, but look forward to do so.

Update Strategies & Validation - Arghhhh... Java - You Suck!!!

Good idea, bad implementation. To be fair to the guys, they're handcuffed here. Friggin' Eclipse is still hanging on to Java 1.4. I mean really... we're on 6. Does anyone really still use 1.4? I think this topic deserves its own post, because if I see another snippet of code that looks like this I'm going to apply for one of those "Yahoo Gardener" gigs.

new UpdateValueStrategy().setConverter(new IConverter(){
  
  public Object getToType() {
   return Date.class;
  }

  public Object getFromType() {
    return String.class;
  }

  public Object convert(Object from) { 
    // convert your String to a Date
  }

};

Are you kidding me? That would never pass a code review anywhere I've worked. Let me see, can we make this a little better?

new UpdateValueStrategy().setConverter(new IConverter<Date, String>() {
  public Date convert(String from) throws UnconvertableFormatException {
    // convert your String to a Date
    // because it's any string, I'll make you handle the exception
  }
};


Please tell me that its clear to the decisions makers over at Eclipse Headquarters that the lack of generics support in the Eclipse framework really creates a major problem when it relates to technology adoption. Anytime I'm writing code that integrates my models with an Eclipse UI, I feel like I might as well be writing all this stuff in Ruby. I might as well turn off incremental compilation because I'm passing a bunch of Object references around. Once the Eclipse frameworks get a hold of me, all my types have been lost. To get them back, I'm casting all over the friggin' place. Discussions with a couple of the committers indicates that they're also frustrated with these handcuffs. Rumors seem to point to e4, but I'm going to hunt for a definitive answer while I'm here.

Commands - It's All About Scale and Extension

I'll just say a couple of things about the declarative Command framework. First of all, for those of you looking for an 'undo' solution, this is not it. Not that it can't be used for that use case, but that's not what it was developed for. Secondly, there seems to be a bit of a bad smell around 'best practices'. The guys running the session didn't get into the value proposition. They started with "here's how you do this" and "here's how you do that". Nobody wanted to talk about "why do I want to do this?". When I asked the question, the answer was weak to say the least. Don't get me wrong, I absolutely see the value proposition. It's about extension and scale. If I want my business application to also play the role of platform, i.e. host for extension, then I want the extender to have options too. Perfectly valid. But if I'm just building a small application on top of the RCP stack then I don't see why I'd want to declare my commands outside. There's definitely an overhead I have to pay in terms of development and tool support.

Assuming I want this capability, the Command declaration gives my application a way to show my commands in a menu without loading the class, which is all possible because of Equinox. At-the-end-of-the-day, the Command framework is simply further UI decoupling of the legacy ActionSet strategy. Again a step in the right direction.

Common Navigator Framework (CNF) - Platform Navigation

CNF is about providing a solution for a common integration/extension use case. "Let me put my stuff in your tree view". One plugin can show Projects, another plugin can show Tasks. CNF allows you to do this without binding the two plugins. It does so in such a way that the user doesn't have to use two separate navigation views. Nice.

Afternoon Session - Advanced RCP

First things first - it's not that advanced. We were presented with "best practices in RCP" using a sample MP3 application. All-in-all, I liked the session because it brought everything together. The funny thing about it is that while it brought together many of the frameworks, it did uncover many inconsistencies. For example:

Best Practice #1 - Use Adapter Factories

"Use adapter factories (IAdapterFactory) to adapt your models to the binding context needed at the time". For example, if you want your model to show up in a tree, do it this way.

treeViewer = new TreeViewer(parent, SWT.BORDER| SWT.MULTI| SWT.V_SCROLL);
IAdapterFactory adapterFactory = new AdapterFactory();
Platform.getAdapterManager().registerAdapters(adapterFactory, Mp3File.class);
treeViewer.setLabelProvider(new WorkbenchLabelProvider());
treeViewer.setContentProvider(new BaseWorkbenchContentProvider());

Simple. Register your adapter and the BaseWorkbenchContentProvider will find the adaption in the factory. We don't need to get into the adapter code here - it's not the point. The point is that I don't have to use any content provider other than the one provided by the workbench. That begs the question, "why are you making me specify it then?", but I'm not going to chase that down right now. Anyway, not a big deal. It works. I get it. Great. Sure. Whatever. Now for Best Practice #2.

Best Practice #2 - Use Virtual Tables

"When you have large datasets, only load what you need". Ya, no kidding. Sounds like a plan.

TableViewertableViewer = new TableViewer(parent, SWT.VIRTUAL|SWT.BORDER|SWT.V_SCROLL);
// skipping the noise
tableViewer.setItemCount(100000);
tableViewer.setContentProvider(new LazyContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());
tableViewer.setUseHashlookup(true);
tableViewer.setInput(null);

What? LazyContentProvider? Didn't you tell me less than 10 minutes ago that I'm to adapt via an IAdapterFactory and use the BaseWorkbenchContentProvider?. Make up your mind! Turns out that #1 and #2 are not only incompatible, but they're mutually exclusive. Awesome. NOT!!!

Enough About Day #1

In the end, I don't want to be hard on the guys. They're pumping out some good stuff and the Eclipse ecosystem is such a huge machine that it's almost impossible to keep it all together. It's evolving in the right direction. For the rants I do have I should probably put all this blogging energy into contributing to Eclipse.

Looking forward to the e4 sessions tomorrow afternoon.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Mon, 14 Jan 2008 13:33:00 -0800 Everything Looks Like a Nail http://www.andyczerwonka.com/2008/01/everything-looks-like-nail.html http://www.andyczerwonka.com/2008/01/everything-looks-like-nail.html

I've heard it before here and there, but it exactly describes how I feel working with Java for the last few years.

"If all you have is a hammer, then everything looks like a nail."

I've been writing code for over 20 years now; C, C++, Smalltalk, Java, C#, Python, Ruby, etc. When I went to school, we were taught Pascal, C, Cobol (now that sure dates me) because the school I went to wanted to get me ready for the "real world" and that world was using those languages at the time. Admittedly, I didn't learn much in school. I didn't learn much about computer science. I learned plenty about how to build simple CRUD applications using imperative programming languages. Sure, we all used SQL, but didn't spend much time understanding it. Think about programmers today, most know enough SQL to get the job done. How many times have you seen SQL stored-procedure code written... well... procedurally? I bet more than a few. Did you even notice? Did you care? I didn't. I should have.

Java Sucks

I'm not going to sit here and tell you that Java sucks, but... well... Java sucks. Why? Because there's no evolution of the language. Imperative only. Cruft everywhere. Powerless scoping rules. And, most importantly, it's limited my ability to think about problems in different ways. I naturally think procedural - give me Lisp, Haskell... forget it. I've inadvertently trained myself to only see nails.

Java is Powerful

Huge community. Many tested frameworks. I want to leverage that community, those frameworks. I want to make them better. I sure as hell don't want to start again. I'm not going to rewrite Hibernate. I don't want to rewrite Wicket. I don't want to rewrite JScience.

Why Not Ruby?

I was there for a while, but I can't stay. I really love the language. It' has almost everything I need. It has a large community. So why not? I don't want to invest my time into a toy. Sorry Ruby people, I only have enough bandwidth for one, and I see too many fundamental problems. No compiler. Not type-safe. (dodging bullets) No concurrency. Hey, I was in that community and put up with all those problems because I couldn't take Java anymore. Now I don't have to.

Scala

Scala, introduced to me by a colleague who's always on the lookout for a better way, seems to really impress. It's multi-paradigm; object-oriented, functional, concurrent. It's type-safe! Yeah! Powerful generics! Yeah! Closures! Yeah! Type-safe mix-ins! Yeah! Oh... did I mention... (cue the drum roll) it's Java! Can you imagine trying to write cross-cutting mix-ins in Java? Scala generates .class files that run in the standard Java 5 virtual machine. You want to leverage your favorite Java framework? Go ahead. No problem. What? You want your Java team to leverage a library you wrote in Scala? No problem. One drawback, and not really a language drawback, is the learning curve for all of us that see only nails.

Some of you are thinking "what the hell is he talking about?". "What's wrong with doing it the traditional way? 99% of the software we use today is built using imperative programming and they work just fine". Well yes, back some 2000 years ago, 99% or homes were built using straw and clay. They were just fine then too. Since then, homes have evolved because people wanted more. Today, people are smarter, tools are better. We want more.

Tools

Ouch. Scala isn't there. Getting better, yes, but it needs some time. Unless the tools get there, the masses won't come for the longer term. I won't come for the long term if the tools don't evolve. I've invested in Eclipse as a tool and a platform. For me, it's as important as the language - especially if the language is cumbersome. I'm not going back to vi and print statements. Forget it. I don't care how great the language is. Thankfully, Scala has an Eclipse plugin that at least gives me the critical stuff, i.e. debugger, syntax highlighting, etc. It's getting there. It just needs some time.

Give it a try.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka
Tue, 25 Sep 2007 11:38:00 -0700 Getting Real... Now That's What I'm Talking About http://www.andyczerwonka.com/getting-real-now-thats-what-im-talking-about http://www.andyczerwonka.com/getting-real-now-thats-what-im-talking-about I've recently been thinking philosophically about the best way to build software, when I stumbled upon 37signals' Getting Real book. I decided to pick up a copy here because reading online for an extended period sucks.

I'm not going to sit here and tell you it's the Holy Grail but it's the Holy Grail. For the right type of business. Sure, this book is specific to 37signals' business, or shall I say companies who make a living selling service-based software for the masses. Regardless, take these points and interpret them for your business and you'll be better for it.

The following points, directly from the book, are "bang-on". I don't care what kind of software you're creating. These points make a helluva-lot of sense to me, because I've either lived either this side and experienced the joy or that side and experienced the pain. I'm not saying that I don't agree with the others points in the book, it's just that these are the ones that really shine for me.

Note: These are in the order as taken from the book

There are a couple of points of my own I'd like to add that may arguably disagree with a couple of points in the book.

Stay The Course

Be cautious about changing your mind. Being flexible is not the same as being schizophrenic. Embrace change when you know, not when you think. See out the decisions you've made. Test them on your market. If you hire the right customer, you'll find this won't be a problem for you.

Don't Be Lazy

Agreed, you won't get it right the first time, but don't let that be an excuse to being lazy. See the big picture when you're building an application and pay attention to what you're doing. Don't let the race to running software get in the way of quality.


Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1164038/andy.png http://posterous.com/users/heOPKRstS1A5c Andy Czerwonka andyczerwonka Andy Czerwonka