Friday, December 31, 2010

Joys of XML Serialization

Love it or hate it, XML is everywhere and for data and objects, it can be extremely useful.

On one of my last projects, a colleague introduced me to the useful XSD2Code project, which creates a .Net object from an XSD. This made it easy for him to build a structure that could be compiled into code to ensure everyone followed the same structure. This is extremely valuable if someone gives you an XSD as a format to write to and you want to populate it using an object.

In a more recent project, we needed to share details from a component with another calling application via a web service. Enter XMLSerializer, the .Net equivalent of taking an object and dumping it into XML.

Dim s As XmlSerializer = New XmlSerializer(Object)
Dim w As New StringWriter()


s.Serialize(w, Object)
return w.tostring

Sounds great, right? It was for a short time, but as the object got bigger, it contained more collections and references to other objects. Eventually, the Serialize method took up 100% of CPU Usage and never finished. Of course, we couldn't find the problem right off the bat so it caused lots of grief.

(without going into too much detail showcasing my ignorance on all of the specifics, XMLSerializer uses reflection to identify all of the public properties of an object and then outputs them to an XML file - if the object has a lot of objects or collections within it, it can cause a huge drain on the whole process).

Certain posts call to use the BinaryFormatter instead - which is impossible to read but when you de-serialize it, you get the objects out at the other end.

Dim formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()


Dim ms As New MemoryStream()


formatter.Serialize(ms, Me)


Dim sXML As String
sXML = System.Convert.ToBase64String(ms.ToArray())

But this makes the string illegible to any non-.Net applications, of which there are many - especially if you plan on building publicly accessible web services.

So I started to go through my initial object and blank out certain properties, so that the serialization would work.

What I didn't realize is I could simply tell the Serializer to ignore certain attributes. Enter the XMLIgnore attribute.

Instead of simply calling New XMLSerializer, I call a method that returns the Serializer but with certain attributes that tell it to ignore specific details.

Function GetSmartSerializer() as XMLSerializer
Dim xOver As New XmlAttributeOverrides()
Dim attrs As New XmlAttributes()


attrs = New XmlAttributes()
attrs.XmlIgnore = True
xOver.Add(GetType(ObjectClass), "MyBigCollectionThatNoOneNeedsToSee", attrs)


Dim xSer As New XmlSerializer(GetType(PRAM_Data.Session), xOver)
Return xSer

With the code above, when the application calls

Dim o as XMLSerializer = GetSmartSerializer()
Dim w As New StringWriter()


s.Serialize(w, Object)
return w.tostring

It now excludes the property "MyBigCollectionThatNoOneNeedsToSee" from the XML.

More details can be found here:
XmlAttributes.XmlIgnore Property (System.Xml.Serialization)

I'm curious though - has anyone else encountered this limitation of the XMLSerializer? What solution have you used?

Wednesday, December 22, 2010

Where are my features?

Here's an innovative way to show your customers where certain features are at in the development cycle.

FreeAgent Depot — A furtive glance behind the wizard's curtain

How well do you communicate with your clients about upcoming features?

Wednesday, November 10, 2010

Monday, November 01, 2010

HTML5 is Microsoft's cross-platform play

This makes an interesting development. I wonder if MS is going to come out with some form of XAML-HTML5 converter to support the developers who have devoted significant resources to Silverlight on the web. Silverlight *is* Microsoft's tool for Windows Phone 7 development so that's not an entirely lost investment.

Personally, I love XAML and use it for client development. WPF is far superior to WinForms but the loss of Silverlight as a long-term "supported" web tool isn't going to sit well with many.

Microsoft's Muglia reconfirms HTML is Microsoft's cross-platform play | ZDNet

TechDays Ottawa is coming up - it will be interesting to see how this announcement plays out at it. I'll be speaking on using Expression Blend and SketchFlow for prototyping but I certainly won't be focusing a lot on Silverlight as an application platform - WPF for clients is where it's at.

Update: Here's  a good article that compares MS' new strategy to the Apple HTML/Cocoa strategy.

Friday, October 15, 2010

Not at SW Fox? Check out the live feed and the tweets

If you are like me and didn't manage to get down to Southwest Fox, you can still follow what's going on.

While it's sad that no one is live blogging, they are "tweeting".
Check the link here:
swfox - Twitter Search

You can also watch the keynote on uStream here.

Saturday, September 04, 2010

PEM Editor 6 Now Released!

Jim Nelson has just posted a new update to his super popular Property/Event/Method editor on VFPX.

