Sep 11 2007

DotNetNuke: Redirect after Login

Category: DotNetNuke, Programminglomaxx @ 2:14 pm

I was doing some coding on a DotNetNuke module today and ran into a problem where I needed to check to see if a user was authenticated when they arrived at my page. If they weren’t I wanted to be able to send them to the login screen and allow them to login. Once they’d logged in, I wanted them to redirect back to the url that they were previously trying to get to.

I couldn’t actually find a reference to this anywhere so I thought I’d post the code up that allowed me to do it.

If Not Request.IsAuthenticated Then
    Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, True, PortalSettings, "Login", "returnurl=" & Server.UrlEncode(Request.Url.ToString)))
End If

Because the login page accepts a returnurl parameter in the querystring I can pass the current url of the page I’m on to the login page and it will return to that page after the user is logged in.


Sep 07 2007

Video Tutorials and Coding

Category: Programminglomaxx @ 4:30 pm

One thing I’ve noticed more and more in recent times is that with the advent of YouTube and prior to that Google Video, video tutorials have exploded and are available on just about every website. I can see the appeal of video tutorials and with video podcasting becoming so popular, there’s no reason why people shouldn’t be taking advantage of this medium to get their tutorials out there, but one thing that I’m finding myself disliking more and more is the proliferation of Video Tutorials that show you how to do something in code.

Video tutorials have been successfully done before in other industries where they have been around since the beginning of television, like in the cooking industry where people like Jamie Oliver have made a fortune with their video tutorials called “Cooking Shows”.

Other successful areas are in home improvements shows that not only have their own shows, but entire channels dedicated to them.

In recent times, video tutorials showing you how to do something in code have become the norm and you only have to check out places like the Ajax.Net homepage to see that video tutorials are becoming the rule rather than the exception. At first it seems like a good idea to make your code tutorials video based, after all They’re very easy to make with tools like TechSmith’s Camtasia and you can show the user exactly what you are doing on the screen, however after watching a few of these video tutorials I’ve started to find a few things that are really starting to bug me:

  1. They’re a massive download. I know, sometimes they’re only a couple of meg, but still, even the smaller video tutorials weigh in at a much heftier size than their text based counterparts
  2. You can’t copy and paste. This one REALLY gets me cranky. I know it’s just a tutorial and I should be writing my own code, but seriously, not being able to copy and paste from a tutorial is just too painful to bear. Things like config settings really are handy to copy and paste, but some of these video tutorials rattle off 30 or so config settings that you need to continuously pause whilst you manually type them out.

  3. Navigation is a pain. As easy as video presentations are to create, they sure aren’t easy to navigate. If you want to quickly look up how something was done in the tutorial, you need to open the file up and jump around the video trying to remember where exactly it was that a particular action was performed. Even worse, is if the video isn’t available for download and you have to re-download the whole thing again, wasting your bandwidth and time waiting for it to load up before you can navigate it.

  4. You can’t search a video. I know silverlight is addressing this with some of the cool stuff it’s doing, but being able to search a video at present is not an option.

  5. Low resolutions are bad enough, but trying to read a low res code sample via a low res video is nearly impossible, and more often than not, a high res alternative is not available.

  6. I can’t skim a video. Well I can, but it means I have to download the whole video to do so. Often, I just like to skim an article to get the feel for the quality of the content, but it’s not so easy with a video.

Having said all of this, I should point out that I’m not completely against videos on the net. I quite like some of the podcasts around and I like videos that quickly and easily demonstrate key features of products. But it seems that people have missed the point of videos and are using them more and more to replace high quality written articles without actually thinking about the obstacles they are creating by choosing to take the easy option of creating videos rather than writing articles instead. Probably one of the best examples of written code examples is Scott Gu’s Linq to SQL tutorials. I know he’s done video tutorials as well, but they are usually designed to show a few features of a product or tool. When he wants to get in depth, there’s no substitute for his written code tutorials.

So next time you sit down to create a code tutorial, think hard about whether or not video is the right delivery medium to use.


Sep 06 2007

Why Access Isn’t Always a Good Idea

Category: Programminglomaxx @ 10:10 pm

There are very few days that go by where I don’t curse Access. It’s not because it’s a bad program. It’s not because it’s buggy or poorly designed. It isn’t even because it’s purple. The reason I curse this application is because it makes things TOO EASY. That’s right, not because it complicates things, not because it does things in funny inane ways, but because it makes things TOO EASY.

How can this be you say? How can it possibly be a bad thing to make something too easy? Well let me explain.

Access is a tool for designing relational desktop databases and it’s a very good tool for doing it to. It not only comes with a backend database (albeit limited, but nonetheless, it’s a relational database engine), but it also comes with a forms generator, access to VBA and you can even have ODBC connectivity so you can access your data from other applications. It’s a very neat package and it works quite well. Not only does it work well, it’s dead simple to write a table, create a form and even wire up some basic code to validate the form before you save it to the database.

