Dev-Picayune

picayune: of little value or importance

Adventures in Java Land

Yesterday and today I have started looking into Java again. Seems a majority of the developers (especially outside of the web guys) at my work are Java guys so it’s sort of expected of me to follow suit. I am not convinced but I thought I should give it a fair shot. Personally, I’d rather work in .NET (which I have been doing for the last few years off and on) or Mono (based on .NET) but still, I have to give Java a fair shot.

A possible project I have lined up at work is writing a utility that copies files from the store servers out to the registers (database updates, program updates, etc…). I’ve expanded the scope quite a bit to also handle major patch and version upgrades of the point of sale software. But it was nice thinking OO for a moment and realizing that I could start very small. I took out a piece of paper and scratched out a few ideas about a FileMover class. And here is where the old separate UI from business logic thing kicks you in the head… I knew that I would probably be using some sort of timer event on the window to nicely work within the system. That meant that my main working method for the FileMover class would be something like copyBlock or copyChunk where I move only a section of the data over. The class will have a status attribute and the initialization parameters will be the source and destination file names. But in a truly separated world where UI doesn’t matter, would I programmatically think to not just copy the whole dang file at once? Shoot, I could just have a static library of methods for doing simple stuff like copying a file. But knowing that some of the files could be as large a gigabyte or more, and knowing that I wanted a nicer interaction with the UI and the OS, it forced my hand on the lower level design.

Obviously, I could really muddy the waters by going threaded and that would take care of some of the external complexities. I could still move things in chunks internally but to the outside it would just look like a single method call. Then messages could be exchanged to report on the status of the copy back to the parent thread. But that’s major overkill in this environment and nothing to be gained except complexity and slower total copying.

Anyway… guess it’s time to move past the “hello world” program and start really using this stuff.

No comments yet. Be the first.

Leave a reply

For spam filtering purposes, please copy the number 6560 to the field below: