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:

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.

I’ve committed my first code of the new design of it all. I’ve scribbled this design down in Notepad, but it should be pretty clear from the structure of the objects in com.schmal.domain.*. Additionally, I’ve tossed out a few drop-downs in the UI for giggles; they actually call the service methods via jQuery.ajax and are pretty snappy. Of course, I hardly have anything in my database.

Anyway, only the basic League information is done. I anticipate some struggles getting Hibernate to do what I want, so we’ll see how it goes.

Now that I’ve posted about my development project on Reddit, I feel I should have some sort of blog to keep anyone interested up-to-date. In general, I’m pretty awful at blogging as I lose interest very rapidly, but I feel like this project may have my attention and motivation for some time. I may be lazy about the blogging, but you can probably always check my GitHub to scope out code updates and whatnot.

Anyway, I’ll try to be good about posting updates and progress, along with snarky comments or venting about whatever library/tool I’m using that’s frustrating me (or ESPN’s frustrating web coding). For now, I’ll try to note progress via color coded words! Black means “shit, hardly even begun, if at all”, red means “started, but far away,” orange is “started, have some momentum”, and green is “working to some degree.” I have nothing above that, because this will probably never be fully completed. This will just track it to the point where there is some sort of deliverable that’s public.