Sunday, January 21, 2007

The .Net Evolution

If you’re a programmer, or someone interested in programming, then you’ve no doubt been subjected to the battles over the years regarding which programming language is the “best”.

Years ago I started using Basic, so it was quite natural for me to select Visual Basic as my language of choice when I decided to get reacquainted with coding. There are strong opinions over which is better – Visual Basic or C++. C++ programmers love the control they have with their language and how fast their compiled code runs in relation to VB.

VB’ers, on the other hand, are all about getting their project completed and up & running quickly. VB allows a coder to create and implement a form (the “screen” the user interfaces with) very quickly, and with much less pain than is required with C++. And I do suspect that VB doesn’t execute quite as quickly code that is heavy on calculations. But many VB applications are not about speed – they’re about responding to the user’s input.

But then came along .Net. Microsoft created the .Net Framework which is a suite of tools that permit a coder to work in any of several different languages, such as VB.Net, C++.Net and C#.Net, and then essentially compiles all of these into a very similar, if not identical, machine code, the language that a computer really uses – 0’s and 1’s.

This obviously suggests that there is no longer a speed advantage using the C++ language. I’m sure there are plenty of readers who will want to dispute that point. I welcome all such comments. My intent with these writings is to help educate, and that includes me!

I don’t by any means want to start a war, but if it is a fact that VB.Net is now as fast, or nearly as fast, as C++.Net, then I’d be hard-pressed to suggest that anyone new to coding would select any language other than VB as their tool of choice.

I am often utterly amazed at how quickly I can take a vision in my mind and turn it into a functioning reality in an hour or two with VB.Net.

If you have a differing opinion, please share it with us.

So after my first project, Run for the Roses, was complete, and I had established a vision for my next project, I purchased the .Net suite of programming languages – Visual Studio 2003 to be specific. The first thing I realized was that this new version of VB was a fair amount different than VB6. Every time I need to create a variable array, for instance, I have to go peek at how to do that. And to let one class “see” another class you have to create another class to act as the conduit. That probably makes no sense to anyone who doesn’t program, but suffice it to say that Microsoft could have made my life a bit easier if they had made a few more tweaks to things that should be very simple…

On the flip side, I definitely like the IDE a lot better than that of VB6. The IDE is the Integrated Development Environment. That’s where you actually write your code. The IDE is a suite of tools that assists you in writing your code correctly, by showing you errors as you make them, by creating forms – the user interface- and all the other things you do to create an application.

Once you write some code, you then click a button to “compile” your code. This is when .Net takes your human language code and converts it to the language of the computer – 0’s and 1’s. This is also when the .exe file is created – the executable file. Once compiled, you click on the exe file to run your newly-created program.

I’ve written previously about all the books I’ve acquired and read through my technological journeys. I typically would run out and buy two or three 1200 – 1400 page behemoths to have on hand for those times when I hit a roadblock. You have to have two or three volumes because there is never one book that covers most of what you need. Some specialize in this, some in that.

But you know, what I find myself doing most often these days is checking the help that is integrated into the VB IDE, which is often cryptic and sometimes incomplete, and if I don’t get the answer I need there then I jump to Google and search for the answer there. Rather than start into one of my behemoths.

I’ll search for something like: “allintext: vb.net textbox text validate” and I’ll almost always get two or three ways to do what I wanted to do. By the way, if you use Google always start your search with “allintext:”. This will ensure that only links come up that include ALL of your search words on the linked page. This will greatly focus your search effort.

The moral of the story is that I have a bookshelf full of VB.Net books, but I solve 90+% of my issues with the built-in help or Google.

Next time, we’ll talk about deployment. And no, not to Iraq…

Labels: , , , ,

Monday, June 12, 2006

The Sound of Music

Somewhere along the way it struck me that a silent horseracing simulation wouldn’t be terribly, uh, immersive.

I knew nothing about sound files. So I read a few books.

Do you see a sorta common theme here? I read a lot of books. We all have our own means of learning. I’m very visual, I’m an introvert, and I have this innate sense that I can figure it out – with no one’s help. These are not good traits, by the way. I think I could get things done TWICE as quickly if I were a networker and had a smaller ego. But that’s not natural to me. So I take the hard road sometimes.

I strongly encourage you to get involved in local (or net) user groups and so forth. But rest assured that, God forbid, you’re like me – there is still hope. But you have to read a LOT of books. I finally bought two 6’ bookcases to hold my reference books (which go out of style very quickly).

I also don’t like to spend a lot of money, so I always look for decent shareware tools before I go buy the more expensive, feature-rich tools. I found a reasonably priced audio tool called Cool Edit 2000. It was about $70 as I recall, and MORE than covered my needs. That little company has since been bought out by Adobe and is sold under the name Adobe Audition. More expensive, and more features.

Recently Adobe released a tool in beta called Soundbooth that is a brand new application built in the spirit of Cool Edit. It provides the tools that video editors, designers, and others who do not specialize in audio can use. You can download Soundbooth here.

Anyhoo, with Cool Edit 2000, a $60 Radio Shack microphone and a little $15 mic stand, I created a vast number of sound files for my simulation. Certainly not award-winning stuff, but not bad either.

I had created a “you are there” experience.

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

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: , , , , , , , , , , , , , ,

Friday, March 3, 2006

Viewport Foibles

At that point in development I didn’t have much in the way of graphics. One set of graphics of a horse running – 9 different drawings, as I recall, that gave the impression of smooth animation. Like cartoons, right? But I thought I’d better get a handle on how I was going to get that animation into the viewport.

Maybe I should take a moment to talk about sprites. I learned how they work in 1983 or so when I wrote that little program on the ol’ TI-99/4A. A sprite is simply any graphic that you draw on the screen, then erase it (or re-draw the background over it), move it, and then re-draw it on the background. So it moves. Don’t know where the word “sprite” comes from, but that’s what it’s called. Now, if you want it to look a whole lot cooler you have to animate it – just like cartoonists do.

So you simply create a series of drawings on a transparent background that depict what the sprite is doing. So for my horse I created a small drawing of a horse in mid-stride, then I created another drawing with the horse’s front legs going further forward while the back legs are a little further back – and so on. With 9 “panels” the animation looked pretty convincing.

I’m not an artist, and I don’t think you need to be. If you can look at a picture and copy it in pencil, then you can scan it into a paint program and use the program’s tools to brush color over it. It’s pretty amazing how good it will look with not much effort.

At that stage the program loop wasn’t doing a whole lot of stuff. It checked to make sure the “horse” wasn’t running off the screen, it moved the background graphic sideways a couple of pixels, and checked on a number of other things, like who is in the lead, updating the elapsed time clock, etc.

But the horse animation was too jerky – and I didn’t have the program doing HALF the stuff I wanted it to do. Heck, I was only drawing one horse. I needed to draw 12! So I knew I had to find a faster way of getting the sprites on and off the screen. I started reading up on programming the Windows API (application programming interface). An API is a language that lets you write code that “talks” directly to the underlying technology. In this case that was Windows. I learned everything I needed to in order to draw the graphics directly on the Windows, er, window. By the way, I was using Windows 98 at the time.

Guess what? Still not fast enough… Still too jerky.

I had spent something like 2 months implementing the Windows API solution. Back to the drawing board. So I started reading about DirectX. DirectX8 had just come out but that seemed to be overkill for what I needed. DX8 was all about 3D graphics. I was working with scrolling 2D graphics. So I bought several books about DX7. After many weeks I figured out how to draw the graphics in DirectX7. But now I couldn’t get the viewport to be active at the same time that the dashboard was on screen.

I literally spent 3 or 4 months figuring out that problem. I wrote to I-don’t-know how many forums, read everything I could get my hands on, tried everything I could think of. I can’t tell you how now (I think I’ve blocked it from memory) but I figured out the solution – and it was FAST ENOUGH to provide me smooth horses!

That was, I’d say, the toughest challenge I overcame in my journey to completion. But there were many more to come…

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

Monday, February 6, 2006

The Journey Begins

So where do you begin when you know very little about how to do what you want to do? As a wise man, Wayne Walter, once said to me, "Steve, how do you eat an elephant? One step at a time". Not profound, but I remember that saying often, so for me its meaningful.

I imagine really smart people would start this journey by documenting a complete plan with milestones, target dates - the whole nine yards. So I'm not that smart. And as I mentioned before, I'm a little scattered in my thinking and not terribly disciplined - I work hard, but get off my intended path and onto others frequently.

So no project plan for me. No, I decided the first thing I needed to do was to build the user interface for my simulation - and there would be several interfaces.

I guess I should mention that what I was creating was a racehorse simulation - a "day at the track" as it were.

I knew I needed a viewport to see the action. A dashboard to show details of who was in the lead, the horse's odds - that sort of thing. Oh, and that would need to be on the screen at the same time as the viewport of course.

Also needed a window to place bets, another to show the payouts post-race. And the biggy - a fully integrated racing form. And I decided early on that some static facsimile wouldn't be sufficient. No, I wanted the races that you watched run, with the actual results, to be logged in a database and displayed in the racing form the next time you play the game. Boy, THAT was a big bite of that elephant...

As you can see, quite an undertaking for a guy that had spent about 50 hours to date learning the programming language and had no idea how to do any of that except make a simple form in VB6, and write a little code.

Somewhere along the way I read that over 90% of all amateur developers never finish a program. I told myself I wasn't going to fall into that category. In fact I was going to not only complete this project - but actually sell at least one.

So there I was with all those grandiose ideas and not much of a clue about how I would get there.

As I may have mentioned, I am somewhat creative, and have a real passion for creating things - whether its computer code, graphics, music - whatever. Not great at any of it, but really love doing it.

So I naturally tend to start my projects with the user interface. Now I'd guess that the real pro's are just the opposite. They probably start by creating programmatical objects (we'll get to that more later) and the infrastructure of the application itself - the part you never see - and then build the interface around that. Me, I like to start with what the user will see and then build the code around that. Right, wrong - I dunno.

I also think I mentioned that I have a career that is pretty demanding and that is critically important to me - it supports my family and promises a reasonably secure future. So this programming stuff has to take back seat to that. What that means is that I work hard all week, and then I work hard all weekend - but doing what I'm passionate about. So its not really work.

The sense of accomplishment I get when I figure out something, or complete a component, is just amazing. And provides me more energy and drive to do more.

So anyhoo, I started drawing out the dashboard portion of the user interface. Pretty easy to do with VB6 - in fact, amazingly easy, once you figure out a couple of basics. Pretty much a trial & error process (like all this stuff). Do it, run it, tweak it, run it, etc. Eventually you say - "that looks pretty good". Not that you're not going to change it 27 more times along the way, you understand...

But wait a sec - you may be interested to know where I got VB6. The Microsoft website? Not hardly. No, I buy most of my development tools on eBay. Can't find it cheaper anywhere else, at least not legally. And as a software developer I feel pretty strongly about software piracy.

After getting the dashboard pretty much where I wanted it I decided the next thing I should tackle is the viewport. It was critical to have the graphics of the horse race running on the same screen as the dashboard.

Should be pretty simple, huh? Well, that little piece took months to figure out. More on that next time.

Gotta get to work for now.

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

Saturday, September 10, 2005

Renaissance Man

I have a story to tell.

If you are interested in technologies, you WILL be interested in this. If you are not - don't bother to read further. Only Geeks need apply.

In this age of specialists, particularly in the worlds of technology and innovation, the Renaissance Man (or Woman) seems to have fallen by the wayside. Technology people seem to be website designers, or graphics artists, or audio technicians, or programmers, or hardware experts. But few are all of those.

I'm one.

This isn't a story of a "smart guy". When it comes to intelligence I am average at best. Lousy memory, scattered thinking, easily distracted.

So why aren't there more people who succeed as generalists in technologies? Because they don't try.

Why don't they try? Lack of confidence? Or perseverance? Opportunity?

I'm here to tell you how you can learn and apply any of these skills if you only want to. I hope you enjoy the journey.

I won't post often, but I hope to give you what I didn't have (or didn't seek) - someone to lead the way to success. I'll do it by telling you and showing you some of the thorniest learnings I've made over the past few years - and hopefully to show you the easier path.

And why? Because we need more Renaissance People, more polymathes. Are you one?

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

So who am I?

Average Joe. You can call me Steve.

As of this writing I'm 51 years old and live in Southern California. Not from here, but like it here.

I am wondrously married to the Love of My Life. Her name is Shirley - I call her Shirl.

My day job is as an executive for one of the country's largest banking organizations. Something I've done for over 30 years now. I've never worked in any field of technology, but I've been a Geek since I saw my first Pong game, circa 1968.

I am self-taught in the following disciplines:

.Net application development - excellent (please forgive the lack of humility)
Database design - very good
Graphics art - good
Audio design - fair
Website design - good

During the past 6 years I have learned, or honed my skills in, technologies that were needed to develop and sell a software sports simulation. After meeting that first, very important hurdle (completing & selling something that I wrote), I knew that I could do more; better.

Today I am in development of a software tool that teaches anyone to excel at one of today's most entertaining and popular games. Release date scheduled for early 2007. VERY exciting!

If you have ever wished to create, test and market a product that you designed from the ground up, I hope to help guide you on this path we now travel together.

I hope you enjoy the ride.


Copyright 2005-2007 S. E. Krieger - All Rights Reserved

Labels: , , , , , , ,