Procedural Epistemology Thinker RSS 2.0
 Monday, February 11, 2008

Even though ScottGu and others have written about ASP.NET MVC I figured I’d add a series of notations about URL Routing, Controllers and Controller Actions, Rendering Helpers and Understanding the Model.

Who knows maybe the way I explain it will drive the point home.

Part 1 is just my overview of the ASP.NET MVC Framework

ASP.NET MVC Framework (Part 2): Understanding URL Routing

Background

WebForms

In ASP.NET Forms we used Server controls that must appear between a <form> tag. Each server control had to use a runat=”server” attribute to tell the server to process that form on the server.

ViewState

In classic ASP when forms were submitted all form values were cleared. Unfortunately if the form had an error then you lost all that information you submitted. In ASP.NET the form is able to return with all the form values.  ViewState is a way for the server to know the status of the page.

                Event Driven Programming

ASP.NET objects (server controls) on the webpage exposed events that allowed a programmer to process ASP.NET code. By having a Load, Click or Change event handled by code made coding much simpler and much better organized.

                ASP.NET 2.0

In ASP.NET 2.0 we received Master Pages, Themes and Web Parts, more server controls for navigation or security. The provider patterns for Roles, personalization or memberships, etc .

MVC Execution Process

With ASP.NET MVC Framework a web request now passes to an UrlRoutingModule object (HTTP module) which is then parses and a route is selected. Then an MvcHandler take the object and selects a controller instance that will call that controllers Execute method.

 

Stages of the Mvc Web Project

 Initial request

 In Global.asax file, routes are added to the RouteTable object

 Routing

 The UrlRoutingModule creates the RouteData object. RouteData is used to determine which controller to request and which action to invoke

 Map to Controller

 The MvcRouteHandler handler attempts to create the type name for the controller, based on data in the RouteData instance

 Invoke ControllerBuilder   

 The handler calls the global static CreateController method of the ControllerBuilder class, obtaining an IController instance.

 Create Controller

 The ControllerBuilder instance creates a new controller directly, or uses a IControllerFactory object to create the controller

 Execute Controller

The MvcHandler instance is added to the context and calls the controller’s Execute method.

 

 

 So instead of Event Handlers we now have Controller Classes and instead of ViewState exposing certain sequences of events for programming, we now have full control over the behavior of an application.

 

Default Naming Conventions

 Pretty simple, if you have a controller name it UrlPathController  this is so the UrlRoutingModule and MvcHandler can determine which controllers to invoke. Any controller class has to implement the System.Web.MVC.IController. By implementing this IController you will gain access to using the [ControllerAction] Attribute, which we’ll get into next writing.

 

Mapping URLs to the Controllers

        MVC Framework has a default URL convention it follows to map URL’s. The syntax is:

                     URL = [Controller] / [Action] / [id]


      This means your URLs will look like: 

http://domain/site/controller-name/action-method-name/parameters

   NOTE: If you see a controller-name.mvc this is required for anybody running IIS 6.0 as their web server

Global.asax

This file is used to define route mappings. You do this in the Application_Start event. The syntax is:

      // Note: Change Url= to Url="[controller].mvc/[action]/[id]"

      // to enable automatic support on IIS 6.0.

 

      RouteTable.Routes.Add(new Route

      {

        Url = "[controller]/[action]/[id]",

        Defaults = new { action = "Index", id = (string)null },

        RouteHandler = typeof(MvcRouteHandler)

      });

 

      RouteTable.Routes.Add(new Route

          {

            Url = "Default.aspx",

            Defaults = new { controller = "Home", action = "Index",

                id = (string)null },

            RouteHandler = typeof(MvcRouteHandler)

          });

 

This is saying Add a route to the RouteTable which lists my controller and action. Notice you are not required to give it a parameter or id initially.

Here are some example URLs to drive the point home:

