<commit_before>---
layout: post
title: Put a Feed On It  
---
  
![]({{ site.baseurl }}content/images/imgres.jpg)

> Did you see this bag before? I didn't. Now there's a bird on it. It's flying, it's free!
> 
> -<NAME>, *"Put a Bird on It"*

If you're making a webapp that deals with public data, especially timestamped records that are for public display, here's a good rule of thumb to follow: <strong><em>put a feed on it</em></strong>. At some point, you're going to want to pull that data into another place and display it as part of some landing page or aggregate it into some 3rd party service.

<!--more-->

If you work in a large enough organization, somebody's eventually going to want to pull in your data. If you've exposed a feed, you control the business logic of what gets shown. If you don't expose a feed, someone's eventually going to find a way to pull the data directly from your database, probably without your knowing anything about it, and who knows if they're respecting the intended design of your models, which they've probably had to reverse engineer by guess.

Luckily, it's incredibly easy to "put a feed on it." I recently did this with an <a href="http://www.asp.net/mvc" target="_blank">ASP.NET MVC</a> webapp that was in the latter situation described above.

### Create Serializable Feed Models

First, you'll want to create some models specifically for using as feed items. I created the following, which enabled me to map our <a href="https://announcements.uww.edu/" target="_blank">Announcement Board application's</a> data models into an <a href="http://en.wikipedia.org/wiki/RSS" target="_blank">RSS 2.0</a> compatible feed.

##### AnnouncementFeed.cs (Feed Object)

First we need an object that will allow us to inject some of the required RSS fields into our output. Note that, while some of the elements are essentially read-only, if you don't supply a <code lang="csharp">set { }</code> definition, the field will be omitted from the feed output.

Attributes allow us to control how elements are named in the feed output.

<pre><code class="language-csharp">using System;<commit_msg>Update 2012-08-30-put-a-feed-on-it.md<commit_after>---
layout: post
title: Put a Feed On It  
---
  
> Did you see this bag before? I didn't. Now there's a bird on it. It's flying, it's free!
> 
> -<NAME>, *"Put a Bird on It"*

![]({{ site.baseurl }}content/images/imgres.jpg)

If you're making a webapp that deals with public data, especially timestamped records that are for public display, here's a good rule of thumb to follow: <strong><em>put a feed on it</em></strong>. At some point, you're going to want to pull that data into another place and display it as part of some landing page or aggregate it into some 3rd party service.

If you work in a large enough organization, somebody's eventually going to want to pull in your data. If you've exposed a feed, you control the business logic of what gets shown. If you don't expose a feed, someone's eventually going to find a way to pull the data directly from your database, probably without your knowing anything about it, and who knows if they're respecting the intended design of your models, which they've probably had to reverse engineer by guess.

Luckily, it's incredibly easy to "put a feed on it." I recently did this with an <a href="http://www.asp.net/mvc" target="_blank">ASP.NET MVC</a> webapp that was in the latter situation described above.

### Create Serializable Feed Models

First, you'll want to create some models specifically for using as feed items. I created the following, which enabled me to map our <a href="https://announcements.uww.edu/" target="_blank">Announcement Board application's</a> data models into an <a href="http://en.wikipedia.org/wiki/RSS" target="_blank">RSS 2.0</a> compatible feed.

##### AnnouncementFeed.cs (Feed Object)

First we need an object that will allow us to inject some of the required RSS fields into our output. Note that, while some of the elements are essentially read-only, if you don't supply a <code lang="csharp">set { }</code> definition, the field will be omitted from the feed output.

Attributes allow us to control how elements are named in the feed output.

<pre><code class="language-csharp">using System;
{'fraction_non_alphanumeric': 0.08890452732817265, 'fraction_numerical': 0.003284072249589491, 'mean_word_length': 4.343358395989975, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 40, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1542317', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1123, 'n_words': 633}