There are way too many features to count on this - but you can be sure that Cathy Pountney will be covering them in her SW Fox Session.

That said, some super-useful features that make this not even just an editor but a whole IDE enhancer:
a) Go To Definition
b) Extract to Method - the very easy way to refactor highlighted code
c) BeautifyX
d) Object comparison
e) Design Time event handlers (auto-resizing for one)

If you haven't tried it, there are some videos available but I'll also be doing some for an upcoming post.

Note: I spoke with Jim on a recent FoxShow interview before this release came out.

Saturday, August 28, 2010

Another Reason to visit SW Fox: Software, Software, Software

Doug recently linked to Kevin Ragsdale's post about why people should attend Southwest Fox. If you've been listening to the FoxShow recently, we've been interviewing speakers and there are more interviews to come in the next few weeks.

AKSEL is also proud to announce that we are offering two subscriptions to MSDN Visual Studio 2010 Ultimate for attendees. If you don't already have MSDN, this is effectively your way of getting every piece of business/developer related software from Microsoft.

Rick, Doug and Tamar will be drawing for the lucky attendee at this year's conference - so you have to be there to win it.

As a note, if you DO already have MSDN, Pay it forward and be sure to throw the subscription back into the hat for others who may not be getting it to get the chance to work with the latest development tools from Microsoft. Note: this subscription also includes great designer tools like Expression with Sketchflow which I love for prototyping applications.


Wednesday, August 18, 2010

Simple But Useful VFP Tip: Remote Views with SQL Server varchar fields

Note: This is a feature that's been in VFP for years - but I've often found that useful features often remain hidden until someone points them out. So I'm taking to finding my little VFP tips as I come across them and re-posting them here.

I work in a variety of environments but one thing I always keep with me on my USB drive is VFP. Regardless of the data I have to work with, I always find that a task comes up that is infinitely easier in VFP. The funny thing is that other colleagues on a team who haven't been exposed to VFP are usually amazed at how quickly stuff can be done.

Today, I was working with a SQL Server table and SSMS only lets you edit the first 200 rows on their own - otherwise you have to script it (or use another tool).

For most of these systems, I typically create a VFP Database Container and then create remote views as necessary.

Oftentimes, the problem is that when VFP comes across a varchar field that is longer than 254 characters, it immediately converts it into a memo field so I am left with something like this:


This is annoying as the field I really need to modify is the DisplayText column or the Memo field and while I can open it, I would prefer to be lazy on this end.

So in the View designer, highlight the desired field and choose Properties. Then change the Data Type of your output of choice. Since most of my text in this column will be less than 254 chars, I'm just making that change here.

Now, when I browse my remote table, I can see the contents of the field, make changes and they propagate right back to the SQL table.


Nice and simple.




Wednesday, August 04, 2010

Turning on the Lightswitch

Microsoft announced a brand new tool for business users yesterday called "Lightswitch", which (according to the announcement) makes it easier to build business applications for the desktop or the cloud.

Beth Massi sounds super excited by it, describing it as a tool that makes it easier to build data-centric applications, something that FoxPro developers know a little about.

Mary Jo Foley discussed Lightswitch as a tool similar to FoxPro:
" The idea, my sources say, is to bring the Fox/Access style of programming to .Net".

I don't buy that or maybe more to the point, I wouldn't put FoxPro and Access in the same boat to begin with.

This sounds more like an "Access" version of InfoPath which lets you "build advanced forms for line of business applications". If you walk through the screen shots shown on Jason Zander's intro page, it looks more like an application Setup Wizard or a "template-driven" application builder.

I welcome all tools to make building applications easy for organizations - it may dilute what many call "programming" - but if it solves an immediate business need, great.

However, remember all those efforts IT and centralized development shops have made to centralize development efforts, ensuring standards, etc?

Unless those standards were Silverlight, WCF and Entity framework, you've just thrown another tool that IT will hate into the mix.

From the intro page
"LightSwitch applications themselves are robust and are built on top of .NET technologies including Entities and WCF, the same technologies you already choose from when you write your apps today. Because the apps are built on top of .NET with VS you will be able to open your LightSwitch applications in the full version of Visual Studio and do advanced extensions."

Those key .Net technologies are VB or C#. I haven't seen what the final application and source looks like but let's face it - Lightswitch is a template-driven application builder for Visual Studio.

Some key points that make Lightswitch sound attractive:
- any database (including SQL, Sharepoint and Azure)
- can build desktop, WCF or browser-based applications
- extensible templates