URL   

 RouteData object values

 /domain/site/blog 

 Controller=”blog”, Action=”index”, id=null

 /domain/site/blog/ShowEntry

 Controller=”blog”, Action=”ShowEntry”, id=null

 /domain/site/blog/ShowEntry/20

 Controller=”blog”, Action=”ShowEntry”, id=”123”

Next blog we’ll get into the Controllers and Controllers Actions.

Monday, February 11, 2008 10:52:29 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
MVC | Technical
 Monday, January 28, 2008

Hooray to MS Press who has put together a Free E-Book that includes excerpts from these 3 books.

The free e-book includes content from three recent publications from Microsoft Press:

Introducing Microsoft LINQ by Paolo Pialorsi and Marco Russo (ISBN: 9780735623910)
This practical guide covers Language Integrated Query (LINQ) syntax fundamentals, LINQ to ADO.NET, and LINQ to XML. The e-book includes the entire contents of this printed book!

Introducing Microsoft ASP.NET AJAX by Dino Esposito (ISBN: 9780735624139)
Learn about the February 2007 release of ASP.NET AJAX Extensions 1.0, including an overview and the control toolkit.

Introducing Microsoft Silverlight 1.0 by Laurence Moroney (ISBN: 9780735625396)
Learn how to use Silverlight to simplify the way you implement compelling user experiences for the Web. Discover how to support an object-oriented program model with JavaScript.

I haven't read it yet, but it's free so no complaining.

Learn more about it here.

Monday, January 28, 2008 10:05:55 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
AJAX | LINQ | Silverlight | Technical
 Monday, January 21, 2008
Although this isn't techincal. I have to show it off anyway.

My buddy from college made me and my wife this painting. Its called "Misty Lake"




The artist name is "Scot Vorwaller" If interested you can find his artist blog here: http://vorwaller.blogspot.com/ He gives a very fair price for his paintings.
Monday, January 21, 2008 2:18:23 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback

 Friday, January 11, 2008

I feel that I would have to break down each Technology and pit them against each other, so here is how I will begin.

 

ASP.NET/C# VS Zend/PHP

 

1.       ASP.NET has the .NET Framework while PHP has nothing like it.

