ASP.NET has improved dramatically with v2.0, to the point of making ASP.NET v1.x look like a bit of a hack job. One of the great improvements covered in this entry is the addition of Master Pages.
Master Pages allows you to define a template layer (and coupled back-end code) to be used on content pages using that master page. For instance a master page might define all linked scripts, CSS, and script blocks, along with a navigation header and footer that exist on all pages on the site (or at least those pages using the master page). An ugly example sits a subdirectory away -- at the root pages for yafla, where the navigation header and footer exist in a master page.
ex. MasterPage.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>My Master Page - This Title Will Be
Overridden
By the Title Element
In Content
Pages</title>
<link rel=stylesheet type="text/css"
href="stylesheet_in_all_pages.css" />
</head>
<body>
<h3>This is my universal
header!</h3>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1"
runat="server">
</asp:contentplaceholder>
</div>
</form>
<h3>© 2015 Robot
Inc.</h3>
</body>
</html>
You can also define code for the various events in the master page,
which will run on the pertinent content pages.
Content pages then define what will fill the content block (or multiple content blocks as the case may be), and of course implement their own back-end code.
<%@ Page
Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2"
Title="This is my overridden title" %>
<asp:Content ID="Content1"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This is my content for this content page
</asp:Content>
Very trivial.
Of course this isn't the only way that this result could be achieved -- I could derive from a page object that imperatively creates all of the common elements, or I could use multiple user controls that defined the basics, but neither of those solutions, or similar workarounds, seem as elegant as master pages to me. There are equal or superior solutions in other platforms, however I'm sticking to the topic of ASP.NET in this entry so they are irrelevant.
The one hiccup I faced in the use of master pages was my desire to have meta keywords (which exist in the header) vary by page, despite the fact that the meta keyword is basically dead. I want the keywords to vary, similar to the way I can declaratively override the title in content pages. Unfortunately this required some code workarounds, which in my case included adding a public property on the master page, MetaKeywords, with a default keyword list, which I then added to the header in the PreRender stage of the master page (the following example is simplified for demonstrations sake, however a real implementation would scan the headers to ensure that the pertinent header doesn't already exist before adding it).
public string MetaKeywords = "default keywords";
protected void Page_PreRender(object
sender, EventArgs e)
{
SetMetaValues(this.Page.Header,
"keywords", MetaKeywords);
}
public static void
SetMetaValues(System.Web.UI.HtmlControls.HtmlHead head, string
name, string content)
{
HtmlMeta metaValue =
null;
metaValue = new
HtmlMeta();
metaValue.Attributes.Add("name",
name);
metaValue.Attributes.Add("content",
content);
head.Controls.Add(metaValue);
return true;
}
Any content page could access its Master property to set the property, and the meta keywords would be appropriately set when the page was rendered. By using the MasterType directive the Master property of the page automatically resolves to the proper type.
Unfortunate that a declarative mechanism wasn't added for arbitrary header elements in the content pages.
The goal of master pages, of course, is to avoid the scourge of copy/paste coding: Unnecessarily having a single line of code in multiple places is an evil in software development, yet it's often the easy, thoughtless solution, yielding volumes of redundant code that invariably diverges and causes maintenance problems for years to come, reducing the quality and agility of the codebase.
I despise copy/pasted code. It truly is a peeve of mine.
When analyzing the quality of code bases, one of the first checks I usually perform is to use one of the automated code duplication checkers (available for most languages). There is a remarkable correlation between code duplication rates and code quality.
The benefit of master pages isn't limited to a single master template, however, but instead you can actually layer multiple master pages. For instance on the yafla site the services category pages use the Services master page, adding additional service specific back-end code and layout, while it uses the web site wide master page. It mirrors the templated way in which many websites are developed.
The downside of layered master pages is that the GUI team apparently didn't have time to build multiple level parsing into the web designer -- wherever you're working on content pages that have more than one level of master pages above them, you are limited to the source view. To attempt otherwise yields a "Design view does not support creating or editing nested master pages. To create or edit nested master pages, use the Source view." Unfortunate, but not deadly.
As an aside, one of the big improvements with ASP.NET v2 is better support of per-page development, similar to classic ASP and competitors such as PHP. This solves one of the primary problems many had with ASP.NET, which is that they didn't prefer to work within the "web site as a monolithic application" model that ASP.NET v1 pretty much enforced. Strangely the improvements bringing these benefits has been met with little fanfare, and few are even aware of it. I do plan on doing a feature on it shortly.
Tagged: [Software Development], [Programming], [Software-Development]
While I remain committed to SQL Server, after a lengthy evaluation and feature analysis process, we will start advocating MySQL 5 to some clients under a set number of conditions, both on the Windows and the Linux platforms. While MySQL was previously lacking some critical foundational features, v5 ups the ante considerably, filling a particular niche in the solution spectrum. This is a part of a wider trend at yafla of embracing some of the "alternative" platforms, outside of our normal Microsoft-enabled comfort zone, where it benefits our customers and the solution.
Due to licensing conditions we still won't be targeting our applications at MySQL.
We still advocate PostgreSQL, another excellent open source RDBMS, for some scenarios.
One of the continuing trends of the Web 2.0 revolution is tag-mania -- sticking tags on everything and anything, hoping that it somehow improves the flow, digestion, and utility of information. From adding tag clouds to your blog, to slashdot, to photos, to bookmarks, tags have continued to spread across the web landscape.
As with every tech "revolution", in corporations across the globe eager employees are embracing the trend, advocating adding tags to documents and directories and files, and embracing the concept of metadata.
As a bit of an explanation for those who haven't been following TechCrunch in morbid curiousity -- wondering what dubious business came out of super-secret stealth alpha invite-only mode today -- and thus aren't up on their Web 2.0 lingo, tags are, in essence, a set of words that one or more users apply to something to categorize it -- what we historically called keywords, albeit sometimes (thought not always) with a "democratic" process determining the rendered tag set.
For instance the tags of this post might be "Web 2.0, tags". Ten visitors might add "tripe", making it the dominant tag in the tag cloud.
Getting a variety of people adding tags to the same content, or building a common directory of information loosely categorized by tags, is what's commonly called a folksonomy. Consider, for comparison, a formal taxonomy of a system like Yahoo's classic categorization, where a submitter would choose exactly where in the hierarchy a link went, and the Yahoo overlords would validate it, and insert it if appropriate. Instead the loose addition of tags adapts to have multiple categorizations over time.
[Web 2.0 aware readers will probably shudder seeing an explanation of something so "basic", yet discussions in the field have led to me to believe that much of this great revolution has gone unnoticed by the bulk of society, including even the majority of technology workers. I regularly converse with people who've never seen del.icious, don't know who 37signals are, and haven't been to Reddit or Digg or Flickr or Furl. Much like bloggers have grossly overestimated the impact of blogs on the general population, there seems to be a presumption that the Web 2.0 lingo and dogma is more universal than it actually is]
While many of the Web 2.0 aficionados declare there to be a fundamental religious difference between the venerable keyword and tags, the difference is superficial at best (democratically selected keywords are still just keywords). The same keywords that have always existed as a data block in the JPEG file format, and exists in virtual every document format (Word, for instance), form the foundation of tags. Metadata has been around since we first started storing data, and tags are a continuation of that trend.
Many of the foundations of modern tagging, the evolution of the keyword, were first demonstrated widely by the superlative web photo organizing and sharing application Flickr.
Given the primitive state of image recognition, this was a perfect fit: Without tagging your photo with keywords such as "bridge, burlington skyway, qew", there was no way searches could find that photo if asked, for instance, for pictures of the Burlington Skyway bridge -- We aren't yet at a stage where software can reliable figure out what the subjects of a picture are, and mechanical metadata is still incomplete (although it's getting there), so keywords/tags/folksonomies fills a critical gap if the photography data process.
Outside of photos the use of tags is often much more dubious.
To go back in history a bit, when search engines first appeared they largely relied upon meta keywords. This was a compromise due to limits in the "comprehension" of content -- search engines got confused easily, and even when they could parse the content properly they couldn't truly figure out what the content was about.
Keywords came along, offering a simple, condensed, human-created subset of the data, categorizing the important attributes of the content. Search engines embraced and utilized keywords as an important element of fulfilling search requests.
The honeymoon didn't last for long. It turned out that keywords were a prime stomping ground for search engine spammers, not to mention that it was a horribly limited method of searching through data: Not only were the choices of keywords entirely subjective -- often grossly incomplete and inconsistent -- but by design it was limited to a very, very small subset of the content. If you really wanted content about metal railings, you might have missed my extensive discussion on that topic in my Burlington Skyway Bridge article because I didn't feel that metal railings made the cut for the keywords.
Meta tags are largely dead now.
In its place search engines have become much better at determining what a given page is about (or at least simulating a reasonable promixity thereof). By analyzing content, having a directory of similar and derivative words, and by deriving information by context (such as links and related pages, and how they word links) and layout (noting that heading text, title, and early text holds more importance in classifying the page, though it still is used in concert with the rest of the content), search engines have come a long way it understanding content, and in correlating searches with appropriate results.
The loss of the keyword has proven to be very beneficial for search. Now it's the actual data that classifies the content, rather than artificial metadata.
With improvements in language processors and context associative correlations (e.g. where the content parser understands that the paragraph on boxers is talking about the boxer breed of dog, determined by its correlation with other documents coupled with other details of the language, using language trees to classify probable meaning), things will only get better.
Content search has a very bright present, and a brighter future.
Yet tags continue to spread in woefully inappropriate domains, even where it's serving as nothing more than the modern day equivalent of the venerable META keyword. Instead of building reliable, feature-rich search tools into product, appropriately determining relationships and context to understant content, product vendors are just tossing in a hack-job tag infrastructure and calling their job complete.
Worse still, users are accepting it and calling it a feature.
Mozilla has announced the winners of the previously mentioned extend Firefox contest, with the three grand-prize victors carrying home a beefy PC, along with a considerable amount of developer credibility. Category winners earned some decent prizes as well.
Congratulations to the winners on a job well done.
Having said that, I've tried out the winning extensions, and I have to confess that I'm underwhelmed. Not to take away from their accomplishments, but for a challenge of such magnitude, for a core product with millions of software developer fans, I expected some awe-inspiring, revolutionary products to emerge.
Firefox has an enormously robust and feature rich extension model, where almost anything is possible, yet the roster of available extensions is dominated by trivial tools with simplistic, archaic interfaces, too many of which seem like hack jobs (the exception being the extensions by big corporations -- Corporations that spit and polish their offering to reap the benefits of tracking your habits and encouraging you to use of their search).
Of course I'm complaining about something that is generally free, so as the old saying goes, you get what you pay for...In fact you get far more than you pay for, but it demonstrates that there are limits to the sacrifice and resources someone will commit to a product that they find difficult to monetize.
Not only is it close to impossible to achieve revenue from an extension unless you're pushing a different product (such as search), but the skills and technologies that you learn building extensions is hard to leverage for professional gain (e.g. knowing XUL and the Mozilla extension API is of marginal value outside of building extensions, where the C skills gained doing kernel hacking has tremendous professional value).
Nonetheless, at least the winners weren't gadget clocks. Gadget clocks and basic arithmetic web service examples always strike me as a sign of a technology or platform that is being oversold.
I like Reddit.
On average the signal to noise ratio is great, and a scan through the hot list is usually a very worthwhile venture. The wide range of topics makes it more entertaining and informative than many tech-only sites, but it still has enough tech-related info to feel pertinent to the software development profession.
I've also received a substantial number of hits from Reddit over the past couple of months, with no less than 5 entries hitting the front page for periods of time, with each of them yielded 6000+ inbound visitors. Though these are of no profit to me, it is satisfying that many of these visitors left great comments and sent interesting emails, and found the entries informative or educational. After each onslaught the number of RSS subscribers jumps by a hefty amount.
Early on I admittingly submitted a couple of my longer, more thought-out posts to Reddit, thinking it would help exposure a bit, but became a bit discouraged by the whole exercise after seeing them instantly start descending into the negative range. Pure speculation, but my guess is that some rather unsportsmanlike submitters are automatically "voting down" everything in proximity of their addition, hoping to make their own submission stand out in relation (it's the only rational explanation for the almost instant vote downs). I would also guess that many users skip over low-ranked new items, so it basically becomes a race to get the first couple of up votes before it's voted into oblivion, and then a continued series of up votes to offset the continual downvotes.
This came to mind as I was just "testing out" the quicklinks that I just added on posts. I discovered a case of a single entry that had been submitted to Reddit three different times from different areas of the blog (which is a "benefit" of users who subscribe to and read the different areas). I've put these in order, determined by the obvious sequential ID that Reddit adds. I'm not sure of the specific times of each of them.
http://reddit.com/info?id=14ev - This was added from the home page version. It earned a forgettable score of 1.
http://reddit.com/info?id=14lu - This was apparently added referencing the static version located here. It earned a healthy -4 score. Perhaps because it was a duplicate of the prior one.
http://reddit.com/info?id=14sm - This was added from the Software Development version. It earned a very respectable score of 204, and I knew about this one because of a substantial impact on the visits over a two day period.
The exact same content, in different forms, yielded a 1, a -4, and a front-page for two days 204. Whether it was because of titles, time of day, or simply luck of the draw (that the last one got momentum before the haters started downvoting), it is a fascinating demonstration that these sorts of web democracies aren't always a meritocrasy.
Just thought that was a little fascinating.
I've received a couple of fantastic comments about troubles that people have faced adding items from here to their del.icio.us bookmarks, namely because Radio Userland uses a constant title for all entries (and del.icio.us automatically uses the title, so three different entries get the same title if you fail to manually override its choice). The common title problem was one of the reasons I created the notables static listing, though of course that listing is just a subsection of entries.
To help with this issue, I've added quicklinks below each entry to add it to your del.icio.us bookmarks, furl bookmarks, to Digg it or to Reddit it (which will link to an existing entry if one is already on there), and to check for Technorati links (there are seldom Technorati links because most of the readers here aren't bloggers, or they aren't the sort of bloggers that comment on every site they visit. I'd get a big boost in the Technorati rankings if I started pandering to the incestuous blogging community). I've mirrored these items to the static section as well.
For yafla registered clients (which basically means professional consulting clients who need the online tools) I've implemented an "AJAX" style logon (evident on the home page. It was basically developed for the upcoming http://www.360notes.com, which is currently in super-ultra-amazing stealth mode). It's responsive and extremely lightweight, and works throughout the site without redirects.
Maybe I'll bundle it up and sell it as an AJAX-enabled ASP.NET logon security user control!