jQuery
Toolset 2009
Most of my work so far this year has been with one client. This client was a Java shop for quite some time and is pretty green to Microsoft. Also, they don’t seem to ever have had real success with building enterprise class systems. That’s not to say that they haven’t wrote very large and very complex systems. They have done it all with either the bare minimum in tooling or a incorrect implementation of the tooling.
In fact; one of their primary reasons for moving to .NET was to perform a tooling reset. They decided it was too hard to use technology like OR/M, DI, Messaging, and MVC. The figured that (straight from the horse mouth) “Webforms, ADO.NET and SQL” is all we need. I don’t even understand that statement…anyway…back to the tools
Of course I believe this is all based on the improper use of technology. As they say “Any tool can become a weapon if held properly”. unfortunately for me and future developers with this client. The technology that was so frond upon is the tool that….um…well…never mind.
All I am trying to say is that I’ve been pretty tied into some specific Microsoft technology most of the year. Most of the tools on this list had to pass through a standards committee meeting and some are still under the radar…Ok on with the tools!
Visual Studio 2008 (2005, Visual Basic, Dreamweaver)
Thankfully most of my work is new development so I spend a bulk of my time in Visual Studio 2008. Unfortunately is not TFS so my task tracking is handled outside….if at all. Also there are no productivity plug-ins available, I even asked if I could install my own…so no ReShaper or Visual SVN
ASP.NET 3.5 SP1 VB.NET
With most of my work new development I do get to keep up with the .NET version. I am REALLY looking forward to .NET 4 (its just 4 right?…I heard someone from MS flies out and you get your hand slapped if you call it 4.0)
ASP.NET MVC
Yeah! what more can I say.
ASP.NET MVC Futures
This one has not passed through the development standards committee yet but since I also sit on the committee I don’t think it will be much of a fight. Really I only use it for Html.RenderAction
WCF
The tooling is rough but the technology is solid. I am really happy with WCF and hope it infects my clients….but I feel that will stick with asmx for a few more YEARS….
EF
I am just not ready to fight for Nhibernate just yet…I have a new project starting around the 20th, as with every new project I try to push through one new technology. I think this one will finally get a OR/M.
I do like where MS is going with EF and look forward to EF 4, isn’t that what its called in .NET 4.0?, but as much as I work with EF 1 ….man its rough. I’ve often considered using Linq2Sql and building on top ala Rob Conery’s MVC Storefront.
AutoMapper
A convention-based object-object mapper.
AutoMapper uses a fluent configuration API to define an object-object mapping strategy. AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.
iTextSharp
iTextSharp is a port of the iText, a free Java-Pdf library.
Unity
The Unity Application Block (Unity) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection.
MSTest (unit testing)
Still using the default unit testing framework. Right now I am really focused on getting more developers to write tests…anything…please. Really; there are no tests. Functional testing by non-technical people is NOT testing. Crap…I feel another post coming on…
LINQPad
I am a big fan of LINQ!
LINQPad lets you interactively query SQL databases in a modern query language: LINQ. Kiss goodbye to SQL Management Studio!
LINQPad supports everything in C# 3.0 and Framework 3.5:
- LINQ to Objects
- LINQ to SQL
- Entity Framework
- LINQ to XML
Spark View Engine
Spark is a view engine for Asp.Net Mvc and Castle Project MonoRail frameworks. The idea is to allow the html to dominate the flow and the code to fit seamlessly.
It should be noted that I am pretty new to spark and I am testing it in some personal projects to see if its worth bringing into a client. BUT the client has a strict VB only stance…so my testing will not only be standard spark stuff but doing so in a VB.NET MVC project….check out the videos.
jQuery
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
I am a JavaScript nut…primarrly jQuery and Dojo…really happy to see it in MVC because it was denied by my largest client until it started coming out of File->New Project…..Thanks Microsoft
jQuery Facebox w/ homegrown iframe support
Facebox is a jQuery-based, Facebook-style lightbox which can display images, divs, or entire remote pages. It’s simple to use and easy on the eyes.
Bringing in modals was a lot of work; demos, meetings, documents, etc….we went with thickbox….I am using facebox with support for iframe content.
CruiseControl.NET
CruiseControl.NET is an Automated Continuous Integration server, implemented using the Microsoft .NET Framework. Again; under the radar…I have a ccnet server running on my desktop…
FxCop
FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements.
SVN
Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS).
BUT…its 1.3.2….and it has pretty limited support for merges…..ugh…I think you get the picture by now….
WebSVN
WebSVN offers a view onto your subversion repositories that’s been designed to reflect the Subversion methodology. You can view the log of any file or directory and see a list of all the files changed, added or deleted in any given revision. You can also view the differences between two versions of a file so as to see exactly what was changed in a particular revision.
WebSVN offers the following features:
- Easy to use interface
- Customisable templating system
- Colourisation of file listings
- Blame view
- Log message searching
- RSS feed support
- and more…
And best of all….something about radar…
Feedreader
I use feedreader to monitor the RSS feeds from WebSVN. This way I know what is going on with my teams projects and other teams projects which my programs are dependant
SourceMonitor
SourceMonitor lets you see inside your software source code to find out how much code you have and to identify the relative complexity of your modules. For example, you can use SourceMonitor to identify the code that is most likely to contain defects and thus warrants formal review
- Collects metrics in a fast, single pass through source files.
- Measures metrics for source code written in C++, C, C#, VB.NET, Java, Delphi, Visual Basic (VB6) or HTML.
- Includes method and function level metrics for C++, C, C#, VB.NET, Java, and Delphi.
- Saves metrics in checkpoints for comparison during software development projects.
- Displays and prints metrics in tables and charts.
- Operates within a standard Windows GUI or inside your scripts using XML command files.
- Exports metrics to XML or CSV (comma-separated-value) files for further processing with other tools.
Conclusion
I am one stealthy developer…you would think that since I am on the committee that defines developer standards most of these items would be known, understood, or used…..or maybe you think I’m not demoing, teaching, preaching, or begging…well if you think that you don’t know me
I am shouting, arguing, and fighting…..ugh…
A completely biased comparison of ASP.NET MVC and Webforms
I have to admit I am total bias towards MVC but hear me out. I have yet to work in an organization that implements an OOP or even MVP when using WebForms. It’s all been directly bound controls to data readers/sets/tables. No object model, no business object layer, page_load is used and abused, etc. It can’t be stated enough that MVC will not save a project from the bullshit code that is forms over data crap but at least there is hope in the form of a tiny amount of guidance from Microsoft. </rant>
Introduction
In the .NET world the MVC pattern is relatively new but it has been the staple development architecture for Java and Ruby for over a decade. Most of the current the debate between what technology is “better” is argued from a developer’s point of view. While the technical underpinnings of a technology can often translate to the projects success; I feel that both WebForms and MVC are mature enough that most projects will do fine with either.
The technical debate does nothing for those who are trying to persuade their organization to consider ASP.NET MVC. What I am trying to present here is a list of decision points an organization can use when deciding on MVC vs. WebForms.
ASP.NET WebForms
Through the abstraction of HTML, CSS, and JavaScript; ASP.NET WebForms attempts to recreate the experience of developing a desktop application. The entire HTTP protocol is successfully abstracted away and developers are present with a faux statefulness that mimics desktop applications. Development teams are able to use a WYSIWIG style of development.
ASP.NET MVC
Out of the box ASP.NET MVC forces developers to understand HTML, CSS, and JavaScript. There is little to no abstraction which can be a double edged sword. On one hand your development team has access to the raw power of the markup & languages that make up the web. On the other; if your development team is not experienced with HTML, CSS, and JavaScript there might be a learning curve.
Decision Matrix
|
ASP WebForms |
ASP.NET MVC |
|
Your project is small and your team is not experienced with MVC |
Your project is large (experience with MVC not required) |
|
Your project requires many specific 3rd party vendor components |
Your project is not bound to 3rd party vendor components (The UI can still be very rich) |
|
Your project team is not comfortable with open-source libraries (expecially jQuery) |
Your project team is comfortable with open-source libraries (especially jQuery) |
|
Your customers requirements, possibly by contract, will not change during development |
Your customers requirements may change during development |
|
Your project will never be "extended" or have a feature "added" |
Your project maybe be "extended" or have features "added" |
|
Your project is mission critical and deserves the comfort provided by unit testing |
|
|
Your project is limited in maintenance hours |
|
|
Your project cares about HTML markup compliance |
Conclusion
I think that most projects will be able to succeed using either technology. The question is simply how much pain will you cause your developers? Will you stick with web forms and create an endless maintenance cycle? We know how much developers love maintenance programming. Or will you force them out of their comfort zone and make them learn something new for the sake of your project?
Twitter Map Mashup
I did a search the other day for the a new blog post I saw fly by on Twitter about the top 100 twitter applications and ended up re-reading a post from RRW about the top 10 twitter applications. Now the post is from 2007, so I am sure that the top 10 has changed quite a bit. What I took away from the article was a note about Twitter Atlas.
What’s it missing? The ability to get only your Twitter group’s tweets shown on the map.
First thought: really, that’s so silly there has to be a fun little mashup for that…and I on went to check out the top 100. Once there I pulled up all the map based apps…could not find anything that displayed, in easy fashion, the people you follow.
So, 4 hours later…damn I hate CSS…I need someone to do all my CSS work for me…its just not the part of coding that I like. Anyway, so I coded a mashup. You can guess what it does. Pop in a user, click and get the people they follow on a map. Then you can click on anyone they follow and do the same…its kinda fun and I waste a lot of time getting list in the network.
Downside, the twitter API requires auth to pull the total users..so I can’t tell how many people someone is follow, so I can’t figure out how many pages I need to request to get everyone. I only do one request.
Can anyone suggest a name?
Check it my twitter map mashup and let me know what you think…thanks!
Oh, anyone from ESRI..can I use your basemap data? I’d really like to redo this in the ArcGIS Server JS API….I think…
UPDATE: Crap its LATE!, I added a breadcrumb ..I think it encourages one to keep diving into the network. Which is really cool but without caching there is a huge number of requests to the google geocode service…yuck.. Next task…caching of markers…Late next week after I do some real client work…
jQuery, Ajax, prepend and events (onclick?)
Ok, why in gods name can’t I figure this out!
Adding simple elements to the DOM works…no problem.
1: new_elem = '<a href="#" onclick="alert(\'alert\')">MyAdd</a>';
2: var test = $(new_elem);
3: $('#home_column').prepend(test);
I end up with a link…when I click it…I get an alert.
BUT!….when I have the same code in the success of an ajax call the elements are added to the DOM but nothing happens when I click on it!…I know! Crazy right?
1: $.ajax({
2: success: function(data){
3: new_elem = '<a href="#" onclick="alert(\'alert\')">MyAdd</a>';
4: var test = $(new_elem);
5: $('#home_column').prepend(test);
6: },
7: url: 'http://twitter.com/statuses/friends_timeline.json' + app.twitter.since_parameter()
8: });
So….this code is placed in $(document).ready….it runs…the element is added to the DOM…life is good right? NOPE! I can’t click on it…well I can but nothing happens.
I think my ajaxSetup is pretty standard...
1: $.ajaxSetup({
2: mode:'queue',
3: beforeSend: function(xhr) {
4: var auth = $.base64Encode(USERNAME + ":" + PASSWORD);
5: xhr.setRequestHeader("Authorization", "Basic " + auth);
6: xhr.setRequestHeader("Cookie", "");
7: xhr.setRequestHeader("If-Modified-Since", 'Sun, 1 Jan 2007 18:54:41 GMT');
8: },
9: dataType: "json",
10: type: "GET"
11: });
Why would I not code stuff using Adobe Air?
Really, why have I waited so long to jump into a platform that is based on JavaScript…and HTML and CSS. Really, after spending 1.5 hours with Air I am totally amazed at my own stupidity. Oh’ and I started on YAAATC (Yet another adobe air twitter client) yaht-C…its like expresso and espresso…
Its rather late and I have to get up early…to go to work and code more Air stuff I guess…
Pinggr – meta micro blogging
Or just what I coded to I could lean how to use facebook connect…
Background
When facebook connect was released I wanted to code something to see how it all worked. I wanted to code something I could prop up relatively quick. Partly due to my lack of time but also because I have not released one single piece of software all year! I decided that, since I was just hopping into the land of twitter and I found it complicated to manage my twitter status and my facebook status, that I would write a small app that would allow me to update the status of each site either concurrently or independently.
Specifications
- support facebook connect : (100%)
- local uid/pass system : (80%)
- update facebook status : (100%)
- update twitter status : (100%)
- update local status : (100%)
- private status updates : (100%)
- support tags : (100%)
- support date/time updates (past, present and future) : (70%)
- provide meaningful statistics : (30%)
- support a public profile/time line page. http://pinggr.com/detroitpro : (50%)
- mobile version : (10%)
- simple API : (0%)
Out of scope
- Clone twitter
- I am thinking that it would more sit “on top” of the status update services.
- Full “router” support aka: act like ping.fm
Features I would like to add in the future
- Twitter style reply and dm
- openid support
- more status sites
ASP.NET MVC SiteMap
Note: This code does not support caching or security trimming. It is simply a way to build something that compares to the .NET TreeView control using the MVC pattern.
Recently one of my clients had the "perfect storm" of requirements, restrictions, deadlines and policies that lead to the need to develop a MVC TreeView(ish) control.
Requirements:
- Database storage – Site administrations needed a simple interface into editing and I was not about to write something to update XML files.
- NOT use the SQL Service Broker for easy SQL caching support – Security concerns….I assume…I was never told why NOT but just NO.
- Support the MVC pattern – new projects where being developed using ASP.NET MVC
- Easy to implement and maintain
Design:
- With MS shipping jQuery it would be nice to use a jQuery plugin to render the tree
- Leverage existing technology – Exising project are using the SQL SiteMap Provider, hence, accompanying tables and stored procedures.
- Extend the ASP.NET MVC HtmlHelpers class
Note: I assume your application is currently setup to use the SQL SiteMap Provider…or at least the Table for the provider exists.
Step 1: Create a Stored Procedure that uses a CTE
Most of the heavy lifting happens here. As you can see, when viewing the full-size image, the results are ordered by "thePath". That makes parsing the results into a ordered list very easy.
1: WITH siteMapCTE(SYSID, ID, Parent,title,description,url,roles, level, thePath) AS (
2: SELECT SYSID, ID, Parent,title,description,url,roles, 1 as level, CONVERT(VARBINARY(MAX), ID) AS thePath
3: FROM aspnet_SiteMap WHERE Parent is NULL
4: UNION ALL
5: SELECT e.SYSID, e.ID, e.Parent,e.title,e.description,e.url,e.roles, c.level + 1, c.thePath + CONVERT(VARBINARY(MAX), e.ID) AS thePath
6: FROM aspnet_SiteMap e
7: INNER JOIN siteMapCTE c
8: ON e.Parent = c.ID
9: )
10: SELECT * FROM siteMapCTE ORDER BY thePath, title
Step 2: Create new HtmlHelper method
First off..Stephen Walther’s first ASP.NET MVC article was on writing html helpers using Extension Methods. I have his sample in a current project so it was a great place to drop in the new method.
<Extension()> _
Public Function ListBasedSiteMap(ByVal HtmlHelper As HtmlHelper, ByVal items As Object) As String
If items Is Nothing Then
Throw New ArgumentNullException("items")
End If
Dim builder As New StringBuilder()
Dim mPreviousLevel As Integer
Dim mUrl As String = String.Empty
builder.Append("<div class=""demo"" id=""testMap""><ul>")
For Each row As DataRow In items.Rows
If row.Item("url").ToString.Contains("~/") = True Then
mUrl = "/" & System.Configuration.ConfigurationManager.AppSettings("application.name") & "" & row.Item("url").ToString.Split("~/")(1)
Else
mUrl = row.Item("url").ToString
End If
If row.Item("level") = 1 Then
builder.AppendLine("<li id=""" & row.Item("id") & """ class=""open""><a href=""" & mUrl & """>" & row.Item("title") & "</a>")
ElseIf mPreviousLevel < row.Item("level") Then
'child
builder.AppendLine("<ul>")
builder.AppendLine("<li id=""" & row.Item("id") & """><a href=""" & mUrl & """>" & row.Item("title") & "</a>")
ElseIf mPreviousLevel = row.Item("level") Then
builder.AppendLine("<li id=""" & row.Item("id") & """><a href=""" & mUrl & """>" & row.Item("title") & "</a>")
ElseIf mPreviousLevel > row.Item("level") Then
'close level
builder.AppendLine("</li>")
builder.AppendLine("</ul>")
builder.AppendLine("<li id=""" & row.Item("id") & """><a href=""" & mUrl & """>" & row.Item("title") & "</a>")
Else
'parent ?
End If
added.Add(row.Item("id"))
mPreviousLevel = row.Item("level")
Next
builder.AppendLine("</ul></div>")
Return builder.ToString()
End Function
Oh…I pass the results in as a data table….you can change that to be whatever your passing….
Step 3: Get results to your view
How ever you like, get the data to the view. Again, I am using my own DAL and pass the results in as a Data Table
Step 4: Put the unordered list on the view
1: <%=Html.ListBasedSiteMap(ViewData("siteMap"))%>
Don’t forget to import the HtmlHelpers namespace…in your paper (I presume its a master page or the web.config)
1: <%@ Import Namespace="yourNameSpace.HtmlHelpers" %>
Break
Ok, at this point you should have an non-styled unordered list of SiteMap nodes that looks something like. All we have to do now is style, wire and go. As a matter of fact, the sitemap should work too!…it just looks like crap.
Step E: jsTree!
I’m not going to walk you through the process of wiring up your site to use jsTree but that is the next step. download, and put the files into your project, add the script and link tags for the javascript and css…modify the CSS as needed…
So maybe I did walk you through it…anyway.
Step VI: onload event….um…
I’m using dojo for this project with the exception of the TreeView so I leveraged dojo’s OOP and onload….this should work but its not tested.
1: var first = null;
2: $(function() {
3: tree1 = new tree_component();
4: tree1.init(jQuery("#testMap"), {
5: cookies: {
6: prefix: "sitemap",
7: opts: { path: '/' }
8: },
9: callback: {
10: onchange: function(NODE) {
11: if (!first) {
12: first = true;
13: } else { document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
14: }
15: }
16: });
17: });
Finish
Here is what I ended up with…
Again, I know…no caching…no security trimming but it works and you can allow management of the nodes from a web interface (of course you have to code that) … If anyone adds trimming please let me know…I don’t have a need now but I’d like to keep this all together in one place.
My take on Microsoft shipping jQuery
First, if you have not heard, Microsoft will be shipping jQuery as part of visual studio. And if the swiftness that the .NET team moves I am sure we can see it in a the next SP. Update: Just re-read the article…The jQuery intellisense annotation support will be available as a free web-download in a few weeks…w00t.
jQuery
jQuery is great, its selector engine is by far the simplest and (I think) most powerful component. But, when using jQuery I always seem to be looking for pluggins…widgets…etc.
Microsoft’s Challenge
Even though my current shop uses dojo, which I love too!, I am truly excited by this move. But integrated jQuery is the potential to become another underutilized component in the .NET toolbox. intellisense is great but most DNDD can’t type a lick of JS. Microsoft is going to have to wrap some widgets around this powerful engine.
DNDD: Drag and Drop Developer. Yes it does have a negative condensation.