Thursday, March 5, 2009

Source Code Doesn't Lie #4: UI Framework Layer

The source code challenge creating a UI framework layer

The Winner - Visual FoxPro

Score card through 4 coding challenges:
The Legacy Visual FoxPro 4
The Great Visual Studio 0


Let’s start with a brief overview of what N-TIER design entails.

An n-tier application is one where the application is split into logic sections. These sections are the user interface tier, the middle tier where the application business rule along with data access programming resides and the data tier (the database). While all the tiers may reside on one or two computers or servers this model allows the application to be “scaled” to improve performance. In other words the user interface may reside on the client’s workstation or in a browser, the middle tier could utilize its own application server and the data tier would have its own server.

There are numerous benefits to this programming model besides scalability, for example the same middle tier and database can be accessed by both a web based interface or a client application interface. This means all the middle tier code and the database is shared instead of writing the code twice. Moreover a framework can be implemented to further reduce programming by creating a baseline of generic programming (classes) which the application is based upon. By employing a framework in conjunction with N-TIER design patterns we are able to create an application that is scalable, easy to maintain and provides a consistent programming model for maintenance along with a consistent user interface.

The most common mistake a programmer (and Microsoft for that matter) makes when trying to implement this design pattern is to place code that really belongs in the middle tier in the user interface tier or to access the database directly from the user interface layer.

Now that we have a basic understanding of the N-TIER model let’s move to implementing the classes that would be required by the user interface layer for a Visual FoxPro application and a winform application. I must be in a good mood tonight as using Winforms will paint Visual Studio in the best light. Microsoft royally screwed this model up in WPF and a comparison with Visual FoxPro would not even be close in terms of code and ease of implementation. On a side note: Yes they failed with Webforms and MVC as well .

Are you ready to develop a framework UI layer at light speed with Visual Studio 2008 and .BLOAT?

The first step is subclass the native development controls into a UI framework class. To keep things simple we will subclass a form, label and textbox class. Let’s start with Visual FoxPro, this step requires zero coding we simply use the class browser. As you see in the screen shot we have a base UI framework layer that is ready to use in our application. This took less then a minute to build.

Now let’s perform the same task in Visual Studio. First off you can’t subclass UI controls in the class browser therefore we have to hand code each class. In order to save some code in Visual Studio - which I really freaking shouldn't - I will exclude the code necessary to workaround bugs that are related to setting default proprieties in the subclass that get jacked by the property sheet.

Now here is the Visual Studio Code that was NOT required in the legacy Visual FoxPro base framework layer.

//FOLKS: This is the Microsoft money section it forces your client to use the windows
//operating system. Steve and Bill count the dollar signs each time they see a
//USING system in your code.
using System;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;

namespace UILayer

//Since VS doesn't have a class browser that works
//or an ide with code windows we need regions to keep the code manageable
#region forms

//Why in the hell do I have to add an attribute to my class that
//tells the great Visual Studio what icon it needs to display in the toolbox for the class?
//The ide freaking knows it is inheriting from a textbox. It should display a default
//textbox icon then allow us to override it as needed.
//In VFP a property sheet could have been used and no coding would be necessary


public class SampleForm : Form

public SampleForm()


//Blah, Blah Blah the same crap not exciting but it is code we should not have to write!
//All that should be required is us setting proprieties and the business logic.
// yes this is plumbing code!

#region textboxes
public class SampleTextBox : TextBox

public SampleTextBox()


#region labels
public class SampleLabel : Label

public SampleLabel()



It is obvious FoxPro requires less work as the more we keep adding to this model the worse things get for Visual Studio. Adding methods, proprieties and inheritance are all done in the class browser visually with the legacy FoxPro and using the Microsoft's Latest Technology Visual Studio 2008 with 70k class of bloat in .NET this it is all done in code.

If this nonsense was not bad enough; let's say for example you decide to use the wizards in Visual Studio instead of using subclasses, guess what happens? (Don't think this wizard code is not used in the field I see it all the time in applications). Anyway back to my point guess what occurs, I will tell you, a WTF MOMENT occurs - that is what. The visual studio wizards embeds data access code into the user interface layer, not only do we lose the value of inheritance and have duplicate code everywhere, the foundation of N-TIER design is broken by code generated by Microsoft!

Even the Visual Studio Cheerleaders will try to spin this extra work as a positive, below is an excerpt from code magazine…

“...Subclassing the base .NET Windows Forms controls is different from VFP because developers must write code to do so. You cannot subclass visually, but the process will provide good exposure to the language and the .NET Framework.”

What the hell are they talking about, they can't think we are that stupid - Let's read it again -