Hank Fay jumped in with his analysis almost immediately, calling it a Bait & Switch, calling it an insult for domain-expert programmers:
"I have consulted with, and worked for, non-professional programmers for 12 years now, and if anything, the programs they create are more complex, in terms of data needs and UI needs, than what professional developers create. Oh, for sure, professional programmers can write complex algorithms, or wonderful feats of asynchronization communication over barriers of distance, protocol, and so forth. But when it comes to the business-end of the horse, one has to know the domain to understand the complexity, and that’s where the domain experts shine."

As someone who knows how important a good consultant is to moving an application along the right path, but I have also seen consultants or "experts" completely destroy a business opportunity, by either taking too long or not understanding the right concepts.

My big concern here is that Microsoft has added once again to the number of tools a business can use to extend or build applications with. You need to track something, do you use:
- Visual Studio (WinForms)
- Visual Studio (ASP.Net)
- SharePoint
- Dynamics
- Access
- Infopath
- LightSwitch
- Visual Studio (Office Extensions)
- Web Matrix
- MVC
- WPF/Silverlight

I know that LightSwitch is an extension from Visual Studio but promoting it as a separate product can make this tricky to decide.

Yes, each one has certain things that it does well - but remember when Microsoft's own teams had a rough time deciding between tools when it was just VS, Visual FoxPro and Access? Imagine what the discussion will sound like now.

As many developers now focus on development patterns such as MVC (MVP, MVVM, etc) to build best-of-breed applications, Lightswitch removes that process. As I noted above, until we see the actual code created, it's hard to judge how successful it will be.

I'm a big proponent for the right tool for the right job - but there isn't a lot of guidance as to where Lightswitch fits. That's going to be the big challenge.

SW Fox 2010 Location Changes!

I received an email last night from Rick Schummer, announcing a fairly big change for Southwest Fox 2010 - it's no longer in Mesa, Arizona - it's in Gilbert.

Previously made reservations at the Arizona Golf Resort have been cancelled - instead, the conference will be at the Legado Hotel and SanTan Elegante Conference and Reception Center in nearby Gilbert.

The new location looks amazing.

Use the code "SWFox" when registering.

Southwest Fox is the annual gathering of FoxPro developers with great sessions on development tools, techniques and practices.

Tuesday, July 20, 2010

Google promotes travel by kayak

I was planning a trip and looked up some directions in Google. Unfortunately, Google Maps went the wrong way and figured I wanted to go to China.

That wasn't a big problem until I read the directions.
Check it out below:


I had to double-check my settings. I was looking for car directions (not walking) but still, instead of flying or taking a cruise 2700 miles, Google thought I could travel best by kayak across the Pacific Ocean.

Priceless.

Saturday, June 26, 2010

Ken Levy on Servoy in Europe

Sounds like Ken Levy is really getting big on Servoy and convincing VFP developers to look into it. Fresh after his Servoy webinar.

Details for a special seminar on July 5th in the Amersfoot, Netherlands are available here.

Eric den Doop : VFP Developers from Europe are invited at 5 july 2010 at the Servoy HQ in Amersfoort - Netherlands

Thursday, June 24, 2010

Mindmapping with iThoughts, MindManager and Box.Net / DropBox

I love it when I find an implementation of technology that has likely existed for a few years but works (almost) seamlessly the way I need it to. I may have missed it the first time out but it's still important to let people know how they might find it useful.

iPhone Mindmapping with iThoughts

I've spoken about Mind-mapping and MindJet many times before.

MindManager is a great tool but when I'm in a short client meeting, I don't always like to pull out my notebook. For the past year, I've been using iThoughts on my iPhone and really enjoying how well it integrates with MindManager, using its innovative "transfer" capability (it creates a web server on a Wifi connection and gives you a web page to upload and download files).

MindJet's iPhone interface is remarkably similar to the iThoughts interface - almost to the point of it seeming like a direct copy or re-licensed version.

However, when my iPhone was upgraded to iOS 4.0, it also upgraded all of my applications, including iThoughts to version 3.0. The refreshed interface is wonderful - including in-line editing and more.

What impresses me the most is the integration with Box.Net, which has been around for a while. I created a free account and uploaded some of my MindManager maps. I then opened my files in iThoughts on my iPhone (no conversion necessary), made changes and synchronized. The files are all updated. I could then make changes in MindManager and sync them directly over the web.

The downside is that I can't synchronize a Windows folder with Box.Net (or if I can , please let me know how). Mesh does this via a desktop client. If I could do that, then the circle would be complete. I could modify my map on my notebook and it would sync transparently.

