Tuesday, May 18, 2010

GORM Criteria using child to parent relationship

I was surprised that I couldn’t find an example of this in any of the Grails and GORM docs or online examples.

I want to find the names and number of occurrences of the CHILD in a 1 to many association based on an attribute in the parent.

The domain classes are:

class Parent {
static hasMany = [children:Child]
String firstname
}

class Child {
static belongsTo = [parent:Parent]
String name

}

To find all the children and # of occurrences across ANY Parent where firstname is 'John':

def fName = 'John'
def children = Parent.withCriteria {
projections {
groupProperty 'name'
count 'id'
}
parent {
eq 'firstname', fName
}

}

Wednesday, March 10, 2010

March 2010 AWSome Meeting - Cloud Security

Last night’s AWSome Atlanta meeting was about Virtualization and Cloud Security topics. Taylor Banks presented about 50 slides on the different things to pay attention to, first in a virtualized environment, then in a Cloud. He correctly pointed out that all the issues with virtualization are also present in a Cloud environment, so make sure you get them right the first time.

Taylor was a good presenter, though I do wonder when he managed to get a breath in. He talked a lot, but he wasn’t rambling. He was noticeably excited and involved in the materials he was presenting.

Very early on he presented an new acronym that I think I’ll start using : K.I.S.S.M.Y.A.S.S

Meaning:
Keep It Simple, Stupid Make Your Architecture Simpler to Secure

Yes he mentioned it a few more times during the presentation.

He also said something very profound:
Cloud Security is often more of a process than technology
Yes securing the servers and services is important, but aren’t you already doing that in your self-hosted environments? So Cloud Security is about making decisions about what data you are sharing, how important the data is, what formats you are protecting it in and who can access it.

Taylor also took a few shots at the pundits around Cloud Security and did a pretty funny impression of a DBA. He had a comical routine about how giving two different DBAs identical SQL Server instances in a VM, but only telling one that it was a VM. You can guess what he was making fun of ;-)

The presentation is here.

Taylor’s twitter handle is @TaylorBanks.

Wednesday, February 10, 2010

AWSome Atlanta February 2010

Last night’s AWSome Atlanta meeting was one of the best attended that I can remember. The main topic was the Chef configuration management tool for computer infrastructures. The crowd was a mix of the ‘usual suspects’ and quite a few new faces.

During the usual introduction from John Willis we learned there were a number of consultants, end users and a few academics in the crowd. Probably half indicated they were starting to learn about Cloud Computing.

Josh Timberman @jtimberman from Opscode presented about Chef, the concepts behind it and ways to use it in your environment. His presentation was good, but it took a few minutes to get a ‘big picture’ view of what he talked about. However once you understood the goal was to standup a new server (or upgrade an existing server) consistently the materials made a lot of sense.

One of the more interesting things I learned about Chef is they are in beta of a SaaS version where they (Opscode) will host the Chef server which can then be reached via a client within EC2, Rackspace etc. or within your own environment. This is interesting because it removes the need to have a server hosted someplace other than the IaaS provider for the Chef cookbooks and recipes. (Thus no need for IT resources.)

The 30 second overview of Chef: you create recipes and cookbooks for the applications and configurations you need to standup a server. So you can create an “apache 2, Tomcat 6, JDK 6.10 MySoftware 2.00” recipe that knows how to install and configure an exact copy of the environment you want. And do it repeatedly without any intervention or manual steps. (The full explanation took an hour, so there is a lot more to it though.)

Very useful when you are in the cloud and spinning up new instances, but also useful in an internal environment when you need to bring up a new server due to hardware failure (or faster boxes!) or when you want to quickly deploy a new version of software.

Consider building a new Chef recipe for the next release of your software. You create a new server, validate against QA then just change the configuration that defines the production locations/databases etc. No manual check lists, no forgetting about a new service or cron job.

After Josh’s presentation we had about an hour of open discussion. Lots of topics, including EC2, where the cloud is going to impact business, my views on the return of the ISV and a short religious discussion on Ruby ;-) (Sorry Keith)

I hope the new folks got enough out of the session to keep coming back.

Opscode can be found here.

AWSome Atlanta can be found here.

Thursday, January 28, 2010

In my last post I commented that sometimes “drinking the Kool Aid” is a bad thing. Here’s an example that bit me for a couple of hours this week.

Groovy and Grails have done a lot to ‘make things work’ by expanding many of the core Java classes to remove the need for all the ‘work’ needed to get something to work. For example, database connections ‘just work’ and you don’t need tons of exception handling code or thinking about how to release them.

Groovy also makes interacting with existing Java code trivial.