a.       .NET Framework has Two main parts:

                                                               i.      Common Language Runtime(CLR): The CLR can run code written in any language that’s adapted to .NET (VB.NET, J# and C#) it can run on any operating system that has a version of the CLR. Like Java that doesn’t have to be written in Java.

                                                             ii.      A hierarchical set of class libraries (Think PHP functions + the PEAR libraries and it extends them a lot, and have them organized in a nicer hierarchical structure). Included in those class libraries are ASP.NET (templating system), ADO.NET (a data access system), Windows Forms (classes for building windows apps), XML/XSLT frameworks (Code Generation), WCF (Built-in Web Services), Expression Framework Classes (Designer Framework), WF (Workflow Framework)

b.      ASP.NET uses a templating system on steroids called Web Forms which uses its runat=”server” attribute which gives you server side controls. Which run on the server giving you many more events, more possibility and more security. There is DaDaBIK but it doesn’t come anywhere close.

 

Performance Tests

 

c.       This person used the .NET Framework in C# Mono, but they are the same.
http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=csharp&lang2=php

  

2.       Speed

a.       .NET languages are static typed meaning they are compiled into assemblies making them 2/3 time faster than PHP, whose applications are interpreted. To achieve the same effect with PHP, Zend and PHP accelerator must be installed on the server. I’ve done this and ran performance tests and ASP.NET is still faster by a large margin. Also OOP is much faster in ASP.NET than it is in PHP.

b.      For Performance Speeds on C#: http://dada.perl.it/shootout/csharp.html

c.       For PHP: http://dada.perl.it/shootout/php.html

d.       

 

3.       More Language Support

a.       ASP.NET is written using "real" OO (Object Oriented) programming languages of your choice. PHP is just a simple scripting language in comparison to .NET languages like C++, VB.NET or C#.

 

4.       Much better Development Environment

a.       Visual Studio has multiple Integrated Development Environements (IDE’s) for the different roles you play in development (Database Admin, Tester, Developer, Project Manager, Business Analyst). Just a few of the things you can do:

                                                               i.      Automatically create reports and diagrams from your database

                                                             ii.      Debug the code line by line, while at the same time seeing what happens in the application as well as typing in a command window a variable and seeing what the results of that variable is, or calling a function in the command window.

                                                            iii.      Assign temporary value to variables in the middle of execution, in order to test out different scenarios.

                                                           iv.      Hover the cursor over variables in your code while debugging, to see what value they have “right now”

5.       It’s Part of .NET

a.       ASP.NET is a part of .NET, and that benefit is too large to simply ignore. If you know how to write ASP.NET applications, you know how to write ordinary applications too. Even windows apps, if you read up a little on the Windows Forms classes (as opposed to the Web Forms). PHP has PHP-GTK, but it's currently very immature compared to .NET.

 

6.       Reusable Codebase from Performance Pro 2

a.       If there is anything we want to use from Performance Pro 2 that we don’t really need to change, we have only to add the .asp file or files wrap it up in a COM Component and ASP.NET can access it and use it as if the code was already written. We can’t wrap the original codebase in PHP without rewriting it.

 

7.       At this point it’s cheaper

a.       We have the licenses for all the server software, the hardware for at least half of everything we need as well as the developers of strong skill sets already in house. We spend a lot of money already towards consultants for .NET and put a lot of effort into designing Performance Pro 3 for ASP.NET. If we go the other route we need to hire more experts, other developers, new hardware, new software. Most companies move from MySQL to Oracle as they grow and Oracle is very expensive.

 

Most PHP developers end up just justifying themselves by stating well I’m capable of building this feature or that feature. It’s a programming language of course you can build it. They also state there is this and that company that does it. But that costs more money, while these things are built into .NET. The difference is in productivity, we move to market faster, and the application performs better using the right technologies.

 

Here’s another link to Benefits of .NET Framework that I’m not even listing:

 

http://www.tometasoftware.com/benefits_of_net.asp

 

 

MSSQL VS MySQL (7 Reasons to Use SQL Server)

 

1.       Full Server Side Integration

a.       Full server side integration with the .NET Framework (LINQ to SQL , LINQ to XML)

2.       SQL Server has much much more advanced features over MySQL

a.       SQL Server just flat out has more advanced features then MySQL. SQL Server is a Sybased-derived Engine and Microsoft has just focused on using and expanding that infrastructure. MySQL is an open storage engine which uses InnoDb, BerkleyDB, MyISAM and Heap. Which they have struggled with design because of these multiple choices.

3.       XML is a native type within SQL Server

a.       Allows a DBA to modify an XML doc within the DBMS environment, query the document and validate it against XML schemas without having to DB Program it.

4.       Cheaper

a.       We are already have a SQL Server 2005 Enterprise Edition x86. Bought and purchased. MySQL AB would us more money.

 

5.       Security

a.       SQL Server 2005 has been certified as C-2 compliant and fully supports security at the column level. It also supports native encryption and obfuscat’s(intentionally, very hard to read and understand) the DBA from writing user-defined functions using column encryption APIs. A DBA also has the choice of specifying his own user-defined security functions through the encryption facility implemented in the .NET Framework

b.       MySQL has basic security at the table level and has no such certifications.

 

6.       Recovery

a.       SQL Server is more failsafe and less prone to data corruption. They have robust  checkpoint mechanisms, enhanced data protection, rapid restorations, Mirrored backups and partial backups instead of sorting through entire full backups.

b.      MySQL falls short with a default MyISAM mechanism. The UPS assumes uninterrupted data, and in the event of an unexpected shutdown your data can be lost and the data store corrupted.

7.       Most move to SQL Server or Oracle anyway

a.       Through my experience most move away from MySQL anyway because it just doesn’t meet the demands of today’s very rich artifacts of data. Such as (Media, Pictures, Audio, XML etc)

 

 

This would be considered a persuasive argument for those of you that take the critical thinking or english classes that teach it. ^_^

Friday, January 11, 2008 4:41:22 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] - Trackback
Architecture | Business | NET 3.5 | Technical | Article
 Wednesday, January 02, 2008