There are other alternatives - I could use a web-based MindMapping tool (such as Mind42), but some of these use Flash (and thus don't work on the iPhone) or the web implementation just doesn't have all the features or are too slow.

While web apps may be the future, but until they get to the point where they can match the features and functionality of the dedicated platform apps, we will need tools like box.net and others, and thankfully, they are there to fill that void.

Update: although I had heard about it for a few years, I hadn't tried DropBox - a direct competitor to Box.net. While Box.net offers some more advanced features, for what I need, DropBox is the better solution. Thankfully, the latest version of iThoughts supports both. The real benefit of DropBox is that it *does* provide folder syncing (even though it is its "own" folder - My DropBox).

The sync between DropBox and iThoughts is amazing. I updated a Map on my laptop and then sync'd one minute later on my iPhone. The changes were there. I then did the same on my Iphone - after syncing through iThoughts, the change was there on the laptop. No time lag whatsoever. That's perfect for what I need.

Tuesday, June 22, 2010

LINQ, Reserved Names and .Net

Here's another good reason not to use reserved names.

I'm working on a LINQ project with a series of tables that manage user roles. As a result, I have table names like Systems, Roles and Users.
My trouble started when I would add the objects to the Designer, hit Save and then suddenly Visual Studio would say things like

"System.Data.Linq.Mapping.DatabaseAttribute is not defined"
or
"System.Nullable is not defined"


In short, stopping me dead in my tracks. Now that I look back, I don't know why I didn't see the reason earlier.

When using the Object Relational Designer, Visual Studio wants to be smart and changes any words that are plural to singular so they make more sense when dealing with data.


That way, your code looks like

oUser = New User
oUser.UserName = "John"

instead of
oUser = New Users
etc

This is really nice because it does make the code a little more legible except in this situation:

Plural (singular)
Users (User)
Roles (Role)
UserRoles (UserRole)
Systems (System)


See the gotcha? Visual Studio translated the "Systems" table into a "System" object which immediately negated all of the main namespaces in the project.

The renaming feature for the objects in LINQ-to-SQL is great - but be warned, when you start getting errors like this, take a look at your source tables.

Friday, June 18, 2010

Intense Development: Why We Need Passionate Programmers

At a conference a few years back, I formally met someone who I had been speaking with online for a few years. One of his comments was "wow, I didn't realize you were this intense". At the time, I was surprised as while enthusiastic about the conference, I didn't think I was being that noticeable. But I will admit - I am very intense or passionate about the things I do. I think that's very important to the developer and consulting world and far too often, it's missing.

Programming is an analytical and (supposedly) fact-based process, which is why most programmers tend to be left-brained. This discernment is more myth-based (as logical sciences such as maths are handled by both) but more creative or emotional types are said to be "right-brainers".

Today, when you need both programmers and designers rolled into one (or at least combined in a single project), this can get tricky.

As a consultant, I deal with a number of clients. Some I have had the pleasure of working with for years, while others have been shorter-lived. However, I always try to find something in their work that excites me. Yes, I'm there as a "contractor", a repairman or mercenary of sorts - but without that excitement or commitment, why would I care about doing a good job?

There are arguments for why you don't want too much enthusiasm. Being more pragmatic and analytical, you may tend NOT to make mistakes (ask any programmer after a late night session if they think their code is bug free). But you may also alienate the client or worse yourself. In programming, it's very easy to become overwhelmed with the possibilities for failure and paint yourself into a corner where all you deliver is the least-risky, least-powerful piece. That's not to say that it can't be usable but it may not deliver on expectation.

Sidebar:
(there's a reason why Apple tends to either delay products or take away features - when they deliver something that they describe as powerful or impressive or "magical", they truly believe it themselves).

If you haven't seen Steve Jobs' interview at D8, watch it. Forgetting all about the conversation about AT&T, sex, Flash and Google, there's a very interesting part about what he found when he returned to Apple 12 years ago. To summarize, he found a lot of amazing and skilled developers and he asked them "why are you still here?". The common response was that they had "six-color blood", a term that throws back to the second Apple logo. Some might say that kind of passion is more of a tear-jerky look back at history, although we have certainly seen what Apple has done since then.

End of Sidebar


I would rather have a passionate programmer or consultant than anything else. When I first meet a consultant on a job, I ask what areas of work do they "love". When asked, I'm always pretty much a "data-head" - I love data and turning it into information. Others love pure coding; others refactoring, etc - why someone who loves one area would bother taking on the responsibility of another area distresses me - because it means that there is one less person who cares about the project.

Even in a hard economy, such as this one, where people are struggling to find work, and perhaps even more importantly in such an economy, is passion necessary. You have to find a job, you have to get work - if you get it, at least be excited or passionate about it. If you don't want to do it, then get out of the way. Recently, I started at a client site with a colleague of mine. While I was consulting directly for myself, he was consulting through a parent company. While his other workload was hard, he immediately saw that he couldn't do a good job at the client site because he just wasn't interested in delivering the type of solution they wanted. He left the job within two weeks. The client may have lost money during those two weeks - but at least they weren't stuck with someone who didn't care about what they were delivering.

Early in my career, I was at a company working with a team of about 4 or 5 other guys and while I was likely third in terms of being there, I was by no means the most computer-educated or technically knowledgeable. But we all had our areas that we had to work on, and there was one section that was taking longer than the others. The guy working on it had his masters in Computer engineering but just wasn't into it. He would stare at the screen and it just didn't make sense, like the Matrix falling down in front of him. What was a relatively simple task was not getting completed. At one point, I even said "I can't think for you". The project wasn't something that I had started but it was the job at hand - it had to get done and I was intent on getting it done. I was, coming back to my first story, "intense".

I refuse to apologize for my intensity or passion on projects. I think it does a disservice to the client and to the project itself. Yes, it might be a small project in the grand scheme of things (and what isn't - unless you're really changing the world), but it's still *your* project or *your* client. If you don't care, get out of the way and let someone who does take that role.

Wednesday, June 09, 2010

Ken Levy Webinar: Servoy for Visual FoxPro Developers

For those who didn't receive the invite, Ken Levy is doing a session on how FoxPro developers can work with Servoy, a java-based development tool.

You can register here.

There's also an intro screencast you can see here.

I looked at Servoy a few years back and it looked pretty cool for development. As Ken notes in his email "Servoy is a very community oriented product with passionate users reminding me of the enthusiastic FoxPro community. " Should make for an interesting demo.

WPF: Bubbling Events from User Controls

While building a WPF application, I ran into a scenario that immediately called for a bubble event. While the basic concept behind it is pretty straight forward and there are a number of examples to show it,
when I put it all into practice, it didn't work. I got it working and it's just a little tweak but hopefully no one will spend the time I did looking for it.

Bubbled events do exactly as they sound: the event fires at a very low level and then continues up the application hierarchy waiting to be "handled".

In a traditional application, you might have a method called cmdSave_Click which handles the Click event for the Save button.

A bubbled event is more akin to button groups in VFP, where you may have four buttons and when one is clicked, the code to actually handle it is managed in the button group's method rather than the individual button click.

Take that concept and expand on it further. A real-world example that I remember Steve Black once using is Help. When user hits F1, ideally the user gets help for the one object or dialog they are on. Failing that, they should get help for the basic page they are on, Failing that, they finally get help on an entire application. The Help bubbles until it is handled.

Not a very technical description but hopefully it works for you.

In WPF, they have routed events and attached events, which is when some other function or method handles another event. This is similar to a VFP BINDEVENT(), where you write a function to manage another object's event. The difference here is that you can actually create the event in the WPF component.

So in my scenario, I've created a Navigation "pane" that appears on the left side of the application. When the user clicks an item on the Pane, the rest of the application reacts to it, going to a particular report or page, or whatever. This pane is actually a WPF user control. There are other components (like menus) that do the same thing so the logic to actually GO to another page is at the application level. In good form, of course, the Navigation pane doesn't know that, it simply knows that when the user clicks an item on it, it executes an event.

The samples you sometimes see are based on code being directly in XAML (note: the "uc:" simply points to the user control's namespace) :

(note for VFP users: the "Grid" referenced here is for the actual page layout - not the traditional data grid you may be used to)


<Grid uc:UserControl.CustomEvent="ApplicationHandlerCode">
<uc:UserControl></uc:UserControl>
</Grid>


In the above code, the User control has defined an event named CustomEvent. When the user control's CustomEvent is fired (which may be from a button or another object in the user control), the statement in the Grid element tells it to execute the method ApplicationHandlerCode, which would reside in the main application (or the control where the Grid was placed).

The code here is in VB - primarily because there are tons of C# examples and oh yeah, my client requires VB.

So using my navigation pane as the example, my user control was defined as:
Class navPane
Public Shared ReadOnly NavigateEvent As _
RoutedEvent = EventManager.RegisterRoutedEvent("CustomClick", RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(navPane))

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

Me.Button1.AddHandler(Button.ClickEvent, New RoutedEventHandler(AddressOf Button1_Click))


End Sub
Public Custom Event CustomClick As RoutedEventHandler

AddHandler(ByVal value As RoutedEventHandler)
Me.AddHandler(NavigateEvent, value)
End AddHandler

RemoveHandler(ByVal value As RoutedEventHandler)
Me.RemoveHandler(NavigateEvent, value)
End RemoveHandler

RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)

Dim newEventArgs As New RoutedEventArgs(navPane.NavigateEvent)
Me.RaiseEvent(newEventArgs)

End RaiseEvent
End Event

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
RaiseEvent CustomClick(sender, e)
End Sub
End Class


The part in the RaiseEvent is the most crucial. When looking at other code samples, you will often see:

RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.RaiseEvent(e)
End RaiseEvent


For user controls, this does NOT work. You have to explicitly create a new routedeventargs instance.

RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)

Dim newEventArgs As New RoutedEventArgs(navPane.NavigateEvent)
Me.RaiseEvent(newEventArgs)

End RaiseEvent


Why is this? I'm not quite sure - it seems to me that the RaiseEvent should be able to take the passed arguments but it can't. Go figure.

At any rate, in my main application, I then created my instance (dynamically) of the NavPanel and added my handler directly to it.

Dim pnlNav As New ControlLibrary.navPane

pnlNav.AddHandler(pnlNav.NavigateEvent, New RoutedEventHandler(AddressOf GotoPage), True)


Where GotoPage was my method that handled the events.

Private Sub GotoPage(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
MsgBox("Running goto page")
Window1.txbTitle.Text = "Navigating"
End Sub


As can be seen from my msdn forum request
Bubbled Event from User Control Library Not Firing, the problem wasn't obvious but the resolution works perfectly.

Once again, the key to making it work was simply creating a new RoutedEventArgs and passing THAT. If I wanted to pass specific details, I would add those to my RoutedEventArgs.


Side Note
Now, obviously most of this was done with code. Here's one example of doing something similar but using Storyboard events from Expression Blend and code. The secret behind this is that the description of the routed event is handled as a trigger:

<UserControl.Triggers>
<EventTrigger RoutedEvent="att:Monitor.Alarm">
<BeginStoryboard Storyboard="{StaticResource ShowWarning}"/>
</EventTrigger>
</UserControl.Triggers>


And this trigger runs a StoryBoard which does animation, all from within the XAML. Very cool stuff.

Wednesday, June 02, 2010

New FoxShow: Jim Nelson Interview

In the latest episode of the FoxShow, we feature an interview with Jim Nelson, who is the main project lead on the PEM Editor project at VFPX, on his history with development and how he comes up with some of the ideas he's been putting into PEM Editor.

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
ENDIF

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"
lo.ShowLookup()

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.

Enjoy!

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
begin
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
end
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
--URL: http://www.sqlservercentral.com/scripts/Miscellaneous/30324/
SELECT o.name AS "Table Name", i.rowcnt AS "Row Count"
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND indid IN(0,1)
AND xtype = 'u'
AND o.name <> '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.

Update:
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
begin
set @vcnt = 0
select @vcnt = rowcnt FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND indid IN(0,1)
AND xtype = 'u'
AND o.name =@vtb
if @vcnt>50000
begin
print 'retrieving for ' + @vtb + ' rows: ' + convert(varchar(10),@vcnt)
exec sp_spaceused @vtb
end

fetch next from x into @vsc,@vtb
end
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:

SCHEMA.SCH_ClientName

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.

Tuesday, April 20, 2010

Developer Viewpoint: Rapid Prototyping with SketchFlow

You can see my own direct review of SketchFlow here.

This article is a great introduction to SketchFlow, which is found in Microsoft's Expression Blend.

Rapid Prototyping with SketchFlow

Unlike developer "design" tools, SketchFlow is really great at focusing on the interface and how users will interact with the application. I'm not a graphics designer so I know pretty much right off the bat, my prototype may not have the prettiest graphics designs. However, with Expression Blend, I was able to make the UI look half-decent.

It uses XAML files to show case the interface - this is extremely useful as I just grabbed some earlier work being done in Visual Studio and dropped it in - worked like a charm. I was then able to make changes to the XAML from a designer's perspective instead of a developer's.

With the SketchFlow Map, you simply draw lines to create a flow between "pages" of your application or to integrate shared components. When you build your application, it provides a SketchFlow viewer with a navigation bar on the right. You can also add animations and direct content to create more interactive shots.

Now to present it, you can do a manual presentation (F5) and walk users through it - but one of the killer features is the ability to "package" the flow and give clients an application that they can walk through on their own, see your annotations or add their own and then send you feedback directly.

I'm a big fan of usability testing and while Sketchflow certainly is more on the prototyping side, it really does let you test concepts very easily.

If you're happy with what you've done, you can actually re-use the XAML and components you've built.

The Expression Blend evaluation period is 60 days - so it definitely gives you lots of time to work with it, even just for prototyping out concepts.

Thursday, April 08, 2010

VFP Stack Overflow: What's In A Name?

In the latest issue of FoxRockX, Ken Levy has an interesting op-ed piece called the Visual FoxPro Stack Overflow. I'm not sure if the latest issue is a re-hash of the original which was posted last summer.

It's a little like the similar page on the VFP Stack, nothing all of the possible VFP projects, including VFPX, VFP Studio, etc, etc. What would you call it? The community decided a few years back that VFPX was a better term than VFP.Next. Is that still the best term?

Perhaps more interestingly in the piece, Ken noted that the FoxPro trademark was dropped by Microsoft years ago. As a result, FoxPro and VFP can be found through search engines without anything having to do with the VFP Development tool. This is where the whole concept of stack comes up. If you consider that LAMP is (Linux,Apache,MySQL,PHP), what would a better term for VFP be?

The bigger issue here for me is that how do developers "get" Visual FoxPro, without MSDN, moving forward.

If you consider the tools that are available, it might be possible to build a front-end IDE to VFP - similar to the (abandoned?) VFP Studio, that would simply run the VFP compile steps in the background. Just an idea but it certainly is doable.

One challenge, of course, would be ActiveX controls but if you look at the work being done over at VFPX, there are a lot of places where you don't necessarily need ActiveX.

While a lot of the work I do now is in Visual Studio, I'm using VFP pretty much every day as one of my tools. Building a UI or executable for just specific pieces (such as the Data Explorer) might be another useful way of using it in a day to day environment.

Are you actively using FoxPro on a daily basis? If so, chime in and get involved in the discussion.

Saturday, March 27, 2010

Carbonite and PRG files: Problem and Workaround

I've been using Carbonite for online backup for a few years now. I did try XDrive and I have earlier posts about how horrible it was.

One thing I've always liked about it is the ability to pull back individual files almost like an incremental version update. The fact that the backup drives integrate perfectly with Windows Explorer is a definite plus.

But when my laptop bit the dust recently (a <12 month old Toshiba power jack issue), I was hoping to rely on it for the restoring my files onto my new laptop. While I did have the physical drive from the Toshiba, I wanted to test it out for a full restore.

That's when I found a major problem. By default, Carbonite does not backup what it considers to be system files (EXE, DLL, COM, etc). It does backup VB, CS , ASPX files without a problem. But Carbonite considers a PRG file to be a system file. I'm not quite sure why - but it does. As a result, none of my PRG files were backed up.

As a FoxPro developer, this is tantamount to disaster. I would restore all my files and while the VFP screens and class libraries were all present - I couldn't run any of my code because it was missing a PRG file.

I contacted Carbonite about this and the first response was "sorry, we don't back up system files". What is interesting is that this post lists off the files that Carbonite considers system files.

That list is at the end of this post.

But there is a workaround.

If you highlight a PRG file and right-click, you can choose Properties. Click on the Carbonite tab and check the option to Backup Files of this type.



This solves the problem. So now, all of your PRG files will be backed up.

But what system file ends in PRG?

For reference, here is a list of all the file extensions that Carbonite will not backup in alphabetical order:

.$$$
.$db
.113
.BSC
.IDB
.ILK
.NCB
.OBJ
.PCH
.PDB
.SBR
.abf
.abk
.afm
.ani
.ann
.bac
.bak
.bck
.bcm
.bdb
.bdf
.bkf
.bkp
.bmk
.cab
.cf1
.chm
.chq
.chw
.cnt
.com
.cpl
.cpl
.cur
.dev
.dfont
.dll
.dmp
.drv
.drv
.dvd
.eot
.evt
.exe
.ffa
.ffl
.ffo
.ffx
.fnt
.fon
.ftg
.fts
.fxp
.gid
.grp
.hlp
.hxi
.hxq
.hxr
.hxs
.ico
.idx
.img
.inf
.ini
.ins
.ipf
.iso
.isp
.its
.jar
.jse
.kbd
.kext
.key
.lex
.lib
.lnk
.log
.lwfn
.msc
.msi
.msm
.msp
.mst
.nt
.obs
.ocx
.old
.ost
.otf
.otf
.pf
.pfa
.pfb
.pfm
.plist
.pnf
.pol
.pref
.prf
.prg
.prn
.pwl
.rdb
.reg
.reg
.rll
.rox
.scf
.scr
.sdb
.shb
.suit
.swf
.swp
.sys
.sys
.theme
.tmp
.tms
.ttc
.ttf
.ttf
.v2i
.vbe
.vga
.vgd
.vhd
.vmc
.vmdk
.vmsd
.vmsn
.vmx
.vxd
.vxd
.win
.wpk


Wednesday, March 03, 2010

And Then There Are The Pickles...

A little bit of fall-out from eTecnologia's apparent abandonment of the VFP.Net project.

VFPX could suffer from the same fate except that those involved are already supporting it as an open-source project.

There are lots of ways of working with VFP in .Net and in any language. I use VFP pretty much every day and it's not part of the client's arsenal - but it turns around the work I need done - be it prototypes, sample data input and more...it's faster and better than the alternatives. But it is simply one tool in the toolbox - like the screwdriver that seems to fix almost every problem - there are always times to use others.

I'll post a little more on my own experiences but Hank's post here is very telling. We've heard about VFP Studio and also now about VFP.Net - in both of these cases, it might have been better to open source the two.

ProSysPlus Blog: And Then There Are The Pickles

Monday, January 04, 2010

Disrupting the Business Application Market Place

This will likely be the year that Apple unveils a tablet-based PC. Nothing innovative in that - Microsoft has had Tablet XP and Vista for years and Scoble used to schill those as well.

My thoughts on the consumer aspect can be found here.

There is a bigger issue that developers need to pay attention to.

Since the tablet will use a similar form factor (as reported right now) as an iPhone/iPod Touch, the tablet will likely support existing iPhone apps. So unless "full screen tablet apps" cost more than regular apps, Apple will need to change the entire pricing model for existing tablet style applications. When someone built an application for the Windows XP Tablet, it would be priced just like an existing Windows based application, so about $200-300. MindManager, for example, cost $395. The iPhone version costs $7.99.

It will have to hit a lot of users to match the original price.

Apple revolutionized music pricing with iTunes and even though the tablet may change the print or publishing industry (which Apple already did back in 1986), how it affects regular apps could become critical.

There are some arguments that if the tablet is focused on the print industry, then the disruption has already happened with Amazon's Kindle but the tablet isn't supposed to be "just" an e-reader, if one at all.

Apple certainly doesn't mind being disruptive - in fact, it's built its reputation on it. There are also some benefits in creating different pricing models. Changing the tablet/publishing pricing model would effectively show that a tablet isn't the same as a regular PC and therefore it should be priced differently. It might also force developers to focus on making application features specific to a physical form factor instead of the current "throw it all in" approach.

But the iPhone has also changed how people perceive apps. Why pay $200 for a GPS when you get the same results with Google on your iPhone? Why pay for traffic subscription services when you get it for free with the INRIX app?

How and when this perception moves into the business application world could cause some major disruption.

Should you build applications based on unique features that integrate with others? Or try to put it all in yourself? In my experience, most businesses want everything integrated and the best way to get that is usually from a single source. But that may change, especially with a device that isn't just a phone but a possible business changer.

Has the Surface disrupted the industry yet? No, but Microsoft is reportedly working on more of a consumer or smaller version. But how would a "single-location" multi-touch PC compete against a portable version? I don't think it can.

I also don't buy the whole "Internet Net-book thing". Internet applications have come a huge way in the past few years - and the fact that you can skin your regular web sites to look like iPhone apps is useful too, but I believe that the form factor of the tablet will also bring about at least one "killer" feature, one that is not easily reproducible on the web of today (tomorrow is another day). The current alpha version of Chromium isn't there...yet.

I'm excited about what these changes will mean in 2010 and beyond but just as intrigued about what happens when these changes hit the business application development space.

As a developer, the next time you look at your application, instead of trying to make it run on as many platforms at once, try to envision a specialized version for a given form or input factor.

What would you change to make your application run on:

a) an iPhone or SmartPhone
b) a touch-based desktop computer
c) an audio-only implementation
d) a web-only version
e) a flat 10 screen multi-touch