“...Subclassing the base .NET Windows Forms controls is different from VFP [hell yeah it is it is alot more freaking work in Visual Studio] because developers must write code to do so [which in any worthwhile tool we shouldn't have to]. You cannot subclass visually, [no shit thanks for pointing out the obvious, they should have mentioned due to the fact the visual studio class browser sucks] but the process will provide good exposure to the language and the .NET Framework.”

Yes I read it correctly, they wrote "this process will provide good exposure to the language and the .NET framework" - are they freaking joking me?!?!? Here is what I have to say to the code magazine Visual Studio cheerleaders “SCREW THAT”. This is a major bug in Visual Studio call it exactly what the F&$K it is!

I hate to do this I really do, but we have to dig deeper into this idea of "providing good exposure to the language and the .NET framework".

First off I need to ask this, how many freaking times during the application development process do we need to WASTE time getting "good exposure to the language and the .NET framework". WTF - With all the code we have to write in Visual Studio do they think we are going to forget? There is less typing involved in a Mavis Beacon teaches typing dvd. This is a perfect example of what I have been saying all along folks, cheerleaders will do or say anything to hide the truth of Visual Studio.

Secondarily please stop calling .NET a framework. .NET is NOT a framework. For the most part Microsoft took the Windows API layer and wrapped it in classes - that is all the majority of .NET is. Moreover a portion of .NET is based on outdated legacy technology that has been around since early version of windows, yes before Visual FoxPro. There are basic principles of framework design: I will pick 2 general ones everyone can understand, a framework should eliminate code redundancy and a framework should provide a consistent way of coding. How in the world do we have a consistency in .NET when there is class redundancy everywhere, for example we have 6 bad ways of accessing data alone, that is not eliminating redundancy that is BLOAT! If .NET fails the first two general tests required to be considered a framework then it is not a framework!

Getting back to their quote "good exposure to the language and the .NET framework", If we apply their logic for minute to a car, would anyone want to push a freaking car instead of drive one because the car maker failed to design the engine correctly? Your answer would be NO - but a cheerleader would say that is fine because it would provide good exposure to fresh air. Yes, this is as freaking unbelievable as it sounds, and that is the idea they are trying to sell us on.

The bottom line is Visual Studio is so bad and unproductive it can not be defended using rational arguments so cheerleaders invent crap like "exposure to the language". The pathetic part is, believe or not, these people (and I purposely left out their name) are good programmers, why they insult their intelligence time and time again for Microsoft and Visual Studio is mind boggling? Here is a thought, they want to help the Visual Studio community, then in their next issue of code magazine demand Microsoft give us tools so we can get our work done in the most productive way possible, freaking get some balls and point out the bugs. Look, if you don't have the balls to speak the truth for fear of biting the hand that feeds you, just direct your readers to my website and I'll do it.

I will break down what I think transpired, Microsoft was smart when they issued the end of life of Visual Basic and Visual FoxPro in this respect. Before Microsoft killed these solid products Microsoft grabbed the more respected cheerleaders in each community and promised them 75 virgins besides Vista Ultimate to spin Visual Studio. Microsoft was betting that the Visual Basic and FoxPro development community would blindly take the advise of community leaders and just follow along. (Well it wasn't the virgins, actually most got offered jobs in Redmond then disappeared into the woodworks-I should find Griver's letter to the VFP community on the end of life and analyze that to prove my point) . Then with the Visual Studio community, Microsoft didn't want non-microsoft employees leading the development community so they created the Microsoft Evangelist network, these are the A-team cheerleaders that spin visual studio. You know what, sadly for us, this plan worked perfectly. Developers are listening to the cheerleadering squads, which is exactly why we are stuck with this crappy bloated bullshit platform to write applications with. I have said it all along Microsoft may not release the best software (With Vista and Visual Studio I'm being nice) but they are smart when it comes to business.

Ok I will get off my soap box, well there you have it another code challenge and Visual Studio lost again to Visual FoxPro. It is time to move off the class browser, inheritance and User Interface Layer for the time being as the Visual Studio suck factor is obvious. In the next installment of source code doesn't lie I will put LINQ-TO-SQL up against VFP'S native data centric language. Perhaps we can develop at light speed when creating middle tier components that perform basic business processing.

By the way if you haven't checked out the Ms. Fox Pro (Ms. means female not Microsoft) video, do so, it is posted on my blog and also my facebook page.

Until next time, be productive Developing at Bloat Speed!



foxguy said...

These are great posting ! Your comment about code magazine would be funny if it wasn't so true.

Anonymous said...

You mentioned an n-tier application, where a web app can hit the middle tier. Could you illustrate how Fox Pro could implement such an application?

Camil Ghircoias said...

This article is like honey, thanks for it.
But our future seems to smile on us.
The new made by is bringing vfp back on market. And will be "educated" like .net but with all vfp sexy thinks we like.
By the end of the year they said the first commercial version will be out of the box.

Boudewijn Lutgerink said...

Nice one. I am sure you will like the possibilities eTecnologia is now creating in their NetCompiler for VFP.