Research Log of Web Science Students

Computer Science is not simply programming

There’s no simple way to wire Twitter4j in the Spring Framework

with one comment

jeune.writingCodeException: 404 SEVERE REFACTORING FAIL 
                                      Jeune, you're a noob!

I have been attempting to wire Twitter4j in Spring for the past two days now. Although we’ve been successful at accessing Twitter data using Oauth already, I wasn’t satisfied at just making the code work. What we came up with was a “code duplication” monster and the only way to deal with this thing is through shotgun surgery.

I tried 6 sets of wirings for 2 code designs over 24 hours where I only ate twice (a small serving of pasta with pesto sauce). I was all over the SpringSource,  StackOverFlow and Twitter4j forums asking for help. Although some did come none weren’t enough to solve my problem.

What did I realize?

It’s time to move on.

At the end of day as researchers we will be judged on the features we’ve implemented and not on the refactorings we’ve done. I hope to keep that in mind.

My recommendations: Of course there’s way to wire this. I am thinking about extending AbstractController by an AbstractMethod, TwitterController and then put the relevant code in a protected method so I the controllers who need access to twitter can instantiate and initialize a Twitter class.

That would mean me reading chapter 3 of Spring in Action.

Hmmm I am already thinking about other the consequences of doing this. What if we’re going to access other social networks? Should I make a FacebookController too? I like that challenge, this is where OO design patterns come into play.

Anyway for my travails on trying to wire Twitter4j, here you go.


Written by Jose Asuncion

September 6, 2009 at 8:24 am

Posted in Hardwire

Tagged with ,

One Response

Subscribe to comments with RSS.

  1. […] Problems Solved. October 3, 2009 Jose Asuncion Leave a comment Go to comments For my problem with the GData Request Token, I returned a fresh instance of class GoogleDocs that implements the Provider interface (all made by me). Class GoogleDocs implements the GData specific code for authorizing with OAuth. I’ll do the same for my problem with Twitter4J. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: