Another Post on Automatic Getters and Setters

Recently I was looking at the Groovy section on DZone, and there was an article called Evil: Getters and Setters Where They’re Not Required (original here). He reiterates a lot of what I have been saying in my posts about why I am making the Groovy Validators.

I doubt that he and I are the only two that have noticed this issue. I have heard/read a lot of people complain about the verbosity of getters and setters (like we can get in Eclipse), and how much cleaner it is to use a language that will generate them for you (like Groovy and Ruby). Yet it is odd that so many times people gloss over the fact that these blind, automatic getters and setters essentially leave your variables wide open for just about anything. It seems like people hate verbosity more than they like data integrity.

Granted, I am a bit out of practice with Ruby, so it is possible that there is some sort of validation in the non-Rails Ruby space. And this is purely anecdotal. I just thought it was interesting.

UPDATE: I am making some progress on using the validation annotations with immutable objects. Hopefully Mr LaForge hasn’t closed that bug yet, and announcing my validators will bring me fame and fortune.

Image from “Biblia [Vetus et Novum Testamentum]”, an 11th century manuscript housed at the Bibliothèque nationale de France. Source / BnF; image assumed allowed under Fair Use.

Update on the Austin Groovy/Grails Community

The first is that there are plans for a Grails bootcamp. It might be an all-day event on a Saturday, it might be a two-hour event at a regular meetup. So far there are not too many details.

There are also plans to make an event planning and management app for Agile Austin. It will be called Project Growler. The announcement is here, and it is on GitHub here.

I suggested that this could be used to make a beginning Grails tutorial, like Michael Hartl’s Rails Tutorial. I think the Groovy community should shamelessly copy things that the Ruby community does. They built up a strong, thriving community. Plus, a lot of developers are looking for alternatives to the MRI since it does not handle concurrency too well. Some people are looking at Elixir, some are looking at JRuby. I think Groovy would be a good fit.

Image from Wikimedia, assumed allowed under Fair Use. Section of a fragment of 2nd century Greek manuscript of an unknown romance.

What To Do With Myself Partially Solved

Recently, I stated that I did not know what to do with myself in my free time, or what to work on WRT technology, since there is a lot to work on.

I started looking at Struts 2. It’s Java, it uses POJOs and claims to be thread-safe. I have heard that it is used where I work, and I may get hired full-time, and so I thought it would be a good idea to look into it.

But when I go to, I got a warning pop-up window saying: “Syntax Highlighter: Can’t find brush for: xml”. I really hate it when projects have bad documentation.

I mentioned this on the list. Someone responded that you can find good docs at Notice that it is not a doc for a numbered release. There might be a link to that directory of files, but I could not see it anywhere. Someone else pointed out that this is a bad practice, and the developer who first answered my post said that it would be fixed in the next release. “Soon.”

Whenever that is.

There is also a notice that they are starting to work on the next release of Struts, and it will break backwards compatibility. Perhaps I should just hold off on Struts 2 for the time being.

I noticed that there were a lot of plug-ins for IDEs for Struts 1, and a lot more tutorials online for Struts 1 than Struts2, even long after Struts 2 was released. In many ways Struts 2 looks better. Yet it did not get as much attention.

So I think for now I will look at Groovy and Grails in more detail. There are a couple of Groovy books that have become available for free online. One is the new edition of Venkat Subramaniam’s “Programming Groovy” (at this link), and the other is “Beginning Groovy, Grails and Griffon” (at this link). I need to get a better understanding of closures/lambdas, since I think they will have a big effect on Java 8. Everyone raves about them, but they mostly seem to be used for looping or iterating.

Image from an 15th century manuscript housed at Universitätsbibliothek in Basel (Wikipedia page here), image from e-Codices, assumed allowed under Fair Use.

What To Do With Myself

I am not clear what I should use my free time doing. Right now I am still going through the Struts 2 tutorials, and I am also upgrading a few web apps that I made a few years ago.

I tried to recompile an old app with Maven, and it took a long time because I had to track down the latest versions of all the dependencies. I am also struggling with testing it as well. I am having a hard time setting things up so that the tests hit a different database than the “production” app. I could just edit the hibernate.cfg.xml file in src/main/resources, but I would prefer to do things the “right” way.

I tried using src/test/resources/hibernate.cfg.xml, but that did not work. I know that editing the prod file is not quite correct, but I figure I could spend more time trying to work on that, or I could write some tests.

