grails – I get it…

A couple of years back, I was a longtime and loyal, WebWork (1 and 2), Struts (1 and 2) user. I was very reluctant to even try newfangled frameworks like GWT, or Grails. I thought that using Hibernate, Spring, I was being open enough. This was not true.

So, wanting to stay on top of my game, I opened up to things like Spring MVC, GWT, etc. It was a great idea. Fortunately, because Grails is based on so many tried and true concepts, you’re not leaving sane concepts behind for nonsensical ideas.

Here’s a simple example. Assume you are processing a request, and there’s a variable that you need to provide to the next request/page. You do not want to place this in the session, for a number of good reasons. In the previous frameworks I’ve used, you had to use interceptors that would copy certain variables over for you. This worked, but it was not clean. With Grails, I find myself using the flash concept. Wow. Such a simple idea, that now, I just don’t have to worry about.

Another obvious example is redirection and chaining. I wont waste your time talking about how this was accomplished in the previous frameworks. I will say Grails made it extremely easy. Let’s just say, you leave behind defining a couple of interceptors, and istead write 1-2 lines of code. You can look here for more information.

This post is not to denigrate the awesome work that went into the previous frameworks. But I will say, things like Grails are the manifestation of standing on the shoulders of giants. I’m still working on not using semicolons to end a line. I know I don’t have to omit them, but I’m trying to adopt that. I’m not the earliest adopter, but sooner or later, I tend to come around. I have to give thanks to true early adopters, like the @brianmichelich, answering my stupid questions.

Posted in Grails | Leave a comment

Best jQuery plugin explanantion I’ve read…

OK, so I’m trying too use jQuery, and I wanted to read up on it. After some searching on the well documented jQuery site, I found this post.

No hyperbole. This is one of the best tutorials I’ve read in along time. Early in the post, the author makes a very salient point.

Many tutorial authors offer well-written jQuery code that works in all browsers, but copying it into your site will not help you to understand how the code actually works. It has been scientifically proven that being genuinely curious about learning a subject will make a greater impact on the student’s memory than when the subject has no interest what so ever about the subject he is trying to learn. This is why I recommend paying attention to the information stored on this page. If anything, at least you will learn to understand the basics of jQuery.

The article goes on to make it so that the reader fully understands how jQuery’s plugin structure works, and why. If I could find the author’s name, I’d mention it. Really good stuff.

Posted in UI | Leave a comment

KivaStream…

Finally, I’ve been working on this, off and on, for a little while now. I primarily made this to promote the awesome Kiva. Kiva helps a ton of people every day!

Here’s some thing wrap your mind around – In the past week alone, Kiva’s helped raise over 1.78 million dollars, for about 4,400 entrepreneurs. Kiva is the epitome of helping others help themselves.

It was built using the latest the GWT, and runs on Google’s AppEngine platform. It gets its images of borrowers, and related data via the open Kiva API.

KivaStream Loan-Picker

If ya get a chance, give my application a try. More importantly, give Kiva a try! Thanks.

Posted in Giving, GWT | Leave a comment

Colbert’s take on the Forever Lazy…

Am I missing something, or is this a ‘Onesie’ for useless people? This is genius…

Colbert quote:

Finally, a warm cozy way to renounce your ties to humanity!

The Colbert Report Mon – Thurs 11:30pm / 10:30c
Coma Cozy
www.colbertnation.com
Colbert Report Full Episodes Political Humor & Satire Blog Video Archive
Posted in Funny | Leave a comment

Using JSON for GWT

If you’re going to use JSON for a GWT application, truly, you should truly RTFM… JavaScript overlay types are to the rescue. Especially if your data source is on server remote to your module(s). I’d start here Coding Basics – JavaScript Overlay Types. At the bottom of “Coding Basics – JavaScript Overlay Types” are some links to videos, that are worth watching, but you can watch those later.

After reading that article, I’d head on over to Coding Basics – JavaScript Native Interface (JSNI). Coding Basics – JavaScript Native Interface (JSNI) will give you more than enough background on the connection between your JSON/Java communication. In this article, make sure you pay close attention to the section Sharing objects between Java source and JavaScript. This section is extremely helpful. For example, for your JSNI items, don’t use Java’s primitive long.

