How to Initialize, Share, and Cleanup a Web Service Proxy

clock January 9, 2012 03:36 by author Jeremy

Have you ever felt like consuming an asmx web service could lead to untidy code? Many times, I felt like I was repeating code unnecessarily because my webservice proxy required special initialization and cleanup each time it was used.

When reading through "Design Patterns in C#" a while ago, they presented an example from the Oozinoz DAL that allowed multiple methods to share a data reader. It was a great (and pretty cool) example to centralize the setup of some common components, such as the connection, command, and data reader objects. It was a simple pattern that allowed for a delegate to handle the actual implementation of the code that consumed the data reader. I'm going to present that code here:

public delegate object BorrowReader(IDataReader reader);

public static object LendReader2(string sel, IBorrower borrower)
{
    using (OleDbConnection conn = DataServices.CreateConnection())
    {
        conn.Open();
        OleDbCommand c = new OleDbCommand(sel, conn);
        OleDbDataReader r = c.ExecuteReader();
        return borrower.BorrowReader(r);
    }
}

public interface IBorrower
{
    object BorrowReader(IDataReader reader);
}

Here is a simple implementation from the book:

public static void Main()
{
    string sel = "SELECT * FROM ROCKET";
    DataServices.LendReader2(sel, new BorrowReader(GetName));
}
private static object GetNames(IDataReader reader)
{
    while(reader.Read())
    {
        Console.WriteLine(reader["Name"]);
    }
    return null;
}

So what does it all do? Basically, in the main method above (from a fictitious Console app) your declare a sql statement, pass it to the DataServices.LendReader method. The second parameter to the LendReader2 method is the BorrowReader delegate.

Note the the delegate takes an IDataReader parameter. The LendReader2 method initialized the necessary ADO.NET objects (DbConnection, DbCommand, and DbDataReader). Once ExecuteReader is called, control is sent to the delegate (in this case, the GetNames method) which works with the corresponding data reader. The really great thing about this pattern is the LendReader2 method is responsible for resource cleanup.

What does that have to do with consuming a web service?

I recently had to integrate with a third-party asmx web service. I don't really do that often any more because of WCF and the increasing number of REST-based services that are available. But, in this case, I was using the web service.

I needed to use several methods but I was looking for a clean and elegant way to centralize the instantiation of the web service proxy. That's when I thought about this example from the book.

The first thing I needed was a delegate for my webservice call:

delegate void ServiceCallDelegate(MyService service);

NOTE: MyService should be the type of your web service proxy.

Next, I create a method called MakeServiceCall. This method will be used (obviously) for making calls to the web service.

private void MakeServiceCall(ServiceCallDelegate code)
{
    using (MyService service = new MyService())
    {
        // ANY INITIALIZATION LOGIC GOES HERE

        // THINGS LIKE SETTING USERNAMES, PASSWORDS, ETC ON THE PROXY
               
        // make service call
        code(service);
    }

}

Finally, all that's left is code to consume the web service. I'll walk through the code example but want to present it first:

Account a = null;

MakeServiceCall(delegate(SforceService service)
{

    Result result = service.retrieveAccount("123");

    if (result != null)
    {
        a = result.Account;
    }
});

return a;

So here's a quick review of each piece. First, I created a delegate that took an instance of my web service proxy. That service proxy gets created in my MakeServiceCall method. Any initialization is performed at the beginning of the method (things like newing up the proxy, setting urls, logins, passwords, etc). Then the actual service work is delegated to the delegate that is passed in. In the example code above, the delegated proxy is used to retrieve an account with id 123. The beauty of this pattern is that the cleanup of the service proxy is performed at the end of the MakeServiceCall method (notice the delegate is called from within a using block).

That's all there is to it. A simple example of a solid pattern that cleanly handles common web service tasks such as initialization and cleanup.


What is a sitemap? It's important, that's what.

clock January 8, 2012 14:13 by author Jeremy

If you invested any time trying to optimize your website for search engines, you may have realized something. If you try to optimize a page for more than about 3 keywords, you’ve realized you won’t have good results. I hate to break it to you but the solution is to build out many, many landing pages that are each optimized for your numerous keywords.

Your next question is probably how are the search engines going to find all these new landing pages? I’ve always assumed that I’ll just link to these various landing pages and the magic “spiders” will take care of the rest. But WAIT, there is a better way. Enter the sitemap.

I’ve been building websites for a long time but only recently began focusing on search engine optimization. Interestingly, I’ve seen sitemaps many times but never realized their importance in the SEO process. Much less, I’ve never registered my sitemap with the search engines. Read on so you don’t make the same mistake with your website that I have.

What is a sitemap?

A sitemap is an XML document that tells search engines (especially Google and Bing) which landing pages you would like them to index. This is an often overlooked tool that can yield excellent results with driving traffic to your site.

From sitemaps.org:

Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling. In its simplest form, a Sitemap is an XML file that lists URLs for a site along with additional metadata about each URL (when it was last updated, how often it usually changes, and how important it is, relative to other URLs in the site) so that search engines can more intelligently crawl the site.

Web crawlers usually discover pages from links within the site and from other sites. Sitemaps supplement this data to allow crawlers that support Sitemaps to pick up all URLs in the Sitemap and learn about those URLs using the associated metadata. Using the Sitemap protocol does not guarantee that web pages are included in search engines, but provides hints for web crawlers to do a better job of crawling your site.

A simple sitemap