It is a bit frustrating that there are  a LOT of sample apps that do not have tests included, and also do not have test configurations as well.

I know some people say that tests should never touch the database, but personally I think that is kind of dumb. All this app does is change the database. I am not against mocking and stubbing, and if you are calling external services you need it. But I do not understand the stance that some fundamentalists take that your tests should NEVER touch the database. Changing databases is what a lot of applications do. If all you are doing is using mocks, then you are not testing your app. You are testing some artificial thing that is not really your app.

Image from an 11th century manuscript housed at Bibliotheken Schaffhausen (Wikipedia page here), image from e-Codices, assumed allowed under Fair Use.

Thoughts On Groovy and Grails

I have been going to the Austin Groovy and Grails group. It seems like Groovy is gaining some momentum. It was gaining some momentum, and then for a couple of years it lost some steam, but now it’s coming back.

I have heard some rumbles that Java shops have gone with Rails since they not find some Grails devs. I wonder if there is anything to these anecdotes. It seems like it would be cheaper for Java devs to learn Grails than Rails. If you go with Rails, not only do you have to learn a new language, but a whole new ecosystem.

I have also heard from a lot of people whose companies are using JRuby. These companies have a huge investment in Java code, and they do not want to throw that away, but they want a more dynamic, agile language that is more amenable to TDD. Which makes me wonder why they did not choose Grails. The reasons they go with JRuby is the whole reason Groovy and Grails were invented.

I have worked with JRuby, and frankly it is more trouble than it is worth. There was a presentation about it recently at Austin on Rails, and the speaker showed a slide with some JRuby code. He said, “This code looks odd to a Java developer. It also looks odd to a Ruby developer.” I thought to myself that is a good reason to not use JRuby. Outside of Ruboto, I think JRuby is a solution looking for a problem.

Another issue with JRuby is you lose the ability to use all the gems written in C. There goes a lot of the power of Ruby.

One reason people give for going to JRuby is that the JVM handles concurrency better than MRI. That is true, but for me that does not change the fact that Groovy is easier to work with on the JVM is than Ruby since that is the environment that it was built for. I just do not find JRuby as easy to work with as MRI Ruby or Groovy/Grails. The whole point of Ruby was to be easier for developers, and I think JRuby takes that away. If MRI has a weakness, then fix it, or just drop Ruby entirely. Don’t try to fit a square peg into a round hole just so you can still tell yourself you’re a Ruby developer. It’s just not worth it in my opinion.

I think that if Elixir can get off the ground, then a lot of Ruby developers will go with that. I am not an Erlang developer, so for all I know Elixir may be another square peg/round hole issue.


Image from an 11th century manuscript made at the Abbey Library of Saint Gall  (Wikipedia page here), image from e-Codices, assumed allowed under Fair Use.

2013-05-07 Update

I am pretty late, but here is an update.

I am still working on helping a local developer upgrade his Rails 2 app to Rails 3. I hit a wall. There is a lot of Javascript. I do not know too much Javascript. I asked someone for some help. We will see how things go.

I am kind of thinking about reviving RailsPress. A Rails user group had another thread complaining about WordPress. In addition, there was an article on Naked Capitalism that the site was having some issues with a WordPress host called WPEngine.  WPEngine is in the Capital Factory, an incubator in Austin that hosts the Austin Ruby and Austin Rails groups. If I get RailsPress up and running, I doubt I will be talking about it at the Capital Factory.

I am also looking at Groovy and Grails. I am porting a DNS server written in Java to Groovy. I got the tests written in Spock. I have not started porting the server itself yet. Getting the tests from JUnit to Spock took a while.

I am also looking at Java concurrency. I am going through Programming Concurrency on the JVM by Venkat Subramaniam. I don’t know if I will ever use some of this stuff (I might use GPars in my Groovy DNS port), but this has been a big hole in my Java knowledge that I think it’s time I should fill. I might post about the Callable interface.

Image from  Aurora Consurgens, a 15th century manuscript housed at Central Library of Zurich. Image from e-Codices. This image is assumed to be allowed under Fair Use.

2013-04-06 Update

Not too much happened this week.

I met with the dev whose app I am upgrading from Rails 2 to Rails 3. His app helps people transcribe documents/books/papers. He deals with people who have interesting collections. He is involved in a few projects that could be huge in the digital archiving space. I am pretty much done with all the Ruby stuff. Now I have to add some JQuery.

