Saturday, May 15, 2010

Looking for Data: A cool framework class

As the article below notes, almost every application needs data searching. In Visual FoxPro, the first time out, many developers use a browse or a grid.

Or a user enters a value into a text box and the code behind it might look like:

IF SEEK(tcValue)
DO FORM details

But from Foxite and Jijo Pappachan, comes a very cool and easy to use Lookup class.

The class handles both SQL and VFP backends with ease, allowing for smart optimization.

Of course, if you're already using a framework, you may already have something like this - but this is something that should certainly be put into an updated FFC on VFPX. If you've ever used the existing FoxPro Foundation Classes search tool, it's pretty limited.

This one is definitely more in line with how applications are looking these days.

The sample pages don't work quite right and it needs a few tweaks to handle large field names but it can be easily called manually.

lo = NEWOBJECT("lookupdata","lookup")
USE Contacts
lo.SelectCmd="select fullname,ctitle,firstname from contacts"

It attempts to put a tag name and since tag names have a limit to their field space, it may error out but otherwise it looks quite good.

Check it out below:

jijo pappachan : DataLookup - A framework class

Friday, May 14, 2010

New FoxShow: FoxPro and Silverlight

There's a new FoxShow episode featuring an interview with Uwe Habermann about moving from Visual FoxPro into Silverlight. This is a preview of his upcoming Southwest Fox session. You can download it directly or subscribe in iTunes.


Friday, May 07, 2010

VFPX: New PEM Editor Beta Now Available

If you haven't downloaded the latest PEM Editor from VFPX, you're definitely missing out.

Instead of the traditional tiny dialog to add properties and methods, the new PEM Editor gives you literally everything at your fingertips. See here:

It's not just a good replacement for adding, it's also a fairly good replacement for the Property sheet as well. It's also starting to add features that VS developers have had in their IDE but VFP never got them.

Some immediate highlights (not just from this release but overall):
a) ability to mark properties as favorites globally (so any instance of those properties regardless of form becomes a favorite)
b) Dockable and resizeable
c) highlight inherited and custom code and properties with colors
d) Go To Definition
e) Extract to Method - kind of like instant refactoring

Not only that but PEMEditor features the funky VFPX-Powered logo, which I think needs to become standard for all VFPX IDE controls.

Great job!

Thursday, May 06, 2010

SQL Scripts: Record Counts

As I'm populating a sample set of data in a SQL Server project, I needed a quick way of identifying what tables I had missed.

Here's what I came up with (but a much faster way is noted below using the sys tables).

--- Identifies zero record count tables
declare @vtb varchar(200)
declare @vsc varchar(200)

