Tuesday, April 11, 2006

Data, Data, and more Data

I decided pretty early on that I wanted a dynamic racing form. Now if you don’t know what a racing form is – it’s the bible (no sacrilege intended) of every horse race handicapper. The racing form tells you, for each horse running that day, what his recent history is race-by-race. I mean it tells you stuff like how far he was back from the leader at the 3 furlong pole (a furlong = 1/8 mile), what gate he started out of, what the winning time of that race was, how fast he was in his last 3 practices. And much, much more.

I wanted that!

So my simulation had to capture all that information in real time (now do you see why I needed more speed in my graphics engine?). By the way, programmers call lots of things “engines”. When they say engine all they really mean is a function, or more rather a set of functions, that perform a given task. So I could say that I wrote a “racing form engine”, or a race horse “behaviors engine”. Just means I wrote some code that does that. You have to admit that “engine” sounds pretty cool though, huh?

OK. Now I need to really understand databases. After a lot of reading and , yes, trial & error, I realized that by far the easiest way to implement a database is to use MS Access to create the database, and then connect to it with VB6 using what is referred to as Jet 3.57 or whatever the current version is. It’s integrated right in the VB6 IDE. Really wish I could tell you what an IDE is, but the best I can come up with right now is “something Development Environment”. Maybe “Integrated”, now that I think about it…

Anyhoo, what an IDE is, is a tool that helps you write code. The VB6 IDE knows the VB6 language and provides TONS of help in programming. You can actually write Visual Basic code in Notepad if you want. It’s just like writing HTML – you don’t need Dreamweaver to write HTML or CSS, but BOY is it easier with it.

I’m easily distracted, as you can see. But I hope there’s some value to you in my little forays into the netherworld.

A lot of people hear “database” and think “omigosh – forget it”. But I’m here to tell you- this stuff is EASY. Don’t be intimidated! Creating a database in Access is a cakewalk. It’s very WSIWYG. Create a new database and name it something that is concise – your table names will be more descriptive. Then add a table to collect your data. For my project I named the dbase- that’s slang for database {:<) - “rftr.mdb”. Those are the initials of my project. My primary table was named tblHistory. The “tbl” part tells me it’s a table, and the “History” part tells me what it will contain.

Then I added fields such as horseName, jockeyName, raceLength, winningHorse, winningTime, etc.

You may notice that I use a certain pattern in naming things – there’s a name for this approach, but as usual I have no idea what that is. Basically you start with a lowercase descriptor of the object, and then capitalize each word that comes after that. You might have something called tblWinningHorsesName. I have found, through years of use, that this approach is the easiest for me to read and understand. In programming you will be creating hundreds or thousands of objects. It makes life a lot simpler in a large program to start each object’s name with a description of what it is (ie, “tbl”) and then use this means of differentiating words within the name. By the way, you typically can’t use spaces and a number of other characters in your names. Some people use underscores, but it’s just too hard for me to type “tbl_winning_horses_name”.

Once all the fields are set up, which includes defining what kind of data they will hold, such as text, numbers, dates, etc., then you’re ready to go into VB6 and have your code talk to the database tables and fields you just created.

Really, it’s just collecting data and retrieving data. Access and Jet are the easiest way unless you’re dealing with hundreds of thousands of records, or you have dozens of users that will all be accessing the same dbase concurrently – then Access sucks.

So a couple of months later I had a dbase and the racing form is working - SO COOL!

Labels: , , , , , , , , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home