Saturday, June 9, 2012

Book: The Art of Unit Testing

The Art of Unit TestingThe Art of Unit Testing is a great book by Roy Osherove, the TDD Guru, which tries to instill us the philosophy of writing unit tests in the fastest way without neglecting the basics and the important fundamentals, and he does that perfectly. The book is written with examples in .NET with NUnit as the Unit testing framework and Rhino Mocks as the Isolation framework which are free and open source. It’s suitable for both newbies and experienced – everyone can find something that he can learn about in this book.

The book is divided to 4 parts, but I prefer to divide it into 2 parts:

The first part is all about Unit Testing basics – the definition of “unit test” and what is its goals. It explains that a unit test must meet the following requirements:

  • Trustworthy
  • Readable
  • Maintainable

Without one of these requirements, your test is no good. Then he shows how to write a simple unit test. Later on it starts to get a little deeper, and provides a definition to “stub”. He starts to talk a lot about the design of your code, about how to break dependencies and then how to inject those dependencies as stubs. Starts to get interesting, huh?

The second part (by my division), Roy describes the importance of organizing your tests – how to locate them in terms of solution structure, projects and classes. He discusses on making a testing infrastructure in your team, on integrating your unit tests in your Continuous integration process so that your tests will run on every commit. After that, Roy explains in detail the three requirements that a unit test must have (mentioned above). While reaching the end of the book, he talk about how to integrate unit tests in your organization, which tools you may find useful and what you should be aware of. The last chapter of that book, which in my opinion was the most interesting and enriching, is about working with legacy code – how do test code that its design isn’t testable and preventing you to inject dependencies? How you refactor this kind of code? And many more philosophic topics. Super interesting. Of course it was impossible to cover the whole topic; therefor Roy makes references to Michael Feathers' book Working Effectively with Legacy Code.

TDD

While I was reading this book, I was sort of a beginner developer but I already had a little bit experience in writing unit tests and practicing TDD, therefor I found the first chapters a bit less relevant for me. But it was still nice to understand a little deeper – why it’s important to have a good coverage to your code, and to have readable tests. What I specially loved about this book, besides it is suitable both for beginners and experienced, is that it’s manages to be very practical and yet enough theoretical to be interesting. In addition it’s written in very comfortable English (not so high), so it’s not that boring. :)

I recommend everyone to read this book – from newbies to seniors, team leaders, and even hardcore TDD programmers who want to refresh their basics about TDD.

Sunday, June 3, 2012

Inviting Crawlers

Note: I will focus here on Google search engine, but most of this works for all major modern search engines.

After understanding the basics about search engines and how they work, I decided to act for improving my site search visibility – how my pages will be appeared in search results and how high they will be ranked.

So I started seeking the web for ways to do so, and apparently there are many ways you can do that. In fact, there is an entire field called Search Engine Optimization (SEO), there are even SEO Consultants that make money from this stuff. Sure I’m no SEO, but I’ve gathered some simple do-it-yourself actions that you can do to optimize your search results:

  • Explicitly tell Google to crawl a site. This is a great start for new sites.
  • Design your site to be more crawler-friendly, by structuring your URLs and using Meta tags, such as the <meta name="description" content="…" /> tag.
    Tip about meta tags: Google ignores most Meta tags. The most important one is the description tag, which besides helping crawlers to get a clue about the content of the page, it tells Google what to display under your link. A good description tag will eventually make more visitors to your site.
  • Add links to your site from other pages around the web. Especially from pages similar in content. This is extremely important. It will help your pages to be more visible on searches because crawl robots will get to your site more often and mark it as more relevant and popular.
  • Search engines rank pages by the relevance to the term being searched. For example, if you search for “Code Lodge” you can find a lot of stuff that has no connection to software, but if most of the people that searched this term will enter to the http://www.codelodge.net/ result, it will eventually result in ranking this site higher. So the more clicks you get, you will be rated higher.
  • If you own a blog, then you probably want to add credibility and authorship to your pages. By making sure each page has a link with a rel="author" attribute to your , and from your Google+ page a link that has rel="me" with a link back to your blog. This is how you make your site gain reliability, and with a cyclic link back to your site it will be crawled more often.
  • Pay a SOE guy to do this job for you. :)

Those are some great tips but the best advice that I’ve learned from this session, is simply try to build a quality site with rich content and the rest will come by itself. You can’t build a crappy site that the only good thing about it is it’s meta tags and expect good rankings. Clear your mind from thoughts about search engines and doing tricks that will help you with good search results. Start focusing on building sites with good UX, content, and design that will be good for your visitors, that’s 99% of what matters. You have to work for it, there are no free rides.

nofreerides

That’s all for now, I’m sure that there are much more things I can do, but all those kinds of things takes time to show results. I think I will let time to do its job. Until then I better start working.