Archive for Programming

C# How-To: Creating a Driver Foundation

// September 22nd, 2008 // 2 Comments » // .NET, C#, Programming

“Driver Foundation”?
A driver foundation is a class that your program will go through to access several other types of classes that all have something in common (i.e.: A database driver).

Generic Outlook

dbf_flow1

Actual Example for Database Platform

dbf_flow2

Why would I need this? Is this really necessary?
If you’re not worried about expandability in your application, then forget about it. However, if you’re designing an application that would need to access and query different types of databases (MySQL, PostgreSQL, SQLite, MSSQL, etc), then having a driver foundation is ideal. Otherwise you will end up with an unmanageable mess of code – you would need to control (for each different database type) the output type for queries, query syntax, and a bunch of other stuff.

Using a driver foundation you really only deal with one type of object, and one type of output for all types of databases.

(more…)

PHP DOMXML: Constructing an (Atom) RSS Feed

// September 21st, 2008 // No Comments » // PHP, Programming

There’s no doubt an easier way of parsing an RSS feed (xml) than by using DOM XML, but I’m here to show you how to do it the hard way. Infact, you could learn a thing or two by taking the harder, yet still logical, routes in programming.

The Basic Elements of an Atom RSS Feed
First, you have the “rss” element that defines the version and the xmlns, as shown below:

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">

Next comes your “channel” element – essentially the root of your RSS feed – which contains all the RSS feed information, including content. The channel element does not have any attributes, only child elements. The child elements consist of: title, description, lastBuildDate, language, ttl, atom:link, and the RSS item(s) – as shown below:

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Example RSS Feed</title>
        <description>A mock-up RSS feed.</description>
        <lastBuildDate>Sun, 21 Sep 2008 18:56 -0500</lastBuildDate>
        <language>en-us</language>
        <ttl>60</ttl>
        <atom:link href="http://examplesite.com/feed/news.rss" rel="self" type="application/rss+xml"/>
    </channel>
</rss>

(more…)