Unknown's avatar

About Greg Moore

Founder and owner of Green Mountain Software, a consulting firm based in the Capital District of New York focusing on SQL Server. Formerly, a consulting DBA ("and other duties as assigned") by day, and sometimes night, and caver by night (and sometimes day). Now, a PA student working to add PA-C after my name so I can work as a Physician Assistant. When I'm not in front of a computer or with my family I'm often out hiking, biking, caving or teaching cave rescue skills.

QuiCR

I’ve been toying with an idea for a few months.  Ok.  I’ve been working on actively making it come to fruition.  Now I can announce the idea I’ve been working on: QuiCR.

With QuiCR, companies of all sizes will be able to get instant feedback and responses from their customers. There’s 84 million cell phone users out there, and via QuiCR, companies can leverage them and turn them into instant secret shoppers, or get their feedback, or have them report on maintenance issues that might otherwise go unnoticed.

Check it out out.  We’re still very early in the process, but I’m excited.

 

Deep Survival

I’m currently reading a book called “Deep Survival”.  It was recommend to me by a buddy from the NCRC.  For years I’ve been interested in disasters and accidents.  Not so much the gruesome details that some enjoy;  but rather what caused them and why some people survive.  Deep Survival is more about the latter.

Why is it a trained SEAL can drown on a river while an untrained woman can survive an airplane crash in the Amazon and make it out to civilization?

The author, Laurence Gonzales, goes into the psychology of survivors.  One weakness of course is he can’t interview or ask questions of those who didn’t survive.

That said, in one chapter, he talks about maps and our places in them.  He points out often when people are lost it’s because they’re too busy trying to make reality fit their map.  They’ll look at a lake on the map, not see it in reality and convince themselves that perhaps the lake has dried up.  Or that the peak they’re standing on is really “that one over there.”

It’s only when they accept their reality can they become unlost.

I have to agree with him.  I tell people I haven’t been lost in the woods (or any other place physically) since I was about 3.  I’ve simply been “mislocated” a few times.  Indeed, I once came off a peak in the Adirondaks and after hiking awhile looked around and realized I had no idea where I was.  I didn’t consider myself lost, simply mislocated.  A little map reading later and some orienteering and 30 minutes later I ended up in the correct parking lot.

So a lot of it comes down to “attitude”.  You may not be where you want to be, but if you have the right attitude, you’re not lost.  You’re simply someplace other than you expected to be.  In August when I lost my job, I wasn’t lost. I was simply someplace other than where I expected to be.

While it was a bit scary (I was the sole breadwinner for the family) it was also a relief.  I no longer had the weekly commute from Troy to Virginia.  I could do other things.  I finally had lots of extra time on my calendar. Ok sure, the lack of income was a bit of an issue, but by focusing on the other factors, it really wasn’t so bad.

About two months later I was on a train when inspiration for a new business struck me.  Yesterday I filed the paperwork in the state of New York to form QuiCR LLC.  Under lawyer’s orders I can’t tell you what it is yet.  But stay tuned, over the coming months I will.

Only by letting go of my map, and accepting reality, could I end up where I am now.  It’s still a bit scary, but it’s also very exciting.

Think in Russian

In the classic Cold War thriller, Firefox, Vietnam veteran Mitchell Gant has to steal the top-secret Soviet Union, titular plane.  Among its advanced features is that the systems are controlled by thought.  But only if he thinks in Russian.  This becomes a key plot factor in the climax of the film.

In my last post ; I remarked how many bad solutions I had found to sorting a SQLDataconnection Gridview.  Well I’m happy to say I solved my problem last night. (And as an aside, I will not be posting the solution at this time because while the solution itself is decent, I’m not sure the code is the best.)  Part of my solution was solved by “thinking in Russian”.

As I had mentioned, some of the so-called solutions to this problem that I had found on-line were pretty bad.  In one case the author apparently decided the easiest solution was to decipher the viewstate, extract out the information, sort it and stuff it back into the viewstate.  Now, as I’m writing this, I realize one advantage this has is that it removes a roundtrip from the web server to the database server.  But that’s about it.

I also saw a solution that involved passing the column name back to the code-behind and having that decide which of multiple stored procs to call.  I can’t say I favored this approach since it basically means a lot more maintenance if you ever say want to add a column to your Gridview (which turns out I decided afterwards I may want to do.)

Even worse, I’ve seen people propose things like building the select string on the fly and I can’t even begin to say how bad of an idea that is.

That said, the more I thought about it, the more I realized what the “right” solution was.  Rather than fighting the system, I had to think like the system.

So, after a side trip down to trying to use SqlDataAdapter, I went back to my first approach of using a SqlDataReader.  However, based on one example I saw, I decided to move this to a function of its own.  This, if nothing else resulted in cleaner code (since I was already calling the SQLDataReader in two places (see Rule of Three).  Once I did this, it was a little matter of figuring out how to bind the SqlDataReader to a Datatable and returning that.

Then I could bind the datatable directly to the GridView if I wanted to (which I do on the original Page_Load and Click_Submit OR I  could in the _Sorting event bind it to a local Datatable, sort that and then bind the resulting sorted Datatable to my Gridview.

Worked like a charm.  Well except for one little detail.  And this one I’m still not sure if it is a MSFT bug that lives on for backwards compatibility or I and MANY other developers are doing something wrong, but the GirdView incorrectly will always return “descending” for its sort direction.

So in this case the common (still not convinced it’s the RIGHT or BEST solution) is to stuff a variable in the Viewstate and read that back every time sorting is called and reverse it as needed.

Once I did that, I had working code that could sort my Gridview on the selected column that was clean, easily reproducible and made sense.

I’ve found with my forays into .NET Framework and VB programming that if my initial approach appears overly complicated or just plan wrong, it probably is.  So far in pretty much all cases, I’ve found that if I stop and try to “think in Russian” the solution will appear to me and is generally fairly straightforward and looks right.

Years ago when I studied Latin, I reached the point where I could read Latin natively.  I loved it. But part of the switch is being able to think in the structure of the language.  Not all languages use “SVO” (Subject-Verb-Object) order like English.   Latin, “SOV” (Subject-Object-Verb) order uses.  It takes some getting used to. But once you accept it, things get easier.

So I can’t fly a Mach 6 stealth aircraft, nor do I speak Russian, but I’m starting to think in VB. (Or is that I’m in VB starting to think?)

Goldstone has the Bird

One of my favorite web-comics is xkcd.  I was recently reminded of http://www.xkcd.com/978/.  I’m in the process of putting together a .NET 4.0 Framework based website using VB.  I have a very nice table thank you very much that is bound to a SQL Datasource in the code-behind.  Nice and slick.

Except, I want to make it sortable.  Should be as simple as setting AllowSorting=”True” and marking the columns I want sortable.  However, that doesn’t work when bound to a SQL Datasource.

No problem.  I’ll just Google it.  And there I find about a dozen answers.  And a third of them are just plain wrong (wrong enough even with my limited VB experience I can tell they are wrong), another third quote the wrong answers and the final third simply don’t work (and are so poorly commented in some cases I can’t even figure out what the original author was even attempting.)

And please, before you forward me a bunch of links in an effort to be helpful, don’t.  I’ve seen them.  Probably.

But it does lead to the general question.  How do you know what you read on the Internet is accurate? Even if it quotes a source, how do you know the source is accurate?

For years many people who followed the space program believed that “Goldstone has the bird” was a quote about Explorer 1, the first US satellite being picked up by the Goldstone tracking station, thus proving it had made orbit.  For years this was believed by many.  It is quoted in several reputable places, including the autobiography of someone who should have had first hand knowledge.

However, there is at least one little problem.  Goldstone hadn’t been built at the time.  So even the “original” source appears to have gotten it wrong.

http://www.thespacereview.com/article/550/1 for more details.

Just give that a thought the next time you look something up on Wikipedia or another source to confirm your facts.

Employee Loyalty

I’m in the midst of trying to put together an idea for a new company.  This is something I’ve wanted to do for years.  The hardest part of course is coming up with the right idea.  I think I’ve got that.

But as equally important to me is building a company that I would be proud of and that will attract good employees and retain them.

Years ago, I was consulting at a local software company, performing their IT functions.  They were a large customer of mine so I spent a lot of time there, enough that I was almost like an employee.  Only I wasn’t treated as badly.

I recall one day sitting in a company meeting where the CEO and the CFO patiently explained to the employees why their expense checks would be paid as late as possible.  You see, it was better for the company’s balance sheet.  But don’t worry, the employees would get their money, eventually.  They then basically gave a morale speech that boiled down to, “We’re not sure why everyone is complaining, you should feel lucky to have a job!”

As a contractor I had a much easier way of making sure I got my money when it was due me.  I could simply stop working.  A quick call to the CFO would get me paid.

This late payment of employee expenses combined with other issues basically killed morale at the company.

At the same time, my wife was recruiting for another software company across town and one of my other customers was across the river.  Both were recruiting.  It was amazing how many people jumped ship from the first company to either of these two companies.

One day I was at the company across the river doing some consulting.  They had recently recruited a developer from the first company.  Earlier that day he had submitted an expense check.  Now, like any reasonable person, he would have been content waiting until the next payday or some other reasonable amount of time for his expense check.

Well later that day, I saw him walk out of the finance person’s office with his expense check in hand.

A single act bought his loyalty more than any pay raise or speech about morale could have.

I want to make sure my company (assuming it takes off) can treat its employees with the respect they deserve.

A Bright Idea and State of the Art

I think everyone likes to talk about “their first program”.  I suspect though it’ll become a less common topic with future generations, just like most kids don’t recall the first book they ever read.

My first program calculated things in Celsius if you provided the Fahrenheit temperature.

I was probably 11 when I helped write it.  It was stored on paper tape and ran on the local high school’s minicomputer (probably a PDP-9 but I honestly have no idea).

It wasn’t a long program, it was probably in FORTRAN.  Again, that is so long ago, I can’t recall the details.  And it wasn’t a very impressive program.  Heck, these days you can do it in a Windows CMD script as one line. (well two for clarity, SET F=212, SET /A (%F%-32)/9*5)

I wrote more complex programs in High School (by then had moved up to Turbo Pascal) and made my first money programming in FORTRAN while in college.

Things had improved from paper tape to floppy drives to hard drives.  Writing programs and debugging programs for the most part became faster. But generally anything more complex than basic input and output through the screen and keyboard was still tough to do and time-consuming.

About two weeks ago I had an idea for project.  I was on the road at the time and didn’t get a chance to sit down at my desktop until last week.  In less than 24 hours I had prototyped the idea and tested it.  The program involved a website, a database, doing some lookups, writing to the database and a bit more.  Even just 10-15 years ago it could have easily taken me 4 or 5 times as long to do something like that.

On Thanksgiving Day, my son wrote a program in a language called Scratch http://scratch.mit.edu/ that would take input, make it circle around then settle on the screen.  The more times you entered text the bigger the resulting “wordle” spiral would grow.  He wrote it that morning before our relatives showed up.  It took him maybe an hour or two, including debugging and overcoming some initial limitations.

He’s been writing programs in Scratch (and other languages) for years now.  I doubt he remembers his first program since writing programs now has become about as easy as using a computer.  I’m sure he doesn’t remember his first time using a computer like I do.  He writes programs at age 11 that in many ways are more complex than anything I wrote in my teens.

The state of the art has certainly changed and it’s made the world a better place all-around.  Languages and frameworks make developing faster and easier than ever before.

Though at times I’ll admit I miss the days of FORTRAN.

Order of the day

I’m in the middle of designing a db schema for a project I’m working on.

As I was sitting in my car, waiting for the light to change, I remembered a mantra of SQL design.  And what is funny is I often see this fundamental aspect overlooked or even in at least one case, intentionally ignored: namely tables do not have any intrinsic order.

Almost all of my experience has been using MSFT SQL Server, so my thoughts will be based on that, but the general idea is true.  Beginners to SQL will assume “if I put the data in in order, it will come out in order.” Now if they’re a bit more than a beginner, they’ll even test that.  And lo and behold, they’ll probably find their assumption is right when they test it.  Then they’ll put the code and schema into production and find that suddenly things aren’t working right.

They’ll wonder why it worked on their machine, but not on production.  Generally there’s two reasons.  SQL Server is very aggressive about caching, so there’s a chance it’ll read the data out of memory in the order they put it in.  In addition, if it does have to read it off a disk, it’ll most likely do it in a single-threaded manner, following the primary key and the data will come out as expected.

On production though, between the time the data is inserted and later read back, the cache may look very different.  But even more so, a production machine is liable to have multiple disks and multiple CPUs which means multiple read threads will occur and SQL Server will then put the data together in the faster way possible.  Suddenly it’s no longer in the order the programmer wanted it or expected it.

Now, if you’re writing a quick ad-hoc query to get some data out quickly, that’s probably ok.  I’ll admit I do a lot of queries without an order by when I just need to quickly get some data.  But if it becomes time to productize the code, I’ll use an order by.

As I mentioned at the top of this post, the lack of an Order By seems to be a fairly common mistake made by folks new to SQL programming.

But what about the case when it’s intentional?  Years ago we were rolling out some new code and in the code there was a query that did a query against a table.  In theory the table would only ever have one row.  The programmer decided with one row no order by was necessary.  However, as always theory and practice don’t always match and I asked what would happen if there was more than one row?  His answer was to use a “TOP (1)” in the query.  So I asked him what would guarantee he’d get the top row he wanted.  He said he didn’t think the problem would ever arise and resisted using the ORDER BY “for performance” reasons he said.

Well since I wasn’t his manager, I wasn’t about to fight this particular fight.  But I did make a note of it.

Sure enough, about two years later (a year after he had left the company) the page that used this query started to return the wrong results.  A quick look and a quick addition of an ORDER BY and all was well.

It’s always the little things.  And that’s the order of the day.

Xbox Kinect

So, saw a commercial for the Xbox Kinect last night.  My son asked a bit about it.  What was the most interesting about the commercial wasn’t that it was trying sell games, it was trying to sell the Kinect itself.  And it wasn’t doing that by highlighting games.  It was highlighting http://www.xbox.com/en-US/Kinect/Kinect-Effect. When the game console wars re-ignited a few years ago, there was a scramble between the Playstation, Xbox and Wii.  The Playstation and Xbox took the traditional route. More features.  Higher resolution.  Faster chips.

The Wii took a different route, almost like a guerrilla warfare tactic of not going for the faster chips, higher resolution.  They decided to change the gaming experience and go with their Wii Remote.  This changed the battle tremendously and  honestly is probably the only reason the Wii survived the battle at all.  I think if the Wii had gone the traditional route, Nintendo would have fallen by the wayside as Sony and Microsoft duked it out.

Then, a few years later Microsoft struck back with its own game-changing (sorry, couldn’t resist the pun) strategy.  They introduced the “jet-engine” known as the Kinect.  I use the term “jet-engine” not because it made anything faster, but because it changed the face of gaming dramatically, much like jet-engines changed aerial combat and strategy.

Originally tied strictly to the Xbox 360, within a month or so, open-source drivers for the PC were available.  This made it not just a new way to play games, but a completely new way to interact with a computer.

Now you can paint in three dimensions using it.  You can “grab air” and rotate and manipulate a digital image on the screen as naturally as if it physically in front of you.  You can swim through the Universe if you wish.  You can build a robot to navigate your house (Though it still can’t make the perfect martini.  Yet.)

And of course you can play games.

But like many great designs, its reach is far beyond its original purpose.  It’s innovations like this that truly drive the industry forward.

Next time you design something or build something, don’t fear someone using it in a way you didn’t intend.  Hope for it.

Connectivity

So I’m sitting Amtrak train 280, headed to New York City and then on to Atlanta.  And I can tweet, blog, check email and do business.  This is one reason I like train travel. (Though I’ll admit taking the train to Atlanta from Albany is far from the quickest way of getting there.)

I’ve been able to access the Internet from the train for over a decade now thanks to Sprint.  This time though I’m posting through Amtrak’s on-board WiFi service.  Amtrak is slowly moving into the 21st Century.

Given the technical limitations Amtrak is facing, I have to say so far they’ve done an acceptable job.  They still require you to hit their proxy web page before you can get any connectivity, which stopped me for a bit since I was trying to do non-HTTP based work at first (dialing into my home VPN and a particular chat program I use.)  I understand their point (so they can put up their disclaimer and all) but it is annoying.

One nice feature, though I suspect not much used is that once you agree to their terms of service, it takes you to a page that shows a map with your current location.  This can be useful if you don’t have a GPS and are curious as to where you are.

And from all reports, they’ve done a decent job future-proofing the system.    Briefly, each car basically has a repeater that talks to the cafe car.  The cafe car has the antennas and cell-modems and is designed to be upgradeable as technology improves.

Well, I was going to add more, but my old laptop keeps crashing (time to upgrade, but have to get some business!).  So for now I’ll end with saying I’m on train 19 now, on my way to Atlanta.  Where, thanks to the modern technology I’m now aware there are tornadoes.  Wonder what that will do to my trip.

 

Simplicity

Over the years I’ve been involved in a number of web-based companies.  All had great ideas for their business model.   One had one of them had a great idea for classified ads.  It had the latest in taxonomic matching and advanced search capabilities.  If you were looking for a Mustang, it could tell direct you to ads for cars or horses depending on context and other factors.  Its search capabilities were ahead of the time.  It had pretty much every bell and whistle the newspapers asked for and that the design folks could think of.

Then Craigslist came alone.  Craigslist was free (at least compared to newspaper classified ad sites where the newspapers typically charged.)  It had no taxonomic matching.  Its search capabilities were and still are bare-bones.  In fact, it very much relies on the user to narrow down and define searches.

But it succeeded where the other product failed for what I believe one very simple reason.  It was simply blazingly fast.  It didn’t matter if it returned bad results the first time.  It was so fast the user didn’t mind typing in new search parameters and narrowing down their search.  It was faster than any of the “advanced” newspaper classified engines I saw.  Sure, they might try to do a better job of returning results, but the honest truth was, in most cases people would end up doing multiple searches anyway trying to narrow down their search.  And in the time it took to do 2-3 searches with a typical website, Craigslist allowed the user to do 10-15 searches.  Time was money and people wanted to do things quickly.

Over the years with numerous sites I’ve seen the design get in the way of the end-user.  The truth is, 80% of the time, people will use 20% of the features, but they want those 20% to be as fast as possible.

So, keep it simple and keep it very fast.

One of these days though I’ll relate the story of the 3,000 mile Steinway search.