Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, February 26, 2009

My newest blog

I've let this blog stagnate for a while, mainly because I've been extremely busy working on the Atheist Experience blog a lot.

Now I've got a new blog which I would like to hype.  I just wrote my second post on Castles of Air, which is dedicated to issues focusing on software development.  This is intended to be my professional blog.  I want to keep it separate from the other two blogs, because I would like to be able to show it to professional colleagues without worrying about mixing in my feelings about politics or religion.

This will probably make me post here even less often, since programming and other nerdy stuff were topics that I used to discuss on Kazim's Korner.  However, since my professional blog has no followers yet, I will make a habit of putting a link from here to each post that I make on Castles of Air.  But don't rely I hope that will help to improve traffic flow of both this blog and CoA.  The other blog is of course a nerdy endeavor, but computers are everywhere in our lives, and even non-programmers might be interested in looking inside the process.

My first two posts:

Tuesday, January 13, 2009

Comedy of coding errors

Nerd alert. You will probably enjoy this post if and only if you are a fellow programmer.

There's a fair amount of horrible legacy code here at my new company. It is nobody's fault -- apparently it was written by an intern at another company, then bought by my company. Which is great, because I can loudly ridicule this code without fear of offending anyone. My cubicle-mate is the senior Java developer. Together, the two of us ARE the entire Java team right now; other people here are coding a little bit of Java, but we're the experts and the commerce project is owned exclusively by us.

I ran into a beautifully horrifying bit of code today. First it gathers a list of objects from a table. Then it iterates over each object, seeing whether the object is "authorized"... and then it removes the object from the array. Not only is this inefficient to begin with -- they should have just filtered out the unauthorized objects in the original query -- but they keep rearranging the entire array every time an object is removed. Like this:

1 2 3 4 5
(object 2 is unauthorized)
1 3 4 5

Obviously this runs in O(n^2) time, when it could easily run in O(n) time just by adding a second array.

Wait, it gets worse. I'm trying to fix it, and I realize the same code that kicks out unauthorized objects appears to be in there TWICE... it's iterating over the array twice and doing approximately the same thing each time. I don't know why, but it appears to have something to do with the magic number "50" that keeps showing up in the code. As in:

for (all items) {
if (curItem < 50) {
do one thing
}
}
for (all items) {
if (curItem > 50) {
do almost the same thing, but slightly different
}
}

Dear God, WHY? What does 50 mean? I don't know, the code doesn't give me a clue. You would think 50 is something arbitrary like the number of items displayed per page, but no... only 12 items are displayed per page. ARGH ARGH ARGH ARGH ARGH.

The bright side is that I don't think I've actually had to solve a genuine programming logic puzzle in like this for many months -- I can't remember a single example at DMi. This is fun! When I'm done, the code will run much faster. And there's probably hundreds of examples of this crummy design lurking around, waiting to be fixed.

Yay job security!

Saturday, June 14, 2008

Sudoku solver, new and improved

If anyone enjoyed the Sudoku program I made earlier, I should let you know that it's been updated.

In the latest version you can click on the game board and type numbers directly into the screen, instead of messing around with the text box. You can still copy the contents on the text box and save them for later retrieval.

Also, the box now displays periods instead of spaces for empty squares. This way, the correct amount of white space doesn't disappear when you type it in an HTML comment. For instance, in a previous comment, Tatarize was trying to get me to try this puzzle:

1.......5
....3....
..2.4....
.........
.34...7..
...2.6..1
2....5...
.7.....3.
.....1...

Go ahead and paste that in... it's long, but still quick at maximum speed.

Tuesday, June 03, 2008

Sudoku!

As I mentioned two weeks ago, I started playing around with a Sudoku solving program. So finally, here it is. Your browser must have Java enabled to view it.



Brief instructions:

To watch the program solve a puzzle, click "Solve." You can enter new puzzles by typing numbers in the text box and clicking "update." I recommend going to websudoku.com, copying a hard puzzle, and cheating to get a fast time.

