kmann3's blog

UPnP through OpenBSD

Microsoft provides a web page dedicated to checking basic net connectivity. You can find it here. I find it very useful for checking to see if UPnP works. UPnP is needed for Windows Live Messenger to do webcam stuff and OpenBSD is very much against UPnP, luckily someone wrote a page which helped get it going nicely. It can be found here.

The use of try/catch

So I had an intersting discussion with the guys at work about try/catches.

My opinion is slowly becoming: Try/Catches are habits of poor skill in programmers.

Sure, sometimes you need to use them merely to be sure. Or global try/catches *just to be safe*, sure, but relying on them -- I believe it's poor coding.

The argument they brought up was "so, what -- you're supposed to use if's for *everything*?" to which my response (now) is "what? you use try/catches in *everything* method?" -- which I know they don't -- and it bit us.

You see, in a DataGridCellMouseClick or some event simliar to that you can have it attempt to calculate what cell it's in. So, we had something like:

int SomeVal = Convert.ToInt32(DataGridObject.Cells[e.Cell.Row,e.cell.Column].Value.ToString());

 Sounds simple, right?

Well, turns out if you click on a column -- it barfs (either row or colum will be < 0 if you click them). So, ok -- to what extent do you do sanity check on data? It's awfully unreasonble to do sanity checking on *everything* *everytime*. So, perhaps you should just do it when you intiate it?

The net result was something close to:

if ( e.Cell.Row < 1 || e.Cell.Row < 1)
    /* Assume they clicked on a header column or row */
    return;
int SomeVal = Convert.ToInt32(DataGridObject.Cells[e.Cell.Row,e.cell.Column].Value.ToString());

Something I have learned while writing a migration app is that try/catches slow you down an amount that is not insignificant. A couple million times and you are looking at adding minutes or *hours* to your app. So not only have I learned this habit because it made my app much slower, I learned you should pay more attention to your code.

Perhaps slowing down coding to make code cleaner is a better idea. Think it through.

I found a few comments around the net about this too and it seems that some believe try/catches are so infignificant that you should use them freely while others will say that using a try/catch because you don't do proper parsing / variable handling just shows poor coding skills. A very common one is DateTime.Parse versus using DateTime.TryParse -- which I should use Int32.TryParse above (go figure).

On an important note, I do understand (and use myself) try/catches for play-pen type code. Things that *can't* faily, however, I don't allow try/catches. For example, migrations -- they *can not* fail. Ever. Peroid. Hitting a try/catch means *I* fucked up somewhere or someone pulled a network cable (which I need to research how to check for that anyways).

My "Vista Score"

Stock HP Pavilion Ultimate d4999t:

5.4

Ok, so apparently it only displays properly in IE... that's fucked up.

update: Also doesn't display in Firefox 3 Beta 5. I'll investigate why.... merely just to know.

If a programming language was a boat...

Linky

That is a pretty funny link.

Apple lieing to customers

Not too long ago Apple attempted to push for Safari to get installed by lieing and saying it was part of its update scheme.

This has been blogged all over the web with usually a bad flavor in many peoples mouth.

Some believe that most users just click OK because of Vista's UAC... they are failing to take in to account that the users are not only not informed but the geeks tell them things along the lines of "if an update comes up, just update".

This "let's blame Vista!" attitude is getting anoying. Mostly because far too few people have legit complaints. In fact most people, who are willing to udnerstand that things in the computer world change, have no problem with it. At all. Those that DO have a problem where the EXACT same people bitching about "fisher price XP". Guess which one they love and hate now? Hypocrits. My uncle is someone who just wants it to work and refuses to learn anything different. I remember him going from Office 97 to Office 2003 and how much be bitched. 98-2k, same thing. Oh well... when the fear controls your actions.. they aren't your actions anymore.

Many people are jumping to Mac thinking their stuff Just Works (TM) and they don't have to worry about getting infected with malware. That's only true in the short term. The real problem is education. Someone uninformed isn't going to know the difference between an application needing updates asking for root privs than a trojan asking for root privs. In fact the biggest safeguard for Macs is their list of software you can install is so small it's unreal. Judging from the experience my employers are having and the complaints I've heard people say about Mac it's pretty much turned me off from a Mac -- especially about the VMWare Fusion.