Here is a sample from www.sitemaps.org:

<?xml version="1.0" encoding="UTF-8"?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

   <url>

      <loc>http://www.example.com/</loc>

      <lastmod>2005-01-01</lastmod>

      <changefreq>monthly</changefreq>

      <priority>0.8</priority>

   </url>

</urlset>

Sitemap XML Format

There are rules that a sitemap must adhere to.  Complete details can be found here:  http://www.sitemaps.org/protocol.html (including a complete description of the XML schema). Here are the highlights:

  • All data values in the sitemap must be entity-escaped
  • The sitemap file must be UTF-8 encoding
  • Begin with an opening <urlset> tag and end with a closing </urlset> tag
  • Specify the namespace in the <urlset> tag: “xmlns=http://www.sitemapg.org/schemas/sitemap/0.9”
  • Include a <url> element for each URL, as a parent XML tag
  • Include a <loc> child element for each parent <url> tag
  • All URLs in a single sitemap file must be from the same host (www.example.com and store.example.com are two separate hosts)

Sitemap XML Tags

Attribute   Description
<urlset> required Encapsulates the file and references the current protocol standard.
<url> required Parent tag for each URL entry. The remaining tags are children of this tag.
<loc> required URL of the page. This URL must begin with the protocol (such as http) and end with a trailing slash, if your web server requires it. This value must be less than 2,048 characters.
<lastmod> optional The date of last modification of the file. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD.

Note that this tag is separate from the If-Modified-Since (304) header the server can return, and search engines may use the information from both sources differently.
<changefreq> optional How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Valid values are:

    always
    hourly
    daily
    weekly
    monthly
    yearly
    never

The value "always" should be used to describe documents that change each time they are accessed. The value "never" should be used to describe archived URLs.

Please note that the value of this tag is considered a hint and not a command. Even though search engine crawlers may consider this information when making decisions, they may crawl pages marked "hourly" less frequently than that, and they may crawl pages marked "yearly" more frequently than that. Crawlers may periodically crawl pages marked "never" so that they can handle unexpected changes to those pages.
<priority> optional The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0. This value does not affect how your pages are compared to pages on other sites—it only lets the search engines know which pages you deem most important for the crawlers.

The default priority of a page is 0.5.

Please note that the priority you assign to a page is not likely to influence the position of your URLs in a search engine's result pages. Search engines may use this information when selecting between URLs on the same site, so you can use this tag to increase the likelihood that your most important pages are present in a search index.

Also, please note that assigning a high priority to all of the URLs on your site is not likely to help you. Since the priority is relative, it is only used to select between URLs on your site.

Entity Escaping

In addition to saving the sitemap file with UTF-8 encoding (typically an option when saving your file in your chosen text editor), certain characters need to be escaped, just like HTML.

Character   Escape Code
Ampersand & &amp;
Single Quote ' &apos;
Double Quote " &quot;
Greater Than > &gt;
Less Than < &lt

Here are some samples of entity-escaped URL’s from sitemaps.org:

Below is an example of a URL that uses a non-ASCII character (ü), as well as a character that requires entity escaping (&):

http://www.example.com/ümlat.php&q=name

Below is that same URL, ISO-8859-1 encoded (for hosting on a server that uses that encoding) and URL escaped:

http://www.example.com/%FCmlat.php&q=name

Below is that same URL, UTF-8 encoded (for hosting on a server that uses that encoding) and URL escaped:

http://www.example.com/%C3%BCmlat.php&q=name

Below is that same URL, but also entity escaped:

http://www.example.com/%C3%BCmlat.php&amp;q=name

Submitting your sitemap to Google and Bing