declare x cursor for select table_schema,table_name from information_schema.tables
open x
fetch next from x into @vsc,@vtb
declare @vcnt int
print 'declare @vcnt int'
while @@FETCH_STATUS = 0
set @vcnt = 0
print 'set @vcnt = 0'
print 'select @vcnt=count(*) from ' + @vsc+'.['+@vtb + ']'
print 'if @vcnt=0 print ''' + @vsc+'.'+@vtb + ''''

fetch next from x into @vsc,@vtb
close x
deallocate x

Note, that the script does support the schema tag but it does expect you to already be in the database (via USE).

This generates the output into the message window where you can then take it and run it.

You could also simply pipe it to a variable and then execute that variable.

It's not fancy, but it does work so you may also find it of use.

The other approach I've seen used is one where you use the sys.indexes table.

--Code modified from original posting on SQLServerCentral.Com
SELECT AS "Table Name", i.rowcnt AS "Row Count"
FROM sysobjects o, sysindexes i
AND indid IN(0,1)
AND xtype = 'u'
AND <> 'sysdiagrams'

I have tried to stay away from the sysobjects table primarily since Microsoft doesn't advocate their use (although I can't find a posting about this), even though they are typically the fastest and easiest ways to get to real data.

Here's the similar script but using sp_spaceused to see how much space the actual tables are taking up.

declare @vtb varchar(200)
declare @vsc varchar(200)

declare x cursor for select table_schema,table_name from information_schema.tables
open x
fetch next from x into @vsc,@vtb
declare @vcnt int
print 'declare @vcnt int'
while @@FETCH_STATUS = 0
set @vcnt = 0
select @vcnt = rowcnt FROM sysobjects o, sysindexes i
AND indid IN(0,1)
AND xtype = 'u'
AND =@vtb
if @vcnt>50000
print 'retrieving for ' + @vtb + ' rows: ' + convert(varchar(10),@vcnt)
exec sp_spaceused @vtb

fetch next from x into @vsc,@vtb
close x
deallocate x

Tuesday, May 04, 2010

From VFP to Silverlight (at SW Fox)

Looking at the Southwest Fox 2010 workshops list, it looks like this year's conference will have a silver lining, thanks to Uwe Habermann and Venelina Jordanova (from the dFPUG). The day after SW Fox ends, they are presenting VFP to Silverlight, showing how VFP developers can use a VFP COM server for the business layer and Silverlight as the main UI.

Maybe just an interesting is the note on what Visual Extend will offer:
"The next version of Visual Extend will come with a wizard that allows the migration of forms and reports from existing VFX and VFP applications to Silverlight."

Another good reason to be heading to Mesa in October.

Monday, May 03, 2010

Vote Now: Visual Studio Project and Solution Version Compatibility - .NETicated

As Steve notes on his big post:
Visual Studio Project and Solution Version Compatibility - .NETicated,
"Microsoft is saying though that they listen to Connect votes. Today Kathleen Dollard created a Connect item for this issue, and I encourage you to vote. It’s important. It matters. And Microsoft says they take action based on Connect votes."

"And remember, by not voting, you’re telling Microsoft this is not an important issue."

The link site is here

SQL: To Schema or not to schema?

To schema or not to schema - That is the question;
Whether it is easier to find a table with a Schema.TableName ;
Or to simply build one with a strong naming convention,
and, by opposing schemas, force other developers to learn (and re-learn)
No more, with schemas ;

It's an interesting dilemma - especially when designing a database for an organization who changes standards with almost every new development project.

One recent project implemented schemas along with a naming convention so much that the schema name was repeated in the name of the table:


Definitely overkill. But then if I want to be able to separate out lookup tables from my other tables, having a LOOKUPS schema would appear to work, except that it creates the "extra typing" scenario as every table has to include the schema.

There are a few alternatives:
a) prefix tables with naming conventions that make their purpose obvious. luStates = a lookup table of states and tblStates for a table where the business purpose might be states.

b) ignoring all and keeping it related to the business purpose.

As with most development decisions, a lot of this can be subjective. Some developers even like to make it a challenge. But what every designer should keep in the back of their mind is this:

Is this readable?

Many developers I've spoken to come back to an older application and wonder what wonderful medications they were taking when they wrote a certain line of code (or they forget to remember it was their code to begin with). So the readability and maintainability of the code and by extension, the design becomes super important.

In a recent project, I've opted for a hybrid: the use of schemas for business purposes and the use of naming conventions for lookup tables, only. It makes it easier to identify the lookup tables in code but the schemas make the graphical depiction of the database cleaner.

What approach do you prefer when building an application?

Opinion: RIP Slate, Courier - and what might be missing in the Microsoft tablet strategy

Last week, there was quite a blow to the entire Windows 7 tablet business. HP dropped the Slate (less than a month after its internal PR push) and then Microsoft formally confirmed and killed the Courier project, a potentially game-changing Windows-based tablet, or was it?

The first thing that came to mind, unfortunately, was that while Windows 7 supports gesture-based input, it is more useful in a desktop environment (like the HP TouchSmart). I'm using Windows 7 and from a laptop and desktop, it completely rocks. I was in a business presentation two weeks ago and one of the Microsoft reps pulled out their tablet and used it quick effectively. But the Microsoft tablets (from Toshiba among others) have always been focused on the business end and putting your desktop applications into a pen-based environment.

Today's tablets (or the basic hype around them), on the other hand, are more focused on consumer or "lifestyle" use. I've tried Chromium on a laptop and was left less than impressed. I'm still waiting to see a real "Android" tablet. But Android is based on a phone OS, much like the iPad.

Based on the new reality of how tablets are being positioned, maybe Windows 7 on a tablet simply doesn't offer a truly new experience that tablet users are expecting. So why not build it on Windows Phone 7?

That could be the right approach, right? But the Courier project was apparently based on that operating system. So why was it killed?

Too small? At a reported 5x7 side, it could have been perceived as too much of a toy compared to the larger tablets but, I'm not sold on this. A tablet that could fold up? At 5x7, that makes it instantly carry-friendly but as a business device, maybe that's where it was failing.

Whereas Apple has only ever tried to serve one master, itself (or the one known as Steve), Microsoft is always trying to serve two: business and consumer. Certain things are easily positioned: xBox is definitely not going to be a business-friendly device and SharePoint/Office 2010 are not going to be truly consumer-based products.

But a tablet? That has to be both. From what I've seen on Windows Phone 7, it's definitely on that track, but killing what could be the first non-phone based use for it, might hurt it more than help.

Apple has always taken a "we've just changed the world" approach with their products, not without reason. But their community (and the press by in large) accepts the first product as almost perfection, and then gets all excited by the next iteration of the product, which finally delivers on some of the promise.

Microsoft's strength is in its re-iterative improvement. Guy Kawasaki once said, with Microsoft, quality is job 1.1 (he may have pulled that from another source, but it's definitely published in a number of his books). Funny - isn't that the argument agile uses to improve development processes? There is nothing wrong with a re-iterative approach.

Apple seems to be accepting that it constantly needs to re-iterate its software now that millions of people are using it. Heck, through the iPhone app store, I have some apps that have received over 5 updates since I first installed them. Microsoft has done that for years. Now that consumers are finally getting used to it, they seem to be pulling back from it.

I hope they killed the Courier project so they could re-use (or license) parts of it to have a killer tablet. There is a lot of research that goes on at MS that doesn't always make it into the public eye, then there is the research and technology that creates great applications. I hope this is one of the former; not the latter. Who knows? Maybe HTC is looking at building a Windows Phone 7 tablet.

Yes - I'm aware of the WePad (which will run Android) but it's not available until July..looks cool but we have to wait and see.
Does anyone use the Touchbook? Granted, there's no multi-touch and it's a hybrid laptop. There's one review here.