I don't remember if I posted my complaints about Vista but it really only boils down to OpenGL sucks. I can't play NS anymore correctly (your evolution bar isn't shown properly).

I'll bitch more about this later.

 

Update: Here is some linkage.

The absolute minimum to know about unicode and charsets

Someone posted this under the title "If you don't use this, you are like a doctor who doesn't believe in germs." I'll agree with that to a certain extent.

Here is a link which explains unicode. I spent some time on this before and have started trying to implement a more language netural code conciously. I've done the same on my wiki's and blogs.

Upgrade seems to be a partial success

I still have more fighting to go.
I'm starting to wonder if /any/ CMS doesn't suck. Drupal has always given me a little greif in one way or the other but this time it was with the upgrades. Somehow it disabled the 'content' section of the menu -- which I had to hunt down and re-enable. I'm now trying to figure out how to get my tags back in to blocks but that seems to be a pain.
Sadly, Drupal seems to be the best at what I want... which either says my standards are too high or the tech /still/ sucks.
I wonder how the TaxonomyAccessControl stuff is going.. last I recall it was a gnarly hack to get things working on something you would expect to come by default.

Updates coming soon...

I'm going to be updating this Drupal install and fixing a few things tonight... things may be flakey for a little bit.

Speed testing

I'm in the process of getting an app going under .NET 3.0 using Visual Studio 2008 to see the differences in speed between Linq, SubSonic, and using a plain SQLDataAdapter. Yes, I'm well aware using a DataReader / DataAdapter is going to be faster -- the question is: How much faster? Is it worth making the code that much more cleaner? What about if the code is only going to be used once 4 months from now and, hopefully, never touched again? My problem is I want something to be as fast as possible without making code ugly and without spending a lot of time tweaking -- so I'm taking the shotgun approach. At the moment, it seems like they are all fairly close unless you are dealing with LOTS (millions) of records -- which I am not. SubSonic has its fair share of bugs such as puking if a table doesn't have a primary key. I can understand it not understanding how to right back or do complex queries, I just want to populate a collection with a 'Select *' type statement -- so it doesn't need a care about primary keys as I'm just going to loop through item in the collection and pull data as I see fit. Also, SubSonic seems to always do a 'SELECT *' type query if I want to use the simple code such as 'Some_DB.Some_TableCollection TC = new Some_DB.Some_TableCollection().Load();'. If I want to be specific then I have to use a Query class. Even worse, it's /horrible/ at doing OR's. They really prefer you to use views or stored procedures. Neither of those are bad, but I'm not writing code for something anyone else but me should be using -- so I don't care about exploits or any safety measures. Even if I was, this engine doesn't have any direct input mechanism, so good luck with that. Linq seems overly complicated. Fucking A is it a bitch to setup. Nothing seems automatic. Code doesn't /feel/ cleaner (so far from my, admittedly, little testing). Google doesn't seem to know how to use it either. I'm finding contradicting information. So, this means I have to do a "best case scenario" speed test to get both Linq and SubSonic working, which isn't a bad idea. One of the programming styles I learned was "assume everything will work perfectly, *then* make exceptions". The alternative, which is more common, is plan for the worst then if it's the best do X. The problem with that is you are always occurring the overhead of the worst instead of doing the best first and if it fails (Which it rarely should) then go to some exception handling. This places me back at square 1. Here is my game plan:

  • Have a script which will populate a database + table with random data. This way nothing can be cached and you can regen as needed. This will probably populate a 'person' table with 2 million records. This is a small amount compared to some other databases, but for our instance it should be plenty to test for speed.
  • Write a GUI which has a listbox and a DataGridView. The listbox will contain different methods of getting data from a SQLServer to a DataGridView. The hope being that if I can get it from a SQLServer to a DGV then I can be fairly certain nothing got cached and everything got pulled over for data manipulation.
  • Write a a few tests. These tests will probably be a simple SubSonic, Linq, and SQLDataAdapter. I will later do more complex queries and embed them to attempt to bring out slowness or resource hogs. SQDA and SubSonic will be the first two. Linq will be third, and any other complex queries will be last.
  • Open source the program and release to world under BSD license.

I'm also probably going to try some of this code on other DB engines such as MySQL and SQLite.

Eopen -- flat out sucks

I'm finding that Microsofts eopen website /still/ sucks after many years.
It's still just as flakey as when I used it when I worked at C&D.

It seems that 1/5 of the time I get a 'Service Unavailable', another 1/5 of the time it simply redirects my login back to the orginal page without actually logging me in, another 1/5 of the time is spent waiting... for 10+ seconds for a page to respond (with a random chance as to what error message, if any, I'll get or not), and the other 2/5's of the time it works.

I don't think I've /ever/ found a website that was this unreliable. Wow.

Syndicate content