Search engines look for a plain text file at the root of your website. Convention is to name it sitemap.xml. It must also be publicly accessible from your URL (i.e. http://www.mydomain.com/sitemap.xml). Remember, it can only include urls from a single domain name.

If you haven’t already registered your site with Google and Bing, read this post first.

Otherwise, log in to:

https://www.google.com/webmasters/tools/

  1. From the home page, click the hyperlinked URL of the website that you have built the sitemap for
  2. On the left menu, click on “Site Configuration”, then “Sitemaps”
  3. Click “Submit a Sitemap”
  4. Enter the URL of your sitemap (it has to be publicly accessible)
  5. Click “Submit Sitemap”

http://www.bing.com/toolbox/webmaster/

  1. From the home page, click the hyperlinked URL of the website that you have built the sitemap for
  2. From the top menu, click “Crawl”
  3. From the “Crawl” submenu, click “Sitemaps (XML, Atom, RSS)”
  4. Click the “Add Feed” button
  5. Enter the URL of your sitemap
  6. Click “Submit”

Remember, after you submit your sitemap, it may take a few weeks for the search engine to crawl your site.

Validate your sitemap

To validate the structure of your website, first download the sitemap schema:

http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd

Then add a couple of attributes to your <urlset> tag:

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"

         xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

Then you can select one of the many validation tools listed on either of these links:

http://www.w3.org/XML/Schema#Tools

http://www.xml.com/pub/a/2000/12/13/schematools.html

Don’t make the same mistakes I have made. Take the time to build and submit a quality sitemap.


How do I register my website with search engines?

clock January 6, 2012 17:30 by author Jeremy

If you want your website to be found, you’ve got to register with the major search engines. I’ll walk you through registering your site with Google, Yahoo!, Bing, and several of the smaller search engines.

Google

Currently, about 65% of all search engine searches originate with Google. So, to improve the chances of website visitors finding your website, you want to make sure that your website is properly registered with Google.

Google Webmaster Central

The first step is to create an account with Google Webmaster Central. Google Webmaster Central is an easy way to notify Google that your website exists. It also lets Google know that you are the webmaster of the site, point Google to your site’s sitemap (I’ll write about sitemaps later), verify your Robot.txt file, and find any errors on your website. As I mentioned in earlier, this tool also gives you access to the keyword research tool.

  1. Browse to http://www.google.com/services/
  2. Click on “Webmaster Central”
  3. Click “Sign In to Webmaster Tools”
  4. Create an account or sign in with your existing Google account
  5. Once you are signed in, click “Add a Site”
  6. Enter the URL of the site you want to manage (remember, you’ll need access to the web server that hosts to site so you can prove to Google that you are the webmaster)
  7. The next screen gives you a link to verify ownership
    • First, download the HTML verification file
    • Upload the file to the root of your website (on your web server). It will need to stay there permanently
    • Test the confirmation link that is displayed on the page
    • Click the “Verify” button

Once you complete verification, your website is setup in Google webmaster central.

Google Analytics

From the webmaster central home page, click on the link to Analytics at the top of the page. You can also browse to http://www.google.com/services/

  1. Click on “Google Analytics”
  2. Click “Access Analytics”
  3. Click on the gear icon in the upper right corner.
  4. Click “New Account”
  5. Now enter
    • Account name (a friendly description for you)
    • Website URL (the url to your website)
    • The time zone of your web server
    • Select your preferred Data Sharing Settings
    • Accept the User Agreement by clicking “Yes, I agree…”
  6. Click “Create Account”

Now, your website is setup in Google Analytics. Eventually, you’ll need to go back into webmaster central and let Google know about your sitemap.xml file.

Submit to Bing (and Yahoo!)

Now that Yahoo! Gets its search results from Bing, you’ll be able to register for both search engines by submitting through Bing’s Webmaster Tools.

  1. Browse to https://ssl.bing.com/webmaster/SubmitSitePage.aspx
  2. Click “Webmaster Tools Sign In”
  3. Either sign-up or sign-in
  4. Once you’re signed in, you may be prompted to set up your preferences. Complete the form and click “Save”
  5. Click “Add Site”
  6. Enter the URL of your website
  7. Download the BingSiteAuth.xml file
  8. Upload the file to the root of your website
  9. Confirm the file by visiting the test link
  10. Click the “Verify” button

Now your website is registered with Bing (and with Yahoo!)

DMOZ (open directory project)

To register your site with the open directory project:

  1. Browse to http://dmoz.org
  2. Search for your site to make sure your site isn’t already listed
  3. Click “Suggest URL”
  4. Identify the best category for your website and browse to that category from the dmoz.org home page
  5. Click “suggest URL” at the top of the page. NOTE: if you don’t see “suggest URL” keep clicking through categories until you have selected one that is specific enough for the “suggest URL” link to be displayed
  6. Fill in the form and enter:
    • Your website URL
    • Select “Regular” and the type of link
    • Enter the title of your website (remember to use your website’s home page SEO optimized title)
    • Enter your website description (remember to use your website’s SEO optimized meta description)
    • Enter your email address
    • Enter the user verification code
  7. Click “Submit”

Alexa

Alexa has a lot of weight to Google and other search engines. To register with Alexa:

  1. Browse to http://www.alexa.com/edit
  2. Register for an account or login via Facebook
  3. Enter your site’s URL
  4. Select “Intro (Free)”
    • Save the Alexa verification file to your computer
    • Upload the Alexa verification file to the root of your website
    • Click “Verify the file on your site”
    • NOTE: I had to add quotes to the alexaVerifyID meta tag in the downloaded file to get it to verify: <META name="alexaVerifyID" content="MdVAHkYV9v_jts5GLO9S2MIUT3Q">
  5. Click on “Continue”
  6. Enter your Site Title, Site Description, Alexa Traffic Rank in Country, and your public contact information
  7. Click “Save and Continue”
  8. Click “Go to the Dashboard”

You are now registered with Alexa.

AllCanSeek

To register with AllCanSeek:

  1. Browse to http://www.allcanseek.com/add/
  2. Fill in Email, your website URL, website Title, website keywords, and website description. Be sure to use the SEO optimized version of your title, keywords, and description.
  3. Click “Add Site”

You are now registered with AllCanSeek.

Jayde

Jayde is a specialized search engine for certain types of businesses. To add your website:

  1. Browse to http://www.jayde.com/submit.html
  2. Enter your website URL, your email, and the verification code
  3. Enter other information about your business as applicable: business name, twitter account, etc.
  4. Click “Add my Site”
  5. Check your email
  6. In the email, click “Add My Site”. There are LOTS of links in the email so just click “Add My Site”.

Your website is registered with Jayde.

What about the others?

There are many, many other smaller search engines and directories. For a small amount of money, you can use one of the reputable sites to take care of the rest of these submissions for you (believe me, it is money well spent).

Visit http://www.websitesubmitter.org. This is a high quality and highly reputable site. They have packages starting at $12.95 and max at $139.95. If you take a minute to review the features, you can find the one that is right for your business.

Wrapping it up

I’ve shown you how to list your site to the major search engines: Google and Bing as well as a few other sites. You may choose to use a service like http://www.websitesubmitter.org and have them register your site on Google and Bing as well. I like having access to the dashboards provided by both site’s webmaster tools. Also, be patient. Most registrations take several weeks and months even. In time, you’ll see your traffic increase as your website gains more visibility.


Who is going to buy your product?

clock December 23, 2011 04:01 by author Jeremy

When I first began to develop an Internet based business, my thought process included these delusions of grandeur that the Internet would expose my product to all these people from all over the world. With a US population 308 Million and a world population of almost 7 Billion, making millions of dollars should be a breeze.

If you try to build your Internet business using this strategy, you’ll be in for a rude awakening. You can generate a great deal of web traffic but the people who visit your site will not be your ideal buyer. Any time, effort, and money you invest in boosting traffic to your site will be in vain. Ultimately, the success of your business depends on one (and only) thing: how many products can you sell?

All the traffic in the world will not make you a single dime. You must decide who is most likely to buy your product and develop that buyer profile. Focus all your efforts on reaching the people who are most likely to purchase your product.

This also applies to your search engine optimization efforts. Don’t use generic one word keywords like “fitness”, “make up”, “football”, “books”. They are difficult to optimize for because they are so generic but, most importantly, keywords like this are open for interpretation. Someone who searches something like “books” may be looking to write a book, publish a book, check out a book from the library, sell a book, buy a book, etc. Chances are that a visitor who finds your site using these generic keywords will not be interested in what you have to sell.

One of the most important steps in building a successful product on the Internet is to identify your ideal customer, build out a complete customer profile, and focus all of your marketing efforts around that customer. You WILL get LESS website traffic but you WILL get MORE qualified traffic, which WILL result in MORE sales.

How do you build a customer profile?

I’d like to highlight this next section on building a customer profile form John Jantsch’s book “Duct Tape Marketing”.

What problem does your product solve?

For you to launch a successful product on the Internet, it must solve a problem for your customer. Start by identifying what that problem is. This problem should serve as the basis for your customer profile. The one common thread ALL of your customers will have is the need to solve this particular problem (which your product will miraculously do). As John Jantsch puts it, “the definition of marketing is “getting people, who have a specific need or problem, to know, like, and trust you.”

If you can’t identify a problem (or need or want), then you don’t have a market. If you can’t identify that problem, then visitors to your website won’t be able to either. As a result, they won’t buy your product. Maybe you need to pick something else to sell? Remember, you are not selling a product, you are selling a solution to a problem.

Physical Characteristics

You need to think about certain demographics that apply to your customers. For consumer products, think about:

  • Age
  • Employment Status/Level (white collar, blue collar, management, non-management, hourly, salary, etc)
  • Gender
  • Occupation/Industry
  • Income
  • Education Level
  • Where do they live?
  • Hobbies/Interests

After establishing these characteristics, you should see some patterns emerge that your ideal customers will share. If you don’t, you’ve probably incorrectly identified your customer demographics.

Emotional Characteristics

The psychographics of your customer base will help you figure out how to get your customers to like and trust you and your product. This is difficult but you want to identify things like:

  • Values
  • Fears
  • Desires
  • Goals

Also, be on the lookout for:

  • Hobbies
  • Interests
  • Books and Magazines that are read
  • Musical preferences
  • Travel tastes

Knowing these interests will give you an unlimited number of unique, customizable ways to communicate with your customer. How powerful would it be if you were to email your customer a link to one of their favorite bands with a simple note that says “Thought you might like this”. Would that help them like and trust you

Like identifying the problem your products solve, you want to ask a few questions about your customers:

  • What do they want out of life?
  • What are they not getting?
  • What do they need to feel comfortable?
  • What’s holding them back?

Understanding these psychographics will help you understand how you can bring the most value to your customers. You may want to add a survey to your website to try to identify some of these characteristics of that your website traffic may possess. This will also give your some insight into how successful your marketing efforts are and how accurate your customer profile is being developed. There are many survey programs available (both free and paid).

There is a high probability that your customers will share common likes and interests. As you see these patterns emerge, you’ll know you are close to developing an accurate customer profile. Knowing and identifying these common characteristics (and being able to act upon this knowledge) will help tip the scales in your favor when a customer is faced with a buying decision between you and your competitors.

If you invest the time (it won’t necessarily be easy) to identify your ideal customer profile, you will certainly reap the rewards. Your business will be more successful and your marketing efforts will be much more precise and efficient. You will undoubtedly see the results.

JE


What's a meta tag? Why should I use them on my website?

clock December 16, 2011 21:35 by author Jeremy

Before I started exploring the many aspects of search engine optimization, I had heard a few mentions of meta tags and their use in seo. The only tags that were ever mentioned were title, keywords, and description. However, there is a lot more to fully utilizing meta tags in your web pages and search engine optimization efforts to ensure your customers find you.

Before I talk about each meta tag in detail, I’d like to answer this question: "What is a meta tag?"

I found this great definition on techterms.com:

"This is a special HTML tag that is used to store information about a Web page but is not displayed in a Web browser."

According to Google’s Webmaster Tools help site,

"Meta tags are a great way for webmasters to provide search engines with information about their sites. Meta tags can be used to provide information to all sorts of clients, and each system processes only the meta tags they understand and ignores the rest. Meta tags are added to the section of your HTML page"

Basically, just remember that information contained in your meta tags are used to describe yourself, your company, your location, or your product to search engines.

Also, remember that meta tags apply to each individual web page and should be customized and optimized for each page in your website.

I would like to show some examples that were given by Mike Monahan in his book "Search Engine Optimization Secrets: SEO for 2011". In his book, he uses an example of a fictitious Portland office furniture store call "Portland Office Stuff" (his book is AWESOME. You should invest the time and money to read it).

Meta Tag examples and how to use them

Meta Keywords Tag

<META name="keywords" content="portland office furniture, portland office interiors, portland office cubicles, portland furniture installers, portland furniture repair, portland healthcare furniture, portland medical furniture, teknion, steelcase, herman miller">

After doing keyword research, he decided on these keywords above. The hard part is deciding on your keywords (here’s more information on keyword selection). There’s not much to putting those keywords in the meta tag. Just be sure that the keywords are put in priority order. The most important keywords must be listed first.

Meta Description Tag

<Meta name="description" content="OneSource Office Stuff is the premier source for office systems and furniture for Portland, Gresham, and surrounding areas. We specialize in planning and outfitting your office environment from top to bottom.">

The meta description is what is most seen in a search engine’s results. It is important that your description is written using complete sentences and includes the keywords that your page is going to be optimized for. You need to use the keywords in your description in the same order they are included in the keywords meta tag. You should keep the length of your description to 155 or characters or less (that’s the length that most search engines will display).

Meta Title Tag

<title>Portland Office Stuff | Portland Office Furniture | Portland Office Interiors | Portland Office Cubicles </title>

The title of each webpage is one of the most important parts of your search engine optimization efforts. It is imperative that you use as many of your keywords as you can in the title tag (in the proper order, of course). Google allows up to 66 characters including spaces. The World Wide Web Consortium recommends 64 characters or less, so that’s probably a good rule of thumb.

Many crawlers use the title tag as a main determinant of your page’s content so proper key word utilization is a really big deal. Also, each page of your website should have unique title tags. Use the most important key words for each individual page.

Meta Robots Tag

<meta name="robots" content="index,follow">

The meta robots tag tells search engine spiders whether to review your webpage. The possible values are:

  • index: allows a page to be indexed
  • noindex: keeps a page from being indexed
  • follow: follow links from this page and index them nofollow: do not follow links from this page
  • all: shorthand for index, follow
  • none: shorthand for noindex,nofollow

You’ll only want to use one value, most probably "index,follow". For a public website, this gets your site the most visibility in search engines.

Meta Googlebot Tag

<Meta name="googlebot" content="index, follow" />

This is just like the robots tag...but for Google. Google likes to see their own stuff on your webpages. Be sure to add this tag.

Meta Revisit Tag

<meta name="Revist-After" content="7 days" />

This tag is used to tell search engines how often your content changes so they’ll know how frequently to visit your site. It’s reliance and importance is debatable. If your site is a blog and you post 3 times a week, set the value to 2 or 3 days. The more frequently you update the content on your webpage, the more search engine love you’ll receive.

Meta Subject Tag

<meta name="subject" content="Portland Office Furniture">

It may not be influential in the major search engines but some smaller ones like it. It can’t hurt right? Just put the most relevant keyword as the subject.

Meta Location Tags

<Meta name="city" content="Buford">
<Meta name="country" content="United States (USA)"> 
<Meta name="state" content="GA"> 
<Meta name="zip code" content="30518">

If you are running a local business, these tags are really important to search engines, especially Bing.com. This helps identify geographical locations to search engines and provide more relevant local searches.

Meta Author and Copyright Tags

<Meta name="author" content="Jeremy Edmondson">
<Meta name="copyright" content="Edmondson Inc.">

These tags won’t get you to the top of Google but sometimes a little recognition is nice.

If you put time and energy into writing stellar content, at least give yourself the credit. Other Meta Tags There are many other meta tags but these are the important ones. Learn about the other ones at http://www.metatags.info.

With the rise of mobile devices, there are many new geographic meta tags coming to prominence. I’ll write more about that later.

JE


Spring.Net: There was no DB provider available, unable to create connection OR how to inject a dictionary

clock December 16, 2011 03:06 by author Jeremy

Last night, I was pulling my hair out. I was wiring in a couple of new objects into the Spring.Net container to use dependency injection. I had an object that had a dictionary property filled with commands that my application is listening for. Each command had a dependency on my repository object (which was also managed by the Spring.Net container). It seemed to be an easy thing to define each of these command objects in the Spring.Net configuration file.

I found this snippet in the Spring.Net documentation:

<!--
      results in a call to the setter of the SomeDictionary (System.Collections.IDictionary) property
      -->
      <property name="SomeDictionary">
          <dictionary>
              <entry key="a string => string entry" value="just some string"/>
              <entry key-ref="myKeyObject" value-ref="myConnection"/>
          </dictionary>
      </property>

I used this as my guide and added my object declaration (specifically, setting my entries using the value-ref example to point to injected objects in the container).

When I ran the website for the first time, I got this exception: "There was no DB provider available, unable to create connection". I was certainly perplexed. 5 minutes earlier, the app was running fine. There were no database issues.

A quick Google search yielded no help so I wound up including the Spring.Net source in my Visual Studio project. I needed to walk through the code to figure out what was going on.

Once I started stepping through the code, I found out that the call to get the LocalSessionFactoryObject was being called twice. The first time, it was being created successfully. The second time, the DbProvider was null, which resulted in the exception above. Even thought I had found the problem, I didn't know why and had no idea had to fix it.

So, in frustration, I refreshed the page (because that ALWAYS seems to fix my problem). Luckily, the second time through the code, I actually saw the real exception. Spring threw the real, underlying exception (even the inner exceptions previously didn't show the problem). Spring couldn't cast the type HybridDictionary to IDictionary<string,object> (which was my dictionary type). It didn't like the generic dictionary. So I changed the type to System.Collections.IDictionary, updated my code accordingly, and voila!

Problem solved! It is very interesting to me that Spring.Net shows a downstream exception instead of the one that actually caused the problem.

JE


How do I choose winning keywords?

clock December 11, 2011 16:53 by author Jeremy

In the last post, I wrote about long tail keywords and a few ways to start selecting keywords. The next logical question is “how do I select the correct keywords to target?” These highly focused, targeted keywords are known as trophy keywords. If you select the correct trophy keywords, you will be guaranteed win against your competition.

First off, here are a couple of guidelines. For each page on your site, you want to optimize that page for 1-3 keywords. If you use more than 3, you may do more harm than good with the big search engines. Also note, when I say “keyword”, I mean “long tail keywords” (a short 2-5 word phrase). Stay away from single words that are too generic (like “fitness”). You may generate a lot of traffic but it won’t all be the kind of buyers you are ultimately looking for. Instead, opt for more specific keywords to optimize your web pages around. It’s worth sacrificing large numbers of generic site visitors to attract a smaller number of highly focused website visitors. Your banks accounts will reap the reward.

Tools for Choosing Keywords

  1. Google

    To start examining keywords, go to Google and start typing one of your broad keywords (like “fitness”). Chances are you’ll see a keyword suggestion that jogs your memory. Then you’ll type in another keyword variation…and you’ll keep repeating the process. After doing this for a few iterations, you’ll have a list of keywords to start with (let’s say 15 or 20). NOTE: this same exercise can work on YouTube and other social media websites.

  2. Google Keyword Tool

    Google has some really cool tools available and the Keyword tool is an excellent example. Browse to https://adwords.google.com/select/KeywordToolExternal (you’ll want to save that link in your favorites).

    From this tool, you can test the keywords you came up with in step one. It’ll also show you other related keywords you may be interested in, the competition level for those keywords, global monthly searches and local monthly searches for the suggested keywords. Keep in mind that this tool is designed for PPC campaigns (see the “adwords” subdomain in the URL) but this is an excellent research to aide you in selecting the correct keywords for your website.

    This tool can also be used to analyze your existing website (if you already have one). Google will crawl your website and decide what keywords will work best. Simply enter your website’s URL in the “Website” text box at the top of the “Find keywords” screen. If you choose this option, you’ll be confused by some of the suggestions…until you analyze your website’s content and realize Google is smarter than you. This approach is an amazing way to analyze the quality of your website’s content as it pertains to search engine optimization. Your content may be hindering you from reaching your ideal clients with your trophy keywords.

Deciding on your trophy keywords

Once you’ve obtained all this keyword data from Google, your head may be spinning. The time has come to make a decision. Truthfully, selecting your keywords is going to require some experimenting. As you’re just starting out, you can’t compete with larger sites for highly competitive keywords. It is imperative that you are able to isolate your niche and choose long tail keywords that appeal specifically to that niche. Then benefits of this approach are twofold: you will avoid the competition with the larger sites and you will drive valuable, highly focused niche traffic to your site.

When I type in fitness to the keyword tool, there are 37 million monthly searches for fitness but the competition is low. The high number of searches for fitness with low competition is a good thing but the search term is so general that it really isn’t worth my while to try to rank first for fitness. There are too many possible reasons someone has visited my site. Ultimately, I’m looking for buyers.

A term like “fitness programs” has 135,000 monthly searches but the competition is medium. It may be worth competing with this keyword because people looking for “fitness programs” are quite possibly interested in purchasing a fitness product. I would advise staying away from high competition keywords in the beginning. If you’re like me and just staring to market a product, you don’t have the time or resources to compete for highly competitive keywords. Your time and effort need to be focused on other aspects of your business that will actually make you money.

After about an hour of using the keyword tool, I’ve been able to pick out my trophy keywords. I have isolated 50 keywords I want to target. Remember, you want to optimize a web page for 1-3 trophy keywords. To accurately optimize my site for these keywords, I need develop content for about 20 webpages.

Once I begin developing content targeting these trophy keywords, I must remember to come back to the keyword tool and have it crawl my website to see if my content was optimized. When I get that far in the process, I’ll write more about developing content that is search engine optimized.

In the next post, I’ll write about the importance of meta tags in your pages.


Question: What are keywords? Answer: The first step in new product development

clock December 8, 2011 17:39 by author Jeremy

When I began thinking about developing a new product to sell on the Internet, I didn’t think about the keywords I would use on my website to promote my product (which I still have decided on yet). In fact, I didn’t know what keywords were...really. I had some idea but I think it was little misconceived.

Over the last few months, I’ve been working out twice a week with a personal trainer and really making some changes to my diet. During this time, I’ve learned a lot about fitness but it has also cost me a lot of money. So, conceptually, I’ve decided to target some sort of fitness product. Maybe a workout guide or meal planner?

My immediate first thought was to go select some available fitness related domain name...but then I started reading about the importance of selecting keywords and, more importantly, the presence of those keywords in your domain name.

So that begs the question...how do I select my keywords? I was thinking that I would choose fitness, workouts, and nutrition. Boy, was I wrong! A Google search for “fitness” returns 1.4 BILLION (not million) results. “Workouts” returned 63.6 million results. “Nutrition” returns 476 million results. As you can see, competing with those keywords when launching a new product is suicide. It’s not a matter of when you’ll go out of business; it’s more about how quick you’ll go out of business.

Enter long tail keywords.

Long Tail Keywords

If you’re like me, you may have never heard of long tail keywords, but they are probably the most important part of developing a new product.

Technically, long tail keywords can be defines as a phrase containing 2 – 5 words (“keywords” and “long tail keywords” are conversationally the same). From a search engine marketing perspective, selection of your long tail keywords is critical to the success of your product (or business). Selecting the correct long tail keywords is certainly more of an art than a science but putting a significant amount of effort into their selection is crucial. You are effectively decreasing the amount of competition for your search terms (see “Nutrition” above) and improving the overall quality of the traffic your website will draw. Selecting the correct long tail keywords means your website visitors are much more likely to purchase your product or service.

To expand on my example above, a quick Google search of “nutrition guide” returns 22.9 million results. It’s still very competitive but nowhere near 1.4 billion results. We’re moving in the correct direction.

However, it’s not a simple as adding more keywords. If I change my search terms to “free nutrition guide”, I have now returned 99.5 million results. I’ve moved in the wrong direction.

During my time with the personal trainer, he showed me a diet called Paleo (coincidentally, a search for “Paleo Diet” returns 4.32 million results). Basically, the Paleo Diet is a way of eating like cavemen: lean meats, seafood, vegetables, fruits, and nuts (there’re a few rules to it, but basically that’s the highlights).

So, if I decide to target “Paleo Diet”, the competition is reduced. I can target a phrase like “free paleo diet plans” and reduce the results to 2.6 million.

By the way, Google Instance is a great way to get long tail keyword ideas. Start with a word like “nutrition” and see what pops in the list below the search box. If I type “nutrition gui” it lists choices like “nutrition guide”, “nutrition guidelines”, “nutrition guide for Chick fil a”, and “nutrition guidelines 2011”. It’s a great way to generate ideas for long tail keywords.

If I search for “download free paleo diet plans”, Google returns 468,000 results. That feels like a number I can compete with. There is more to selecting keywords (like how many times the keyword is searched for) than just the number of results that Google returns but I think this example is a good overview of a thought process to follow when thinking about and choosing your keywords.

One last note: as you are thinking about your keywords, try to decide on about 10. This isn’t a hard rule, but anything greater than 10 will start to be ineffective (remember, each page in your website will have to have content optimized around these keywords). Personally, I feel that trying to optimize around more than 10 means you’re not really sure what your business is all about.

So, we have begun the process of selecting our keywords (which will ultimately help decide the product’s name, the company’s name, and the website URL). In the next post, I’ll talk more about tools that are available to assist with selecting keywords and how you actually will select the keywords to use.

JE


How am I going to get rich?

clock December 6, 2011 17:04 by author Jeremy

I want to be rich. I think that anyone who knows me would agree with that statement. My goal in life is to find a way to make a TON of money. Millions and millions and millions. I would love to be in a position to retire at 40 and I am quickly running out of time.

I also love to write code. Solving problems, automating mundane processes, adding insane business value...I am so blessed that I can't wait to get up in the morning and get to work. I love my job and I love what technology can do to transform the world.

When I was in college, I decided to pursue a MBA instead of a technical graduate degree. I thought that would make be a better entrepreneur (that remains to be seen...only time will tell). During my coursework, I learned a great deal but it was very late in my graduate program before I took my first marketing class. That one class really changed my life. Had it been sooner, I would have undoubtedly changed my concentration (instead, it is Information Security). In that class, I realized that customers drive business and business drives technology (typing that out, it seems like a fairly obvious statement).

As a programmer, I think most of us get it backwards. We feel like technology drives business. Most technology professionals take a "build it and they will come" approach. As long as we use the latest, greatest technology, there's no chance a business won't succeed (FYI - revisit the dot com boom). Instead, it's important to figure out what problems our use of technology can solve for a customer. If we, as software engineers, can solve a customer's problem, we will generate some serious revenue for our companies.

So, that leads me to today. Over the last couple of months, I've been reading several books on marketing. I've found that these books make me a better developer. It helps me ask better questions during requirement gathering, build more accurate use cases during development, and write higher quality test cases during testing (NOTE: it is very hard to test your on code). It also makes me want to create a product that can be sold and make me lots and lots of money.

As I've been reading various books (check the "Things I Like" page), it quickly gets overwhelming. There are so many things to worry about:

  • What type of product do I want to develop?
  • What technology am I going to use?
  • How much is it going to cost?
  • How will I drive traffic to my website (i.e. Search Engine Optimization)?
  • Do I start a blog (you're reading this aren't you...)?
  • What about social media?

...and that's just a few of the things running through my head.

Another thing that is concerning as I have read some "get rich on the Internet" type of books is that it is supposedly easy to get rich. Apparently, you don't have to know anything about technology or even be remotely intelligent. So I have to ask myself, why do I have so many questions?

I have decided to take a different approach. I'm going to really figure out the pieces of the puzzle. I doubt it will be easy and I think you have to figure out technology at some point along the way. But when I'm done, I'll have a profitable business model (or a lifetime's worth of hard knocks) that can easily be replicated (by you, of course).

Who knows what we'll find out along the way? I sure don't, but it's going to be fun. I'm going to document my thoughts along the way. My first step was writing this post but I've got to quickly decide on a niche and develop a product. Then, I'll have to build out a website (and shopping cart). Apply some search engine optimization techniques. Figure out the social media aspect (something I still don't fully understand). Market, market, market. The list goes on and on.

When I'm done, I hope to be sitting on a beach somewhere in the Caribbean.

Next time, I'll share my thoughts on the products I'm considering.


Scheduling Tasks using Spring.Net, Quartz.Net, and Dependency Injection

clock June 6, 2011 06:02 by author Jeremy

I'm working on a windows service that has a need to perform some tasks each night. I really didn't want to have to write some mundane threading code that woke up periodically and checked the time. I also wanted to use my existing Spring.Net and NHibernate infrastructure to perform the tasks.

After a bit of research, I came across Quartz.Net. Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems...basically, it was just what I was looking for.

Spring.Net has several hooks to create tasks and a couple of different configuration options.

First, you need to create a class that will be used for your job.

namespace MyService
{
    public class RecurringJob : QuartzJobObject
    {
        private ILog log;

        public IMyService MyService { get; set; }

        protected override void ExecuteInternal(JobExecutionContext context)
        {
            PerformJob();
        }

        private void PerformJob()
        {
            if (log == null)
            {
                log = log4net.LogManager.GetLogger("MyLogger");
            }
            
            log.Info(string.Format("Performing Job at {0}", DateTime.Now));
            
// put real code here } } }

The important thing to not is that this class inherits from QuartzJobObject and overrides ExecuteInternal. This base class is provided by Spring.Net. You'll also need to reference the Quartz DLL.

Next, we'll need to configure our Spring IOC Container. You'll need to add a few objects.

<object id="MyService"
        type="MyServices.MyService, MyServices"
        autowire="byName">
        <constructor-arg index="0" ref="MyRepository" />
</object>

This is a simple object declaration to my service (which has is setup via constructor injection with a NHibernate repository...if you need to know how to set this up, see my other posts).

Next, we need to configure the actual job. It is declared as follows:

<object name="RecurringJob" type="Spring.Scheduling.Quartz.JobDetailObject, Spring.Scheduling.Quartz">
   <property name="JobType" value="MyService.RecurringJob, MyService" />
  <property name="JobDataAsMap">
    <dictionary>
      <entry key="Stateful" value="true" />
    </dictionary>
  </property>
</object>

So, a couple of things here. First, the object that will be used for my job is not actually declared in the IOC container. It's simply a string that represents the type the job will instantiate. Second, you can pass some static data (string, int, bool) to the class by using the JobDataAsMap property. Notice, I set the Stateful property (which exists on the QuartzJobObject base class) so that the scheduled job would be completed before the next job fires. Otherwise, the next scheduled job could start executing before the previous one has completed (in my case, I only want the job to run once a day so it's not a big deal but it COULD be in certain circumstances).

Now, we need to actually setup the schedule for the job. There are two ways to do this (I'll show you both):

<object id="SimpleTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
  <property name="JobDetail" ref="RecurringJob" />

  <!-- 10 seconds -->
  <property name="StartDelay" value="10s" />

  <!-- repeat every 5 seconds -->
  <property name="RepeatInterval" value="5s" />
</object>

<object id="CronTrigger" type="Spring.Scheduling.Quartz.CronTriggerObject, Spring.Scheduling.Quartz">
  <property name="JobDetail" ref="RecurringJob" />

  <!-- run every morning at 6 AM -->
  <property name="CronExpressionString" value="0 0 6 * * ?" />
</object>

The first is a "simple" trigger that essentially defines how long to wait once the app starts up before starting (the "StartDelay" property) and how long to wait between starting each instance of the task at hand (the "" property). You'll also need to set the "JobDetail" property to the instance of your job (that we defined above).

The second is more of an actual scheduled job (the "CronTriggerObject"). In this example, we set the "JobDetail" property just like the simple trigger, but then we set the CronExpxressionString property. This example sets the job to run at 6:00 am each day. For more information on the CronExpressionString syntax, here's a tutorial: http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html.

The last thing to setup is the Quartz Scheduler Factory:

<object id="quartzSchedulerFactory" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
   <property name="SchedulerContextAsMap"> 
      <dictionary> 
         <entry key="MyService" value-ref="MyService" /> 
      </dictionary> 
   </property> 
   <property name="triggers"> 
      <list> 
         <ref object="CronTrigger" /> 
         <ref object="SimpleTrigger" /> 
      </list> 
   </property> 
</object>

Let's discuss the easy part first, set the trigger property to the triggers we previously declared (I've set up both variations but you really only need one). Just comment or delete the one you don't want to use.The most time consuming part of this entire exercise was figuring out how to take advantage of dependency infection in my service. After a couple of hours of research, I finally found the "ScheduleContextAsMap" property. Each instance of the job is technically a new object so attempting to set properties as part of the actual job declaration will not blow up, it just won't work. Here, I specify my instance of the object that I want to inject into my object (this time using setting injection). Remember, the "key" is the property on my job class and the "value-ref" represents the id/name of the object that is declared in the container.

When you crank up your app and instantiate the ApplicationContext, the magic happens and your job begins to execute. That's all there is to it.


TextBox

Sign in

© 2012 Jeremy Edmondson, All Rights Reserved