The Microsoft Patterns & Practices team in May 2007 has released the Enterprise Library 3.1. The Enterprise Library is a collection of application blocks. These are reusable software components designed to help a developer with the common development challenges you face between projects you work on.  This release of the Enterprise Library includes two new application blocks, a software factory for creating application blocks and providers, and other new features and enhancements.

Benefits

The Application blocks help address the common tasks we do every project. Caching, Validation, Data Access, Factories, etc. Microsoft has encapsulated these best practices for .NET applications into the Enterprise Library so that they can be added to your projects quickly and easily. 

Goals

The goals of the Enterprise Library are the following:

  • Consistency. All Enterprise Library application blocks feature consistent design patterns and implementation approaches.
  • Extensibility. All application blocks include defined extensibility points that allow developers to customize the behavior of the application blocks by adding their own code.
  • Ease of use. Enterprise Library offers numerous usability improvements, including a graphical configuration tool, a simpler installation procedure, and clearer and more complete documentation and samples.
  • Integration. Enterprise Library application blocks are designed to work well together and are tested to make sure that they do. It is also possible to use the application blocks individually.

I'll update this with more as I learn more.

You can find it here:

http://www.codeplex.com/entlib

Wednesday, January 02, 2008 7:18:39 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Architecture
 Wednesday, December 26, 2007

Internet Explorer has cool add-ons which make the job of website designers and developers much easier. Here is my list of 20+ excellent IE  add-ons that every web developer and designer should know about.


Internet Explorer Developer Toolbar
 Variety of tools for quickly creating, understanding, and troubleshooting Web pages.

IE Watch
Allows you to view and analyze HTTP/HTTPS headers, Cookies, GET queries and POST data.

IE Web Developer
Allows you to inspect and edit the live HTML DOM, evaluate expressions and display error messages, explore source code of Web page and monitor DHTML Event and HTTP Traffic.

IESpy
Allows one to inspect or manipulate the DOM of any IE Web browser control.

DebugBar
Brings new services to surfers and professionals. Surfers: zoom, direct Web search, e-mail page screenshots, and color picker. Developers: view HTML code, cookies, JavaScript, HTTP/HTTPS headers, and miscellaneous information.

Virtual Machine
Allows you to view java applets on Web pages.

Microsoft Fiddler
Logs all HTTP traffic between your computer and the Internet.

Tangram Xtml Designer
Visual designer for IE Band Object, activeX Control and .NET user control.

Http Watch
 HttpWatch shows you HTTP and HTTPS traffic from within IE allowing you to quickly debug, fix and optimize your Web site.

Embedded Web Browser
The package contains all the programmer need to extend the development of a Web browser.

CGToolbar
Must have tool for CG Artists, Animators, VFX and 3d professionals.

Site Studio 6
Build rich content Web sites, with no HTML skills required.

Haptek Player
 An ActiveX control and Netscape Navigator Plugin that allows any webpage or application (with ActiveX support) to include Haptek’s Autonomous characters.

Flash2X Flash Hunter

Save Flash movies from web pages.

iOpus iMacros
Check the same sites every day,data upload, online marketing and functional testing and regression testing Web sites:

Telerik RadToolBar
A flexible component for implementation of tool and button strips, needed in most web applications.

UltraEdit-32
Powerful Text, HEX, HTML, PHP and Programmer’s Editor.

Bytescout Post2Blog
 Freeware powerful blog editor for WordPress, Typepad, MovableType and other blogs.

Search Monster
Free Flash Web Directory & Internet Search Engine is the Flash-remoting Web directory instant content for you Web site.

