Design, design, design…

May 1, 2013

I’ve done a lot of work (un-synced in GitHub) that “works,” but I’m not happy with it. I’ve been able to analyze box scores for a since team then run queries on that data to compile numbers exactly as displayed in ESPN… but I don’t like it. The design simply seems messy.

So, before I do yet another back-end re-design, I’m going to flesh out the UI design a bit. I think knowing what I want out of the UI will help a lot in knowing what endpoints (REST services) I need to write both for creating/updating data and (later) retrieving data.

As such, playing with CSS and some libraries has begun. With CSS, I’m always reminded of this GIF:


Learning Hibernate & JPA

April 21, 2013

This is somewhat of a discovery project. JPA and Hibernate are a very different way of interfacing with data storage and I’m having to learn a lot and reconcile what I knew in order to do things in the “best way.” I am probably still not doing things in the best fashion, but I’m trying to.

An example would be what to do when, say, a league’s schedule changes drastically. A matchup is really given by the week, and the key of that week is really the start/end date. What if the league manager decides to suddenly have 2-week matchups? Those new weeks will be completely different, so we really need to purge the old and insert the new. Figuring out how to do this properly with JPA and Hibernate wasn’t trivial.

This commit is really where I figured it out… where I begin to stop worrying about the database and start worrying about my domain objects. I don’t have to delete manually via HQL; that would potentially leave the session in a pretty rough state. No, I should manipulate the objects and what they reference instead and let Hibernate sort out the details.

Another epiphany was when dealing with foreign keys. Inside the domain object, I was sticking the parent ID itself in there. To get Hibernate to do that automatically, I had to finagle it a bit with making the column nullable, adding a @JoinColumn annotation to the parent, etc. It just felt hackish to me. Then, after some Googling, I figured out that Hibernate will deal with it if you put the parent object inside the child. It will automatically insert into a foreign key column in the child table. Nice! Of course, you have to make sure Jackson doesn’t choke on the circular reference, but Jackson is easy to deal with.

It’s funny. The commit involved for that particular epiphant is pretty minimal, but took hours to figure out the right combination of annotations. Often with programming, volume is irrelevant. I recall once in an interview at a career fair many years ago, someone asked me how many lines of code I can write per day… as if it mattered. Looking back on that, I realize that person is probably a terrible project leader/manager and I’m glad they didn’t want to hire me. I believe they owned the company that owns the program FlashFXP… perhaps OpenSight Software? Well, it seems all they have is still FlashFXP. Unsurprising.

Anyway, I’m learning, slowly but surely. As I learn, this project continues to come together. I still can’t believe I have momentum on all of this; I usually get disinterested by now.


Yo dawg…

April 18, 2013

Watching my fantasy players play while coding a program to better analyze my fantasy players.

Screenshot!