Week 3, Wednesday

April 8, 2009 at 7:36 pm (Java, Ruby, Week 3) (, , , , )

My apologies for missing yesterday to anyone reading on a daily basis, but I ended up staying home from work and sleeping most of the day on Tuesday. I did get some reading done, but my programming work yesterday was negligible.

Today, however, my illness seems to be receding, and there’s quite a bit to write about. I spent a couple of hours on Java and Tic-Tac-Toe this morning, mostly re-organizing my packages in a way that (I think) better satisfies the package principles in Uncle Bob’s Agile Software Development, Principles, Patterns, and Practices. It took me longer than it should have to get an Ant task back to running the main program – ever since I created the initial packages, that task had been broken (failing with a NoClassDefFound error). I probably spent close to an hour trying to get the classpath where I thought I needed it, but eventually was able to make it work by scoping my “main” class (TicTacToe) down as my package structure was laid out: trptcolin.main.TicTacToe. Now, something tells me this is a hacky way to do it and that I should be able to just specify the classpath and the class name, so I’d be happy to hear any confirmation or denial of that sentiment!

Originally, I had the interfaces and abstract classes for my players, views, and controllers in the same packages as their implementations and subclasses, but then I started to think that because the implementations are likely to change, I wouldn’t want to require each package containing an implementation to ALSO contain a duplicate of the interface. It seems better to have the interfaces pulled up with the main application code, at least at the moment. So I did that, and along the way did some work to ensure that Git saved the file history, which is starting to feel more unnecessary the more time I spend doing it. I think I may start letting IntelliJ do this kind of file-moving work (from package to package), and let Git go ahead and believe that the files have been deleted and created again.

I made my first (small) steps toward a 3-D Tic-Tac-Toe game: I pulled public methods from my Board class into an interface, which I can now implement in a BoardIn3D class the way I already have in my (newly named) BoardIn2D class. Luckily, I don’t have to render the board in 3-D; the display will just be 3 vertical slices of the board in console mode. I love the IDEA of rendering 3-D, but I’d have been scared to try it, especially since I can’t imagine a good user interface that would allow someone to get at the center cube. And speaking of cubes, I have some methods and variables I’m definitely going to need to rename now that 3-D is a possibility (“squares” isn’t going to work anymore).

Eric and I got some more stories done on our Rails project, and I’m enjoying the constant testing we’re doing. It’s a really disciplined approach, and I know the end result is going to be a great product (that’s pretty easy to maintain). He also got a ton of work cranked out yesterday, and I was able to get the bug fixed from Monday with one of our Apache conf files. Note to Passenger users: Passenger runs as the owner of environment.rb, so the log files (and directory) should be writable by that user. Now, ours were both root-owned, so I’m not sure why that didn’t work, but it led me down a path to change the ownership to the Apache process owner, and that finally got logging to work in a staging environment for our app (and subsequently showed me what was going awry with the Apache conf file).

Advertisements

2 Comments

  1. Markus Gärtner said,

    One of my colleagues raised the point of keeping the file history in our revision control system – perforce – while doing renaming refactorings as you described. He articulated that it is a backstep loosing the revision history of a file and one should take p4 integrate src dest with it and then perform the refactoring step in the IDE in order to not lose it.

    My view here is that having a tool to automate those refactoring steps for me is the bigger benefit than to have a proper file history in the revision control system. I never used that feature! I never needed to use it to check where a particular file today is coming from. What matters most is the fact that I know what my current version does and this one I can clearly express to my colleagues in proper unit tests – not in revision control histories, that noone ever reads.

    It’s a similar thing when arguing on breaking encapsulation in order to get a good unit test in place – i.e. making a private instance in a SIngleton protected, so you can use the substituted Singleton pattern. Yes, this step breaks your singleton encapsulation – but for good. You get a test in place, you get one step nearer to 100% code coverage and this has clearly a greater meaning to me than encapsulation of many classes that depend on this singleton. The trade-off is fine with me. A similar thing applies to the comfort of IDE based automatic, safe refactoring support and keeping the file history in your favourite revision control system.

    P.S.: I didn’t get your naming problem. While continuing to read your wonderful write-up of your experiences at 8th Light I assume you got it solved during the last two weeks.

    • trptcolin said,

      Markus-

      Yes, I’m coming to agree with you as I realize how much time I spent changing package names. I did this refactoring again this morning, and I just went with IntelliJ rather than trying to keep the revision history tidy – like you, I figure that it’s more important to save time and avoid errors than it is to make it easy to see every change in a file. It’s not like the files are gone from version control; they’re just harder to get to, and when nobody really goes through them as I’m imagining anyway, it smells a bit of something LIKE premature optimization.

      -Colin

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: