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

Tuesday, January 16, 2007

Run for the Roses

Grew up in Louisville, Kentucky. No, not Louie-ville. Lou-u-vul.

Haven't lived there since 1973. Yeah, I'm pretty old. At least you'll think that if you're under 30. If you're not, I'm in my prime, Baby! Fifty-three is where it's happenin', as far as I'm concerned. I make good money, healthy as hell, have a phenomenal Sweetie, and love life. Experience meets resources. Wow.

If you're under 30 and think it's all over when you're 50 - man, you're gonna be surprised. Life STARTS at middle age. Please don't get me wrong. Don't mean to sound full of myself. Its just that by my age, you've had a good while to amass resources - and you definitely know who you are. Including your failings. But you learn to accept them. I, for instance, know that I'm a hopeless introvert. If my Sweetie leaves my side for 10 minutes at a party, I'm sweatin'. I consistently say things that fall in the category of "did I say that, or just think it?". Not a good trait for a banking executive...

But I digress.

Having grown up in Lou-u-vul, the Kentucky Derby has a special place in my heart. So when I decided to create a thoroughbred racing simulation I knew the venue HAD to be Churchill Downs - Home of the Kentucky Derby.

The birth of "Run for the Roses".

Five years, and lots of learnings later, RFTR was released. Did I make a mint? Uh, no. Have I sold quite a few? Absolutely. I offer every buyer a 90 day money-back guarantee. I haven't had to refund the first dollar.

Is the program perfect? Hardly. But when people email me with an issue, I work diligently to resolve the issue. Apparently I've done a pretty good job at resolving issues. And at making RFTR better as time goes by.

Today, too often, software is released with an absolute expectation that a patch will be coming out in a few weeks - because the initial release is buggy as hell.

Whatever happended to putting out a quality product, fully disclosing any deficiencies, if necessary, and standing behind your work? Isn't that how to do business?

I just "upgraded" the software tool I use to manage my finances to the 2007 version, and I have had NOTHING but problems. I don't have the patience to tell you what a really LOUSY piece of work I've been subjected to - and from a major company. There doesn't seem to be any pride in authorship anymore...

But WE can change that - by writing better programs, and by demanding better quality.

Join me, please.

Sunday, January 14, 2007

How NOT to Build a Website (cont)

In November of 2006 my wife, Shirley, and I took a Mexican Riviera cruise. In anticipation of some much-needed downtime I ordered a book called Head Rush Ajax. Not sure why I bought that book except that I had heard of Ajax, and the book looked interesting in its format.

Well, I read that entire 400 page book during the 8 day cruise. And yes, there was plenty of time left over to make sure that my Sweetie was fully engaged and entertained during the cruise! I felt as though I really understood Ajax after reading that, but more importantly it made me start thinking more about both javascript and html.

When I got home I ordered Head First HTML with CSS & XHTML. If you’ve never read this series of books, you just have to do it. I have never learned as quickly as I did reading those books.

So anyhow, the Head First book on html made me realize how easy html and css is to use. I immediately restructured all of my websites using css. Now I can change the look and feel of an entire site by changing a few lines in the css document.

I do continue to use DW8 for updating and creating my sites, but it’s funny – now I use only the “code” window and never look at the “display” window! And I feel as though I have absolute and complete control of every aspect of my sites and pages. I can move anything anywhere on any page with a quick css update.

So the moral of the story is that if you have, or want to have, a website, learn html and css and do it the right way. You may wonder why I continue to use DW8 if I can write html in Notepad. DW8 still provides good value to me because it helps me see code errors as I make them, and makes it easy to ftp the updates to my live sites. I can make a change, click two buttons to review it, click two more buttons to upload it to the web servers.

That is how to build a website the RIGHT way.

Labels: , , , , ,

Friday, December 15, 2006

How NOT to Build a Website

At the time that I felt I needed my first website I knew basically nothing about html or css. And I was deep in the throes of learning VB6 so I wasn’t about to try to tackle html too.

But I needed a site, so I knew that I needed a tool that would give me WYSIWYG capability – and at low cost. I wasn’t (and still am not) much into spending loads of money on my “hobbies”. I found a little shareware tool for about $29 that did a few pretty cool things – and allowed me to throw a site up in a couple of weeks. It was very basic but at least I had a web presence!

So that sufficed for the next year or two. Then I needed more sophistication and decided to pop for Dreamweaver 8. DW brought a lot more functionality, but at a price – significantly more complexity. Not knowing html, I never even looked at the “code” window. I always worked in the “display” window. Still WYSIWYG dependent, you see.

After I got through the fairly steep learning curve, helped tremendously by a book called Dreamweaver 8: The Missing Manual I was pretty comfortable knocking out an update to my sites over the weekend.

But then a funny thing happened. Well, let’s save that one for the next post.


Technorati Profile

Labels: , , , , , ,

Monday, November 13, 2006

Your Very Own Web Domain

I've had a website for about 5 years now. I started out the old-fashioned (and really easy) way of putting up a generic page at Adelphia.net - my internet provider at the time.

And that was OK for awhile. But then I needed a place to sell my software. Plus I was tired of having email addresses like "stevekri271@adelphia.net". Oh, and I was also tired of having my internet provider change names or close shop, leaving me to create a new email address with the new provider and communicate my new address to all of my contacts.

Now my email address is simple, and it will never change.

So I saw an ad by "1 and 1.com".

In the interest of full disclosure I should say that I will make money (not much) if you go to 1and1.com and end up buying a package. I must also say that for 3 years now their service has been excellent - except for one 3 day stretch in October when the sites were down entirely. They discovered a major issue, fixed it so it won't happen again, and no problems since. They also provided financial compensation for my trouble.

Why own your own domain? It's easy, you get to pick your own domain name, have email addresses like "steve@novasine.com", and see all kinds of stats about how many people come to your site and what they look at there. Lot's of other great reasons, but it's early and I haven't had coffee yet...

I don't mean this to sound like a 1and1.com ad - there are many great hosting companies out there that provide similar services. I just want you to understand what you can get and do for next to nothing in monthly fees.

For as little as $4.99/mo you get:

2 free domain names of your choice
1,000 email accounts
100 GB of storage space
1,000 GB of monthly file transfers
Much, much more

To sign up for this package just go to 1and1.com.

By the way, I have the Developer's Package at 1and1.com. It's $19.95/mo but I get 5 free domains, database support and other developer tools, and tons of filespace and transfer volume.

The first thing you'll want to do is find a great domain name. They are harder and harder to come by. You can pretty much forget finding a common word or phrase available as a .com.
You may get it as a .net or one of the other "top level domains". Those include .org, .us, .info, .name and others.

A recent phenomenon is to use a .us and make a word that ends in .us - such as del.icio.us. I imagine these are getting hard to come by now as well.

So anyhoo, find a good domain name. It should be easy to spell, as short as possible, no hyphens - and you really want a .com if you can get it. They are where everyone starts their search on the web - they're the best.

I currently own 24 domains. Most are .com, some are .net, and I just bought 2 .mobi's that focus on mobile devices, like cellphones and PDA's. I expect to be doing a lot of mobile device programming in the future and want to be ready to market to those users.

The way to determine if a domain name is available is to go to Whois.com and enter your proposed domain name and domain (.com, .net, etc) in the box where it says "Easy domain search".

Also, have you ever wondered who owned a certain domain? Search for the domain as described above. At the bottom of the response page you'll see a link to "Whois Lookup". Click on that to get name, address and other information about the domain owner. This is sometimes helpful if you are concerned about a website being fraudulent.

And if you want to hide your personal information for your own domain you can have your hosting company (at least you can at 1and1) act as your agent, as I do for most of my domains. It shows their name and contact information in the lookup, not mine. The only charge for this, as I recall, is that I have to pay a small fee for any mail that they receive for me and forward to me. Which has never happened.

So once you own your very own domain you need a website to put up on it.

Stay tuned for my struggles over the years as I tried to use website-building software, like Dreamweaver, rather than just learning how to write html and use CSS style sheets.

Man, what a difference!

Labels: , , , , ,

Tuesday, October 3, 2006

Intellectual Property

Protect your creations.

Several months into my work on Run for the Roses I decided that I had better figure out how to copyright or register my work. I wasn't so much concerned about someone stealing my work itself, as I was worried that someone else would write a piece of software using the same name, register it, and then I couldn't use that name for my project.

Now, as luck would have it, when I wrote that first little program back in 1982, I believe it was, I decided to register it with the U.S. Copyright office. So I knew the name was protected as the name of a computer software program. I just updated that registration.

You may be asking how important it is to do this.

As I understand the law, you are not required to formally register or copyright a piece of work. By the simple act of creation, it is protected. But by publishing it in some fashion, and indicating that it is protected, you may head off those who would otherwise seek claim to your work.

This is right from the Copyright Office's website: "No publication or registration or other action in the Copyright Office is required to secure copyright... Copyright is secured automatically when the work is created, and a work is “created” when it is fixed in a copy or phonorecord for the first time. “Copies” are material objects from which a work can be read or visually perceived either directly or with the aid of a machine or device, such as books, manuscripts, sheet music, film, videotape, or microfilm."

Until a few years ago a work had to be published to be automatically protected. And published meant:
" 'Publication' is the distribution of copies or phonorecords of a work to the public by sale or other transfer of ownership, or by rental, lease, or lending. The offering to distribute copies or phonorecords to a group of persons for purposes of further distribution, public performance, or public display constitutes publication. A public performance or display of a work does not of itself constitute publication."

But now you can easily communicate your ownership to others through the use of a simple phrase:

"Copyright 2006 - All Rights Reserved"

The easiest way to "publicize" this for me was to put it on my website and use that line at the bottom of each page. We'll talk later about how easy it is to set up your own website.

So why did I go to the trouble of registering my work? I suppose mostly because if there was ever a dispute, I could pull out my little registrar's certification and say "see, its MINE!". Doesn't mean someone won't sue you; but you'll be better positioned - plus you may thwart (first time I ever used that word) any number of possible litigants (that word too).

OK - so how do you go about registering your work?

It's really very simple. First, go to the U.S. Copyright website where you'll see a section called How to Register a Work. Look under Literary Works. You can read up on the process there, but basically you'll use the Short Form TX for most registrations. The cost is $45 and it is NOT a fast process. I have waited 9 months for a registration to be completed for a work.

But the folks there are really nice, if you ever need to talk to them (rare). Particularly a guy named Joe. He told me last year that they got something like 14,000 registrations each DAY!

Anyhoo, print out Short Form TX, fill it out, print out your code (I believe the requirement is either all the pages, or the first 50 and last 50 pages), write a check for $45, send it in - and wait.

By the way, if you are registering graphics, you'll need to send in the graphics on a CD or DVD (or a print of them if there are few), and if you're registering sounds of any sort you'll also need to send in a CD/DVD. With Run for the Roses I sent in all of that.

You'll finally get a certificate back signed by Joe or one of his colleagues that certifies that your work is Officially Registered!




Labels: , , , ,

Wednesday, August 2, 2006

Eye Candy

Let’s admit it – graphics make or break any simulation or game program. So that means you have to get at least pretty good at creating them. As I’ve mentioned before, I don’t go out and buy the best tools available – I’m just a guy sitting on the sofa creating stuff. A few years ago Paint Shop Pro was a nice little shareware program that you could get for about $40. You can go spend about $500 for the world-renowned Photoshop – but I like being married, as I may have mentioned.

So PSP it was. A few years later PSP went bigtime and started selling boxed product for $99. I’ve paid that price more than once for the latest upgrade – I like this software that well.

Oh, and JASC - creators of PSP - were bought by Corel a while back. You can buy PSP X (there's a version XI now) here for $69 the last time I checked. Its worth 3 times that price. By the way, I don't get a nickel for saying that.

Like any tool, it takes time to get good with it. I bought a few books (surprise) along the way, and I literally feel that I can do anything that I want to do with PSP.

As I mentioned earlier, I chose the simplicity of a scrolling 2D environment for my project. I must admit that I was, and am, a little intimidated by learning 3D graphics. I’ll tackle it one day, but not just yet.

I learned early on that blending my horse images into a background that varied in hues and tones was a big challenge. You see, graphics can only have smooth-looking edges when they blend into the colors behind them. This is how “anti-aliasing” works. So if you have, for instance, a graphic with a black edge, and it’s on a white background, the only way it can have a smooth edge is if the black edge blends into the white background. And the only way that can happen is if the edge of the graphic “blends” by having a set of edge pixels that are dark gray, then another set that are a middle gray, and another set that are a light gray. Then it looks very smooth.

But what happens if you put that black graphic on a brown background? No really – what happens?

OK, you have 3 rings of dark/medium/light gray pixels around the black graphic – on top of brown. Doesn’t look smooth at all – in fact it stands out terribly. It took me quite a while to figure this out and solve for it – by doing my blending with a background color that was similar to the background in the simulation. Thought I’d pass that tidbit on to you so you don’t struggle as much as I did.

By the way, to be as realistic as possible, I actually visited a world-renowned race track that’ll remain nameless, and took dozens of photos that I later used in the background of my simulation.

I ended up creating 300 different horses, 15 jockeys, and 3 layers of 2D scrolling in the background. The end result wasn’t 3D, but it was darn good – and all done with a $40 graphics tool.

Next we’ll talk about how to protect your intellectual property.

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