GWT purposely does not allow for SOP (Same Origin Policy), thus reducing the possibility of cross-site exploits. With that knowledge, next, I’d read Making cross-site requests. This third article will make it clear on how your GWT application can dynamically request and apply JSON data. Again, make sure you trust your data source before using this.

Lastly, as a bit of sanity check, I’d hit Design: Overlay Types. One thing you’ll notice about the JavaScriptObject examples, they don’t use primitive wrappers! This is not a mistake – if you try to use primitive wrappers, you will fail. Note, this last item, “”, was last updated in February of 2010. So, it will have some out of date items, but it will better prepare you.

Posted in GWT | Leave a comment

fame?

So, being famous consumes many of us, to some extent. Some, more deeply than others. Adrian Grenier (He plays Vince on HBO’s Entourage) has a documentary film, in which he follows a teenager who happens to be a member of the Paparazzi. At first, the young man is simply enamored by being a Paparazzo. He’s not really concerned with the consequences, or the impedance on the celebrities lives. that should not surprise you, as he was only 13. Over the course of the film, there are clear changes in both Grenier and the young man. Some good, some not so good. One of the no so good changes are in the young man, and his craving for fame.

Grenier interviews various people, stars, authors and researchers for the film. However, during the filming of the young man, he appears in front of the camera, a good deal. This draws attention. Attention, I don’t think Grenier originally intended for. This attention leads to interviews for the young man, and implicitly, “fame”. To the point that the young man is offered a reality show. In the end, all is made right. If you watch the film, you’ll see. That’s not my focus.