So far, this sounds more like a sales pitch than an explanation as to why I don’t like people playing with access, but here are my reasons why I don’t always agree that Access is a good Idea.

Designing Relational Databases Isn’t Easy

Database design is at times very complex. In fact it’s so complex that some companies will actually hire people whose only function within that company is to design databases. Where it gets interesting is that Access confuses people into thinking that designing databases is easy, when this isn’t the case at all. The only thing that Access makes easy is interacting with the database. See the difference? Let me put it another way.

Creating a database in Access is easy.

Creating a table in Access is easy.

Creating a form in Access is easy.

Creating a query in Access is easy.

Designing a normalized relational database in Access is NOT easy.

People then think that because they are able to perform actions easily against the database, they are now able to design a normalized relational database. It simply isn’t the case. What I understand even less is that people clearly comprehend that developing good software isn’t easy and it doesn’t matter that there are awesome tools such as visual studio that make performing various coding actions simple, you just can’t get anyone from the finance department to whip you up a program because developing software is hard. Yet when it comes to databases they simply don’t care that it’s hard to design good databases. Perhaps it’s the fact that Access is installed on just about every corporate computer in the world, which fools people into thinking that if it’s installed on my machine, then it’s easy enough for me to use?

The Self Certified Database Designer

So many times I’ve gone to a client site after getting a call asking them to help out with “a problem we’re having with our database”. It all sounds pretty innocent until they start explaining the problem. Our conversation will then proceed something like this:

Me: “So what exactly is the problem?”
Client: “Well we have this database that is supposed to store our client information, but we aren’t able to get this report to run properly”
Me: “Hmm, so what sort of database is it?”
Client: “Oh it’s just an Access database that one of the guys in marketing built”

Right about now I feel like saying “Well, if the Marketing guy knows how to build databases, then he should be able to fix it. I assume he’s had experience in designing relational databases since you’ve entrusted him to build one for storing your business critical data in it”

But since they’re paying me good money to be there and usually by the hour, I just respond with “well I guess I’ll take a look at it then”.

I usually get sent to some desktop PC that’s housed in the back recesses of a building somewhere, get told that this is the “server” and I’m left with some instructions on how to get into the database. What I then find is nothing short of Access database blasphemy. Tables without Primary Keys, relationships without foreign keys, tables that aren’t normalized or data that is stored in ways that are simply not going to be useful to anyone doing anything normal with the data. This brings me back to the point that designing databases isn’t easy and this is why they have courses at universities dedicated to the subject. It’s why companies employ people just to manage their databases or sometimes teams of people to do so.

Probably one of the key indicating factors that you’re talking to a Self Certified database designer is the fact that they’re even suggesting using Access to store your company’s important data. People that work with databases and have degrees in database design and have spent a few years commercially designing a database simply wouldn’t suggest you use Access because they’ve been designing databases for long enough to know that Access isn’t going to provide your company with any sort of long term solution. If you’re talking to a real database developer, they will go for a proper database engine because there’s no reason not to. Companies really are surprised when I tell them that there actually is a free version of SQL Server from Microsoft and the 2005 version even comes with a management studio which is extremely powerful when it comes to performing actions against the database, which is what Access is so good at.

Access Has Limitations

Many people who use and recommend Access to other people simply aren’t aware that it actually does have limitations. Some of which include limited file sizes, limited security mechanisms, limited user access, limits on the number of rows a table can have and there are many more.

People often come to me and say, “Yes we know Access has limitations, but what software doesn’t?” or “We know Access has limitations, but our database will never be big enough to be affected by those limitations”.

Well let me tell you this:-

If your database gets big enough that just 2 people are trying to use it at the same time, then it has become big enough for you to be affected by these limitations.

If your database is big enough that you made a copy of it and sent it to someone else in your organisation so they can add information to it, then it has become big enough to be affected by these limitations.

If your database is big enough that you have put a username and password on it to protect it from people in the organisation then it has become big enough to be affected by these limitations.

You see, it isn’t too long before you start being affected by the limitations of an Access database.

VBA Has Limitations

There’s no denying that VBA has a lot of power. It lets you do a whole host of things and it’s really easy to use, however if you try and use VBA for something that it wasn’t originally designed to do, you’ll find out that it can be a painful process getting it to do what you want.

For example, sending emails from within Access is possible, but it sure isn’t easy, especially when you compare it to the ease with which you can send emails from other programming frameworks. Accessing external data sources isn’t always as simple as the wizards would have you believe.

There’s little to no support for third party plugins and other components and redistributing VBA code is nowhere near as clean cut as it should be.

Conclusion

I guess when you look at it, Access is a simple easy to use tool for creating self contained databases, however that simplicity often means that people mistake Access as a substitute for a well designed database application because they can get Access to sort of do what they want it to do.

However in the long term, and especially when you consider the free alternatives that are around, Access just doesn’t really make any sense.

If you are struggling with some Access database issues and would like some advice on what alternatives would suit your business needs, feel free to send me an email and I’ll be more than happy to contact you to discuss your problem.