However, the combination of the two leads to some problems. Consider my case. I wanted to upload a comma separated value (CSV) file in Grails, split the file apart and build objects from it. Pretty straight forward right? Done it many times in Java with Struts or GWT.

Searching for examples also showed a number of ways to do it. I took the ‘approved’ version from the Grails site.

Searching for ‘groovy csv’ also showed a lot of examples, including the use of CSVReader, which I’ve used before.

Putting the two examples together was trivial and took a few minutes to test and everything went perfect. Until I tried to upload the same file a second time to test the ‘update’ logic. I received an exception, because the file was locked on the host I couldn’t replace the ‘working’ copy.

Turns out that CSVReader is a Java class with very specific lifecycle steps that hadn’t been ‘groovy-fied’ yet. So while Groovy handled all the exception framework, collection logic etc, it didn’t know to close the CSVReader at the end. I added the explicit close() on CSVReader object and things work now.

I was (am?) trying to learn the Groovy paradigm, not just the language so I’m deliberately not writing ‘java in Groovy’. So I didn’t look at exceptions or lifecycle events since for a lot of other ‘common’ thinks Groovy just works. I’ll pay a little more attention to lifecycle from now on.

Tuesday, January 26, 2010

This is the first of hopefully several posts about my experiences and frustrations learning Groovy and Grails. I’ve been programming for over 20 years and have seen a lot of techniques, technologies and tools that claim to make a developer more productive. Many did make you more productive. Some did until you needed to modify the code a year later, or modify someone else’s code. So I’m pretty skeptical about all the claims from fan boys about any technology.

So with the hype around dynamic languages including Ruby and Groovy, I started looking into how useful they could be. For the record, when Bruce Tate talked about ruby at AJUG in August 2005 I was both skeptical and annoyed with what he was presenting. As a ‘fan boy’ he could see nothing wrong with Ruby or the impact it would have on a production system. In particular we got into a mini-debate about real costs of running a production server vs. benefits of Rails for faster development based on the runtime performance back then.

In November 2009, Pratik Patel did a Grails and Groovy presentation to AJUG, which was right after my NOSQL East presentation where I was asked why I don’t use Groovy instead of Java for my applications. Pratik’s presentation got me thinking more about Groovy and researching the differences and benefits from the Java world I’ve been working in for over 9 years now.

So, I’ve started my first Goovy/Grails project. I’ve been doing it part time for a couple of weeks and have some initial impressions.

Pros
  • GORM for ORM hides a lot of the data tier and is pretty straightforward, especially if you’ve ever fought with understanding Hibernate. Some of the bizarre things are still there, but for the most part it understandable
  • Auto creation of the UI and the scaffolding in Grails is impressive. After years of screwing up Struts and Tiles configurations and having no idea why, this is cool
  • Being able to call down to Java as needed. I have A LOT of helper code and business logic that I don’t want to rewrite
  • ‘duck typing’

Cons
  • GORM. It took me most of a week and a lot of trial and error to figure out how to return certain fields from a multiple table query in a reporting interface without dropping into HSQL. (Yes, I plan on writing a post about this soon)
  • Dynamic language support in tools. I use IntelliJ which is supposed to have the best Groovy/Grails support and it still sucks. I don’t want to wait until runtime to find out that I spelt a parameter name wrong. Or that a variable name is reserved word in Groovy (Category anyone?)
  • Real examples. The IBM series is pretty good, but I spent a lot of time banging my head on file uploads and GORM beyond the basics.
  • Are some of the ‘features’ really a step back? Naming parameters on method calls has been available since PL/1 (at least) and has always been a criticized as too verbose. It just 'feels' wrong to be using them

The biggest negative so far is drinking too much of the Kool Aid ;-) Grails/Groovy makes some things so simple that when you get outside what they’ve “groovy-fied” you need to think again like a Java programmer. I’ll give an example of this in my next post.

So far though I’m impressed with the language and the ease of doing things.

Monday, January 11, 2010

Video of my NoSQL East presentation

Here is the video from my NoSQL East presentation from last fall.

You can't hear the questions at the end so my answers sound strange ;-)

Thursday, November 19, 2009

Advice for a college Freshman

My post about what you'd teach a 15 year old reminded me of a blog post I have been meaning to write since September. One of the message boards I frequent, SVT Performance had a thread about advice for engineers. Initially it was targeted at women written by an ME, but turned into some good advice for anyone in college. Sorry I can’t deep link to the posting but it is in 'road side'.

I added a few comments, but I have thought more about it so here goes:

Here is my advice to a freshman today in a technical field.

Ask for help. Join study groups. Don’t be afraid of getting to know your peers. You may have been the smartest person in your high school, but there are going to be people better than you in some subject and you better than others in a different one. Get to know your peers so you can help each other. Figure out who are the good people that help others and who are just leaching from the group because they are in over their heads. The guy who kicks ass in Calculus and helps you may struggle in Fluid Dynamics or Data Algorithms were you shine.

Get an internship/co-op as soon as possible. Even as a freshman. Here is one of the last times that you can use your parents and family and not be accused of nepotism. Ask everyone you know if they know anyone in the field you are interested in. Talk to them about summer jobs or co-ops. Of course work through your school’s placement and co-op departments, but sometimes a friend of a friend knows about better positions.

In your internship, make sure the people you work with know who you are. They are going to expect you to ask lots of questions, not know much and even make mistakes. Don’t be the ‘kid’ that no one remembers because you sat in the corner. Here is a chance to introduce yourself to a lot of people in the industry you are interested in. Unlike the rest of the world, these are people you DO have something in common with, so don’t feel awkward about your intelligence or interests. I’ll bet they have felt the same way!

Get a Linked In profile. Yes, I know Facebook is cool (I have one too), but Linked In is where professional people keep track of their networks. It is very rare to hear of someone removing a professional contact in Linked In. Why? Because the network is valuable for years after you’ve stopped working with someone or at a specific job. Being able to search on ‘who works where I am interviewing’ is powerful, but so is asking (or someone asking about you) ‘this would be a great job for Jill, I wonder what she is up to’ AND being able to find them.

Now this doesn’t mean you ask everyone you meet in your internship to be a contact. Instead wait until a couple of weeks BEFORE your internship ends for the semester and ask the people you’ve worked best with for contacts. This isn’t Facebook so you don’t ask everyone.

As you get to know your peers, invite them to Linked In as well. Not the leaches, but the people who genuinely are good at what they do and are people you’d like work with some day. The reason here is the same as above: these are people who are going to be in your industry one day. They are going to be looking for jobs one day or might be able to help you. They may also have the solution to a problem you have (or vice versa). By maintaining the relationship you have at least one way to find them (or them find you) when the time comes.

Again, don’t add everyone in your class. Only add the people you think you’d want to work with. A plus to having a medium sized college network with a small to medium sized professional network is when the hiring manager looks at your profile, they see real professionals AND peers, which tells them a lot about you.

Finally, update your Linked In profile at the beginning and end of each semester at a minimum. As you get closer to graduation the profile and resume should reflect your internships instead of your classes. Update your status regularly about what you are working on. For example, having a status of ‘taking thermo 313 this quarter’ or ‘loved the lecture on np-completeness’ may get people in your network to think of you and reply. This again keeps you in their thoughts.

This isn’t one way. By regularly checking your network you can also see where you could offer help to a peer or a contact. You will be surprised by how many people post about job openings. You may not qualify (or be looking), but the guy that helped you with Calculus might be. By putting them together you help all three of you.

One more thing: don’t cross professional networks and Facebook. While it is tempting to friend someone from your internship, you are in college and you are allowed some stupid things, but don’t let non-friends find out!

Wednesday, November 18, 2009

What would you teach a 15 year old interested in technology?

At last night’s AJUG meeting Burr asked the group a couple of questions about technologies needed today to be hired directly onto a team. The question morphed a little into ‘what would you tell a 15 year old to learn’ if they wanted to be in technology. That question got things going in a different direction with a lot of good feedback.

This post is about my thoughts on this, since I have a 15 year old, although one that isn’t interested in being a programmer.

First would be to learn how to think. I know that sounds strange, but learn how to take data and ask questions or given a problem think about how to solve it. Even when I was in elementary school 30+ years ago, a lot of what we learned was how to apply the processes and algorithms we were taught to the examples/questions we were given. Not, given this poorly defined problem, figure out how to solve it with your full knowledge, not just what the teacher gave you yesterday. Think of it as the difference between geometry on calculating the angle on a graph and assembling a Lego house without instructions.

How do you teach someone to think? Unfortunately I don’t really know. With 3 kids I see that each of them learns differently and the processes I use to help each learn something is different. My only advice on learning how to think: has them questions that aren’t what the teacher taught them in the same area, or ask a different set of questions from what the homework asked. For example, Courtney is working on European history during the colonization times. The expected answer about why the Europeans wanted colonies (from the book) didn’t include the greed factor. And the arrogance factor. So I pushed her to think like the King or Queen during that time and see what you’d want. While she was able to give the 'book' answer, she is also learning to think in someone else shoes.

Back to technology. Thinking about technology, I think learning any language that is ‘backend’ focused isn’t a good place to start. Java, C, Groovy, Ruby, C++, Perl and non-UI languages won’t interest the kids. Instead pair them with something that shows immediate usefulness. So use Grails or Ruby on Rails or even GWT. Get them working on making something they can see and show off.