Zend Studio
Encompasses all the development components necessary for the full PHP application.

DbaBar
Integrated toolbar enabling Oracle Database Administrators to browse their databases from within Internet Explorer within minutes after installation.

Explorer Toolbar Maker
lets you create your own Explorer bar from any HTML page, picture, Macromedia Flash file, or Microsoft Office document.

Wednesday, December 26, 2007 8:58:52 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Internet Explorer
 Friday, December 21, 2007
Scott Hanselman release links to the .NET 3.5 Extensions in action. I just want to say the Dynamic Data Website is AWESOME!.

http://www.hanselman.com/blog/HowToNewASPNET35ExtensionsVideoScreencasts.aspx

Friday, December 21, 2007 5:45:32 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
NET 3.5
 Tuesday, December 18, 2007

Whiplash

I want to identify a major problem I see with companies that are spiraling out of control. So feel free to add this to your Risk Analysis.

History

Big Bad Wolf Company is a company of 70 employees. They have a cash burn of 550k a month. The company has been in the red for 5 years and they have 250 customers. They offer an online patient portal system for clinics and hospitals to track Electronic Health Records. The company has so many bugs in the system that the developers can only afford to do High Critical or High issues with virtually almost no time to develop anything new.

Big Bad Wolf Company was targeting a niche market and was ever changing its company strategy. In any business you run it’s important to be able to shift your company strategy to meet the demands of any industry. Many successful companies of today have done this and if they had not, then they would have gone out of business or they would have stayed in the “living dead” category. (Where business just make enough to plateau but no longer have any growth.)

What fixed the problem of Big Bad Wolf and made them a successful company?

Problem:

The Executive team continually shifted strategy every three months, they continued to bring in a new COO who had his/her own ideas about where the company should and shouldn’t go. During which time each COO came in, assessed the company problems, proposed new solutions which included new technologies to get them from “here” to “there”. So begins the hiring of new employees with these skillsets and conversion of older products to meet the demand and fill in the gaps of the new products. Old time employees became obsolete except to maintain the “legacy” system, Managers were retrained towards the new strategy, etc.

Bottom line: If you find that every project you start at your company never gets finished and you continually start a new one and then a new one. You might be living the world of Big Bad Wolf Company.

Here is an image of a company’s strategy and how it flows:

 

As you can see the plan is made by the executive team with them in the middle of the company. The plan flows out to each member until finally reaching the developer. The waterfall effect: Executive à Middle Manager à Business Expert à Developer.

I apologize for my crud drawing as I didn’t want to put all my time into the image. There is more to the process then just my titles I’ve listed here but everybody pretty much breaks down into these categories. (From my perspective).

Later the company changes strategies and the image might look like this:

 

The open arrows represent the new strategy. But as you can see there is a disconnect between middle management and the business expert, which in turn affects the developer.  Given only one strategy change this might not be as bad of an issue as you think. But as time goes by and more strategies are introduced the employees on the outside of this image get the Whiplash from the changes.

So as a saying that I’ve picked up in the industry is this:

“If you ever find yourself in a hole….Stop Digging!”

Solution Ideas:

  1.  Foster Open Communication: Make sure the left hand knows what the right hand is doing.
  2.  Buy into a Common Vision: Make sure that your team has cohesion and everybody knows what they are doing on the project and what other people are doing on the project. Make sure they all buy into and understand the needs.
  3.  Accountability and Responsibility: It’s way too easy in today’s workforce to “ride” on the wings of others. Each team member should be defined in what role they are to play for the vision.
  4. Expect Change: understand that change is going to happen and plan for it, you can do this by risk analysis meetings.
  5. Push for Quality: Quality is relative, each day a product or service could be getting better or worse. But it will never stand still
  6. Learn: “Those who do not remember the past are condemned to repeat it.”
