Wednesday, September 23, 2009

Multi-Browser/OS Testing

So Scott Hanselman has a post up today about "MultiBrowser or CrossBrowser Testing and deconstructing Microsoft Expression Web SuperPreview". He mentions BrowserShots, and the Virtual PC versions of Windows that you can download, but I think he missed on important one and that is from Adobe.

Adobe has one called, BrowserLab, and this will emulate multiple browsers, as well as multiple operating systems. I have not fully tested this site yet, but our graphic designer showed me this site and it seems to cover most if not all the browser bases.

One of the nicest features is the Onion Skin. This feature allows you to take two browser views and overlay them so that you can see where they differ. Wow, is all I have to say about this feature. Where was this when I was freelancing as a designer/dev? This is a must in any designer or developer's toolbox.

Stanley

Tuesday, September 22, 2009

Pet Peeve with Exceptions

Private Sub MyMethod()
    Try
        '...do something
    Catch ex As Exception
        Throw New Exception("MyMethod", ex)
    End Try
End Sub
The code above is a big pet peave of mine because with code like the above you end up having to dig down through multiple InnerException objects to find the right exception message.

Working with exceptions is a very easy task. Only catch an exception if you can do something about it. Re-thowing the exception is not doing something about it. Reporting the error via email, event viewer, etc., is also not doing something about the exception. All of this can be done at the form/view/page level of the application.

For instance, lets say your building a class:
Public Class Person
    Implements IDisposable

    Private m_FirstName As String = String.Empty
    Private m_LastName As String = String.Empty

    Public Property FirstName() As String
        Get
            Return m_FirstName
        End Get
        Set(ByVal value As String)
            m_FirstName = value
        End Set
    End Property

    Public Property LastName() As String
        Get
            Return m_LastName
        End Get
        Set(ByVal value As String)
            m_LastName= value
        End Set
    End Property

    Public Sub New()
    End Sub

   Public Function GetAddressByNameTheWrongWay(ByVal FirstName As String, ByVal LastName As String) As String
        Try
            '...do something and return
        Catch ex as Exception
            Throw New Exception("some dumb message here",ex)
        End Try
    End Sub

   Public Function GetAddressByNameTheRightWay(ByVal FirstName As String, ByVal LastName As String) As String
        '...do something and return
    End Sub
End Class

So now with that class we have two ways of capturing the exception in our page.

Partial Class Maintenance_IVANSAgentApplications
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim objPerson As New Person
        'Lets call it the wrong way first.
        Response.Write(objPerson.GetAddressByNameTheWrongWay(txtFirstName.text, txtLastName.text))
        'Now lets call it the correct way.
        Try
            Response.Write(objPerson.GetAddressByNameTheWrongWay(txtFirstName.text, txtLastName.text))
        Catch ex as Exception
            Response.Write(ex.Message)
        End Try
    End Sub
End Class

Since we were not able to actually do anything about the error message then we let it bubble up to our page level and catch it there.

Something that you may have been able to catch in our Class Person, would be a database connection issue. Perhaps the database was not available we could put code in to try a different database or to keep trying for so many tries. Just make sure you limit the re-tries, so that you do not get a timeout on your page while waiting for a database to return data when it will never come back.

Stanley

Welcome

Welcome to my little place in Cyber Space. I plan on using this site to help with my writing skills as well as a place to hold information about my software writing. If you have constructive critisim about anything I write here please feel free to leave a comment. I am always open to constructive critisism. If you plan on just making yourself look cool in your own eyes and want to degrade me, then please just keep going to some place else on the web. I am not looking to be put down because you think your cool.

If you like what is here feel free to follow me on Twitter. In general my Twitter posts are about my day or replying to others I follow. I'm still getting into the social revolution on the web. Call me slow, but at least I am making a go of it.

At this point in my career I am working for an Insurance Processing company, writing software. I write using the .NET Framework, using VB. My major project right now, is re-writing our check writing software into Microsoft Dynamcis Great Plains. I use Visual Studio Tools for Microsoft Dynamics GP, along with Visual Studio 2005. The learning curve for GP is pretty high for me as I am not an accounting person and do not understand accounting beyond the very basiscs. So if you have a site that teaches you about accounting basics and more send me a link.

Thanks for stopping by.

Stanley