Saturday, March 26, 2011

Least Busiest Dmv Los Angeles

VFP: Back home

After a couple of years working primarily with. NET in all its flavors (ASP.NET, WinForms, Compact Framework), last month I started a project that brought me back to using VFP as the main development environment.

And the truth has been like coming home. A renovated house, that if, as the project is based on VFP 9 so I could make use of several new options that came in this excellent version.

Paradoxically, more and more I find myself using concepts learned in VFP. NET and C # specifically. Instead of using enumeration constants have simulated class ADDPROPERTY Empty and function, rather use a global variable to store the connection handle returned by SQLEXEC () representing the connection I met with a class called SqlConnection. So, when prior to:

LOCAL nConn,
nResult = 0
nConn

TRY
nConn = SQLSTRINGCONNECT (cConnStr)
nResult = SQLEXEC (nConn, CSQL, cCursor)

CATCH TO ex

FINALLY IF nConn <> 0
SQLDISCONNECT (nConn) ENDIF

ENDTRY

now do:

LOCAL oConn
oConn = CREATEOBJECT ("SqlConnection" cConnStr)

TRY
oConn.Open ()
oConn.Send (CSQL, cCursor)

TO CATCH ex

FINALLY IF = connectionState.Opened oConn.State
oConn.Close () ENDIF

ENDTRY

Comic
right? but the truth is that not only I feel more comfortable with the 2nd version, I guess because it reminds me of what I've been using in recent years, but also believe that the final code is more readable and more reusable and encapsulated too.

By the way, if anyone knows how to simulate the concept of interfaces in VFP, I tell you, because that is one of things. NET VFP want in!


0 comments:

Post a Comment