I’d like to focus on a new ideas, Parasocial Interpersonal Relationships (http://en.wikipedia.org/wiki/Parasocial_interaction). An author, in the film (who actually lead Grenier to see the errors of his ways) discussed to what extent people want to be acknowledged. He also stated that when living in small tribes, this was not an issue, since every one knew everyone. So, in other words, everyone was famous. However, now, with both the size of our societies (for the most part) and the technologies available (Facebook, Twitter, etc), many people feel “unimportant”.

In the film, Matt Damon, during an interview, spoke on how often people ask him how it feels to be famous. He thought it was odd. Odd that people saw fame as the thing itself… “What about the making movies?”, he rhetorically asked the camera. Another author, during an interview, reported something fairly similar. He spoke on a survey that was given to high school students. In this survey, the students were given a list of possible jobs, including CEO of fortune 500 firm, a Senator, an a handful of other powerful positions. One of the job on the list was the assistant to a star. To be clear, not a star, but the assistant to the star. 42% of the students choose the assistant job.

Both Damon and the survey result speak to the root problem. Understanding the difference between a means and an end. Fame itself, or even wanting it, is not an evil. Similar to financial wealth, having it for its own sake is folly. However, in the right hands, these are powerful tools. Tools that can used to create and provide greater things for your immediate (and extended) society. Things like schools, clean water, vaccines. Just as UNICEF’s Goodwill Ambassadors

Posted in Love of Sophia | Leave a comment

simple v better…

Assume you have a system in which a patient can schedule appointments with a given doctor. In this system, aside from being able to create an appointment, the both the doctor and the patient should be able to modify a created appointment. This includes time changes and cancellations. In the system, cancellations are seen as one-way deactivations. Anyway, here’s an example of a simple (working?) way, and a better way.

In the first try, I had appointments referring to an availability. An appointment can’t really exist otherwise. This easily satisfies the requirement that only one person is ever scheduled for a given time. During a cancellation, the appointment that referred to the availability is marked as deactivated. In the simple design, the appointment must loose its hold/reference to the availability.

Simple Way…

Unseen side affect – now, without having to dig through audit tables (we don’t want to have to do this), how can we now reference the availability that the appointment originally referenced? Holding the ID of the original appointment is a possibility, but not really enough. Making the relationship an aggregate and giving the appointment a Boolean marker for the “current appointment” sounded nice, but not enough. It’s possible that 2 or more appointments were made and canceled for the same availability.

At first, I thought of an association class between the availability and the appointment, but that was more than needed. I don’t need state on the association. All the required state, including audit info, such as last updated by and time, is already on the involved entities. Finally, I thought, “Add an numeric index”. This resolved a number of requirements, and allowed me to create a unique index on the relationship. Nothing a little caffeine and time couldn’t handle…

Better Way…

Posted in Technical stuff | Leave a comment

twig is awesome…

Brian M. introduced me to Twig about a week ago, and it’s awesome! I’m a long time Hibernate user. Over the years, like everyone else, I come to really appreciate the 80-90% that Hibernate does for you. Basically, the things an ORM should do. Anyway, when I got into this App-Engine world, my primary aversion was the Key-Value (NOSQL) ideas. Made me uneasy.

Thanks to Twig, that’s not as big a worry. Now you can still have direct Parent-Child mappings. At the same time, if I want, you can still use the lower-level Key mappings. Like with an ORM, I can have eager relationship loading, via the activation feature. For you truly ahead of the curve devs out there, Twig encourages creating truly asynchronous apps.

However, just like anything that makes your dev work easier, you need to use it with caution. With Twig, by default, when you load an entity, all of its relationships are eagerly loaded. Similar to Hibernate, I’d set this to a small, finite quantity. Possibly 1-3 levels deep. Also, by default, all fields are indexed. Again, don’t wait for QA or Production to configure this. I’d actually turn it off, and specify all non-Key fields that need indexing. As their documentation states, index items you know you’ll using for sort and searches.

There are other projects that can add and easier to use layer over the DataStore API. They’re definitely work a look. These include Objectify and SimpleDS, to name a few.

Posted in Google App Engine, GWT | 2 Comments

HTML Color Hex Shorthand…

OK, for you CSS wizards, and people who can generally read and comprehend things, this will be old news. For the rest of us, in the past years you must have seen color hex shorthand like this “#FED”. Until today, I’ve never really cared what that meant.

Some background… I’m a software developer, and I don’t work at Google or Apple. This means my UIs are usually bare bones. I’ll use some rounded corners and floating DIVs, but that’s about it. In the case where my business clients or partners request a fancier UI, I hire out as much as possible (logos, icons, etc). No matter, I’m always stuck doing the CSS (look and feel). I am not good at it. My UIs always look just like they would if a developer with access to rounded corners and a small graphics budget worked on it.

Anyway, I’ve been asked (told) to make the UI a little sharper. To the point, my color scheme choices have to many colors. My buttons look like I built the UI in 2000. Bottom line, I’m trying to do too much, as if to hide my novice. Funny thing is, the best UIs usually look like the designer did very little. Based on the items I’ve read and seen in the past 5 years, I should know that. I digress.

When you use shorthand for hexadecimal color, each character is repeated once. So, “#FED” gets translated into “#FFEEDD”. The full color code is 6 digits long, another representation of RGB (Red, Green and Blue). So the first two digits are the Red codes. The next two digits are the Green codes. The last two are the Blue. When three characters are given, the browser assumes the proper/full hex color code. See this W3c.org post for more details.

Posted in General, UI | Leave a comment

GWT wiring via Spring…

I have a more detailed post in the works, but until then, let’s just say using Spring to wire your GWT components is ridiculously easy. I ran into some issues, but thanks to a post from pgt, I was able to work through them.

In short, write your GWT-Dispatch (gwtd) and GWT-Presenter (gwtp) code (Actions, Results, ActionHandlers, etc) as you normally would. I prefer setter-based injection, so I make sure my dependencies all have public setters. Once your code is structurally ready, add Spring @Component annotation to the classes that will require DI. Next, add the @Autowire annotation to the to-be injected setters/fields. I kid you not, it’s that simple.

With that said, the real work is knowing what and how to define your Display interfaces. It’s more UI abstraction than I’m used to. Regardless, it’s worth it – really makes testing the UI easy.

Posted in GWT | 2 Comments