Search

What the Quote?

"Some people play the drums too much, then they start singing like they're drums. If you're gonna sing like something, it should be a violin, for God's sake."

Laura Tripcony

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."

Rich Cook

"That's gonna pop into my head in the middle of some meeting... I'll spray Gatorade all over the projector, and run to the restroom, hoping to not piss my chinos."

Tim Tripcony

« Java is not my friend | Main| HTTPUpgrade Upgraded »

Good point, Julian

Category show-n-tell thursday
As Julian mentioned, I didn't share how I ended up approaching web page retrieval in Java. Guess I was too busy ranting. Which violates my cardinal rule of programming: leave the emotion out of it. I was reminded again this morning (for other reasons entirely) of a discussion years ago about passion in the workplace... no, not that kind of passion, silly. I mean the tendency for programmers to get all worked up about what they're working on, with which I have historically struggled. As time passes, it becomes less of a problem - ironically, because I know it's a problem and consciously attempt to overcome it, whereas the areas that don't cause me as much trouble often get overlooked and end up causing more problems because I don't focus as much energy on combatting them.

Anyway, the point is that I stubbornly attempt to remain objective about the task at hand, whatever that may be at the time. Occasionally that is perceived as apathy: if I cared more, I'd be more melodramatic. Come to think of it, I've occasionally lost girlfriends for precisely the same reason. But in reality it's the opposite. The more I care about something, the more energy I expend trying to avoid melodrama, because losing objectivity results in blowing things out of proportion, creating problems that didn't exist to begin with, and distracting from the search for a creative solution to any real problems. So when I find myself ranting, it's because for some reason I lost objectivity. Which almost always means that I've settled for a solution that is less than ideal.

In that light, here's the agent in HTTPUpgrade that searches the upgrade site for available versions to present to the user:

import java.net.*;
import java.io.*;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
 public void NotesMain() {
 PrintWriter pw = null;
 try {
 Session session = getSession();
 AgentContext agentContext = session.getAgentContext();
 pw = getAgentOutput();
 pw.println("Content-type: text/html");
 pw.println("Cache-control: no-cache");
 Document docContext = agentContext.getDocumentContext();
 String strQuery = docContext.getItemValueString("QUERY_STRING");
 String strURL = strQuery.substring(strQuery.indexOf("=") + 1, strQuery.lastIndexOf("&"));
 URL urlVersionList = new URL(strURL);
 DataInputStream in = new DataInputStream(new BufferedInputStream(urlVersionList.openStream()));
 String inputLine;
 while ((inputLine = in.readLine()) != null) {
 pw.println(inputLine);
 }
 in.close();
 } catch(Exception e) {
 e.printStackTrace(pw);
 }
 }
 }

See? It works, but it just ain't elegant. I like Julian's better.


Comments

Gravatar Image1 - Free range code... allowed to chat casually to chickens.

Gravatar Image2 - That's a tough one. If you care about something, you care about it, that's all there is to it. You can do your darndest to try to suppress yourself, but you can't stop caring. And really, there are some things that only get fixed because of a good rant.

And I wasn't really bashing you for not putting the code out there, just a little friendly needling. Set the code free man, set it free. If it comes back to you, it's yours to keep. If it doesn't, it's an Internet worm.

- Julian