Future updates include (if I don't get too lazy):
  • The program doesn't validate the initial state, so you can enter an obviously unsolveable puzzle and it will waste a fair amount of time trying to solve it. This is my top priority for a fix.
  • I'd like to be able to click directly on the image and be able to type in numbers there.
  • No guarantees, but you might be able to paste a websudoku.com URL and have it automatically load the puzzle from there.
  • Kevin, the director of engineering, discussed some methods to automatically generate new puzzles. I might give that a try. But it's a solver, not a game, so I might not.
Updates: Validates puzzles correctly. "Maximum" option set on speed bar. Move counter added.

Thursday, March 06, 2008

My new job

Okay, I admit it: I deliberately avoided posting that I lost my job. It's not that I wanted to hide anything, and I'm sure I would have gotten a lot of supportive comments. But I know there are also a small contingent of people (hello, Amway distributors?) who would have enjoyed the opportunity to make snide remarks. And since I was a little down about losing the job in the first place, I just didn't want to deal with it.

So I didn't post that I lost my job, but I'm definitely posting that I got a new one. This past Monday evening I found out that I've been hired to start next Monday. I won't identify the company -- not because I'm paranoid but because I don't know the company culture well and can't be sure if they'll approve of being blogged about. I'll just say that it's a medium sized company, much smaller and hopefully less bureaucratic than IBM. The company manages data about cars. Enormous database which keeps track of cars and parts being purchased from lots of dealerships, all of which has to get passed around quickly in real time. There's a lot of emphasis on efficient data management algorithms, and I believe my data mining education served me well in the interview process.

This job is a raise for me -- not as much of a raise as I was hoping for, but still pretty substantial. Unfortunately I'm not a salaried employee yet, but since it is contract-to-hire, if all goes well then I'll have a salary and benefits right around my birthday this September.

I will immodestly state that I did an outstanding job in the interviews overall, which consisted of a half-hour phone call followed by a four hour on-site interview. I met four people and they all liked me. The interview involved solving a lot of logical puzzles, such as "Tell me what kind of code you would write to match a certain number of buyers and sellers in a reasonable amount of time." I'm really good at those. However, in the end they expressed some reservations about how I lacked recent professional (non-school) experience with SQL databases.

It came down a choice between me and another person who had a stronger background. The feedback I got from my recruiter was "They really like you, they think you've got the best educational background of any candidate, and if they had two positions they'd hire you on the spot." I really wanted the job, so I pestered my recruiter to see if there was anything I could do to sway them further. She suggested something vague about studying more and telling them what I was learning.

I went one better. I said "Tell them I'll write a Java program that solves one of the interview questions and shows off my ability to use SQL." And I did, in two evenings, and also wrote a rudimentary design document for the thing. (Thank you, Suzanne Barber, for your Software Requirements class!)

Anyway, it worked. They still hired the other guy, but apparently they created a second contract position just so they could, in fact, bring us both in. If I hadn't decided to write that program, I might not have gotten it.

So as I said, I'm starting Monday. I'm excited and nervous, because I still have a lot to prove. But I'm glad that I only spent a week unemployed.

I've already emailed a bunch of people, but in case I missed any: Heartfelt thanks to everyone I wrote or called asking for job leads. A lot of the help I got was not just with new jobs, but also with meetings I attended that helped me get my confidence, morale, and presentation straight. Everything was a big help.

Besides which, last Friday I was treated to lunch at the County Line BBQ and got a really nice send-off. My team and I left on good terms. It was understood when I was getting my Master's that I was planning to look for more fruitful work after school, and I only lost my job at this point due to budget cuts within IBM.

And finally, having the week off is pretty nice. I'm doing the very Serious and Important Work of getting a second World o' Warcraft character to level 70.

Thursday, August 30, 2007

Beautiful sentiments about programming

Wrapped up in grad school as I am, it's easy to lose sight of the big picture, and why I got involved in this career path in the first place.

For my classes in Software Engineering and Management, I have to read The Mythical Man-Month by Frederick Brooks. I know the book by reputation; as it was first published in the 70's, I presume that the material is very old news to many people who share my interest in programming. Even so, this is new to me, so I wanted to share a passage from the book that I personally found very inspiring.

"The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures.

Yet the program construct, unlike the poet's words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sounds, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be.

Programming then is fun because it gratifies creative longings built deep within us and delights sensibilities we have in common with all men."

Oh yeah.