There was an Austin Groovy meeting. I think that there will be some interesting things happening in the Groovy space going forward.

I am involved with the SciRuby project. I might curtail that a bit and use Commons Math and Groovy to learn linear algebra for now. It would be good practice with Groovy, and I am more familiar with the JDK. I would like to encourage scientific computing in Ruby, but for now NMatrix requires some hand-compiled C libraries. Right now it does not work on Ruby 2. And someone wants to contribute a library that runs on JRuby. I like Java, I like Ruby, but I don’t like putting them together.

I have heard there are a lot of Java shops that are running JRuby to transition from Java to Ruby. If a Java shop wants to try out dynamic languages, I think they should look at Groovy.

Image from World Digital Library, assumed allowed under Fair Use. Image from the Ashburnham Pentateuch, or Tours Pentateuch, a Latin manuscript of the first five books of the Old Testament from the 6th century or 7th century. Its place of origin is unknown.

RailsPress is a beast

I am having second thoughts about RailsPress. WordPress is a bigger beast than I thought. Maybe it would seem easy if I were a PHP guy.

There are a lot of functions that call the “apply_filters” function. I spent some time last night looking for the “check_passwords” filter. But I don’t think that filter exists. Before the call to apply that filter, there is a call to the “check_password” method in the PasswordHash class. I did some logging (and calling the class from the command line) and they both seem to return the same value.

I think that whenever the “apply_filters” function is called, it gets called after some value has been found using the WordPress API, and the “apply_filters” method is an opportunity for other developers to provide alternative implementations.

I will go at it for a while longer before deciding whether or not to continue.


Image from a 10th-century manuscript housed at the Bamberg State Library (Wikipedia page here), manuscript description here, citation link here, image assumed allowed under Fair Use.


Update on RailsPress

I was working on a port to WordPress I called RailsPress. I had lost a bit of enthusiasm for it lately for a couple of reasons.

The main reason is the database migration script was hard to work with. I had to keep installing gems manually to get it to work. I did not want to write a migrator myself. But I think that it might be good to be able to migrate later versions of the WordPress schema, and do it easily.

I have been looking at Groovy and Grails. There is also a Grails plugin for reverse engineering a database. It is maintained by Burt Beckwith, who is something of a Grails celebrity. I think Grails and Groovy have a brighter future ahead of them, so I thought that might be the way to go. But I might put that off and make GrailsPress after RailsPress.

I found another reverse engineering gem for Rails called rails_reverse_db. I installed it with bundler, and I ran it with rake. I tried it a few times. The first time I ran it by itself, and it created the scaffolding by itself. I tried it again with RSpec and FactoryGirl. One of the migrations blew up on creating the factories. So I did it a third time with just RSpec, and it seemed to work. I will look into it a bit. I hope the guy who made this gem keeps maintaining it. The schema files the two gems produced were identical.

So I think this has some promise. I guess there is a lot happening in the WordPress space. Justin Tallant (who used to live in the apartment above me in Chicago and has the most popular German Shepherd in Logan Square) had a post on WordPress wanting to become a web application framework. I think about 10% of all web sites are running WordPress. I guess that’s not good enough for the WP developers. If they move away from being a great blog, the world will move away from WordPress. Perhaps RailsPress can step in if that happens.


Image from an 11th-century manuscript housed at the Bamberg State Library (Wikipedia page here), manuscript description here, citation link here, image assumed allowed under Fair Use.


2013-03-18 Update

I am a bit late with the weekly update.

Last week was kind of like the week before. I am still at the new job. I am still working on a couple of side projects.

One is helping a local dev upgrade his site from Rails 2 to Rails 3. I fix errors as they come up. I am also adding some tests. I have some for the models. I am starting to add some for the controllers. I was just running the controller test and I thought I finally got it working. Bypassing the authentication took a while. (He is using an obscure gem for authentication.) Then I finally ran the whole suite, and some of the model tests broke. So I had to do some refactoring. Some of it might not be up to the best standards. I am explicitly creating objects instead of doing it all with FactoryGirl. But as Voltaire said: Do not let the perfect be the enemy of the good.

I am also still working with Groovy a bit, rewriting a DNS server in Groovy. It has some JUnit tests. I might replace them with Spock tests. If I am going to do it in Groovy, I should probably do as much in Groovy as I can.

Image from an 11th-century manuscript housed at the Bamberg State Library (Wikipedia page here), manuscript description here, citation link here, image assumed allowed under Fair Use.