Tuesday, December 18, 2007 6:12:15 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Business | Risks
I’ve used a lot of open source projects to get my development done. Just recently I’ve moved into the Microsoft world products and I have to say that I am very impressed. Here’s is my designed company setup. Also note that I only highlighted the important parts of the installations that were different from default. Unless listed here as explicitly changing you should go with the default.:

Setting up the Development tools: (in order)

  1. Setup a different server as our File Share Server and installed Active Directory on that computer.
    1. Created the Domain accounts: TFSSETUP, TFSBUILD, TFSPROXY, TFSREPORT, TFSSERVICE.
    2. One domain for each differnet service that Team Foundation Server will use permissions for.
  2. Loaded  Windows Server 2003
  3. Download and installed all updates for Win2003

Installing SQL Server 2005 

   I work at a smaller company so I have plans to install TFS Single Server installation. Below are the highlighted steps.  

    1. Install all components. Sql Server Database Services, Analysis Services, Reporting Services (Not required but I recommend: Integration Services, Notification and Workstation Components, Books Online and Development Tools.) This is so you can get the SQL Server Management Studio installed.
    2. On Service Account page, "click use a domain user account"
      1. In the Username Box, type the name of the Active Directory (AD) account. (for example, TFSSERVICE).
      2. In Start Services select all the check boxes available: Sql Server, Sql Server Agent, Analysis Services, Reporting Services, and SQL Browser
    3. For Authentication select Windows Auth Mode.
    4. On the Report Server Installation Option Page, click Install but do not configure the server.
    5. The rest just use default settings.
    6. Download and installed all updates for SQL Server 2005 Updates.
    7. Open up Sql Server Management Studio
      1. Connect to Server
      2. Open Security Folder
      3. Right Click on Login --> New Login
      4. Login Name Find TFSSERVICE or whichever you used on the Service Account Page.
      5. Select "Server Roles" on the left.
      6. I just made mine a sysadmin and a few others.
      7. Save

        The reason why you want to do this is to give the right permissions to these accounts to be able to modify and access the data in the database for Team Foundation Server. Many people have had permission problems, this is one of the places you can go and fix this. The ones I added as sysadmin are: TFSSETUP, TFSSERVICE, TFSREPORT

Installing SharePoint Server 2007

Installed Microsoft Office Sharepoint Server 2007 (MOSS 2007): Sharepoint will generate a website for your business needs. 

    1. On the Choose the installation you want page, click Advanced.

    2. On the Server Type tab, click Web Front End.

    3. (Optional) On the Feedback tab, specify an option. For more information about the program, click the link. You must have an Internet connection to view the program information.

    4. Click Install Now.

      When the Setup wizard finishes, a dialog box appears that prompts you to complete the configuration of your server.

    5. In that dialog box, be sure that the Run the SharePoint Products and Technologies Configuration Wizard now check box is selected.

    6. Click Close to start the configuration wizard.

    7. On the Welcome to SharePoint Products and Technologies page, click Next.

    8. On the Connect to a server farm page, click No, I want to create a new server farm, and then click Next.

    9. On the Specify Configuration Database Settings page, perform the following steps:

      1. In Database server, type the name of the server that is running SQL Server and which you will use for Team Foundation Server. If you will use a named instance, add its name after the name of the database server, separated by a slash (for example, MyDatabaseServer\MyInstanceName).

      2. In Database name, type the name of the database that you want to use, or accept the default value.

      3. Under Specify Database Access Account, in Username, type the name of the user account that you want to use as the service account for Windows SharePoint Services.

        You can use the same service account that you will use for Team Foundation Server (referred to as TFSSERVICE).

      4. In Specify Database Access Account, in Password, type the password for the service account.

      5. After you fill in all the required information, click Next.

    10. On the Configure SharePoint Central Administration Web Application page, select the Specify port number check box, and type the port number that you want to use for Windows SharePoint Services administration. Make a careful note of this port number for your records, because you will need this information when you install Team Foundation Server.

    11. In Configure Security Settings, click NT