When I learned to program, most people didn’t interact with computers each day, so showing a green-screen output from the Fortran or C I was writing to my peers or parents was novel and unique. Today, everyone knows the web and a browser so showing them a text output isn’t going to get the response the programmer needs as encouragement to continue. Show someone a web page you built and I’ll bet most kids will get ‘wow, I wish I could do that’ as a response.

Once they have a basic language under their belts, look at the Platform as a Service cloud systems like Microsoft’s Azure, Google’s AppEngine or even Force.com. Why? Because I believe these platforms are going to be where a lot of the jobs are will be in the future. Whether it is a startup taking an idea that MAY require greater scale later, but not today, or the IT developer putting together applications for departments to address specific business problems, these platforms are going to make it easy to deploy solutions fast, instead of waiting on hardware purchases. Of course the whole ISV space is going to make a comeback because of these technologies.

Finally, encourage the kids to get out of the house and play. Build things like go-carts and bird houses. Learn to cook, even if using a recipe from a big cook book (Better is a hand written card from Grandma) Encourage them to take things apart to see how they work. The digital world makes this hard, but what about their bike, scooter or old rusted car sitting in the garage?

Monday, November 2, 2009

ControlTier Presentation At AWSome Atlanta

A co-worker of mine presented about how we are using ControlTier at AWSome Atlanta.

I missed the presentation due to a softball tournament for my daughter, but heard it was great. Watching/Listening to the video I have to agree!

AWSome Atlanta ControlTier Demo

Sunday, August 23, 2009

The return of the small business ISV?

I've been doing a lot of research and thinking about Clouds lately. I know, Clouds is an overused and abused term, but the more I thought about the business uses of a cloud and less about the technology, one thing kept sticking in my mind: the ISV is coming back.

For those around during the rise of the MIS/IT department, business groups used to get what they needed done using computers by hiring a one or few person shop to build software to their exact needed. Ask most 40+ year old developers (and Directors and VPs!) and you'll find that they cut their teeth writing custom code for everything from TRS-80's and HP-1000's to VisiCalc and dBase to sell to small businesses or to larger businesses that didn't have IT yet.

See, before MIS/IT put a clamp down on all non-'approved' applications, it wasn't unusual for a business person who 'knew a computer guy' to hire him (or her, even in those days!) to do exactly what they wanted. So a dBase application to run HR or the dentist office or to handle commissions. In the 80's and 90's I heard a lot of 'so Bob from my Church group did this for us'.

As MIS/IT took control, these small ISVs were starved out by bigger consulting agencies that the IT guys had relationships with (there is a lot more to the decline of the ISV, but I won't get into it today.). Today in most organizations it is impossible to get an application build and installed for a department without IT involvement.

The main reason departments don't do (much) outside work is they don't have any place to run it. With desktops locked down and networks monitored a department couldn't just install an application on a machine bought at Best Buy for their use. I'll talk about all the Access applications that sprung up because of this in a minute.

Now Software as a Service (SaaS) has started to whittle away at this reliance on IT since the apps aren't deployed locally and pretty much all IT sees is the HTTP traffic.

Yes, an department head could get a Rackspace account and run their own hardware, but that is really pushing the box even for someone likes sales (just kidding.) It would also mean they need OS help, which wasn't that easy to come by.

Things are changing though. Take a look at Microsoft's Azure or Google's AppEngine (or the dozen or more similar systems for PHP, Ruby, Java etc.). Here the applications are running inside a container. Containers with well define interfaces with tons of information on the web about how to access them. Containers without any OS access, so you don't need to know Windows, Linux, Tomcat, IIS etc.

Unlike SaaS which typically requires a contract that involves the legal department, Azure and AppEngine can be paid for with a credit card. It wouldn't be a stretch that soon business people are going to 'know a computer guy' who can build apps in these containers. For very little money. Like the kind of money a department manager or director has signing authority over.

Remember those Access databases I talked about a minute ago? Well most of them came out because the business people used Access in school or their interns did and Access is a typical part of Office. So tons of simple (and eventually not-so simple) applications are built with Access, under IT's nose.

What do you think the interns are learning in school now? Not Access so much, but Big Table in AppEngine or SQL Server in Azure. Soon those 'hidden' applications are going to be deployed in the cloud instead of local machines.

So why do I think the small business ISV is coming back? How many business users have problems that could be solved by a small application. One that they'd pay $2000 or $3000 for? How many would be able to hide that amount from IT and the CFO?

Who do you think she'd get for $3000 to build a basic app? Not the big consulting companies, probably not even the local ones IT uses. It will be back to individual developers who will do it at night and over the weekend.

That guy you know from Church.