Developing with LINQ

April 3rd, 2008 by Martin Jacobs

Once in a while you encounter tools that change the way you work and write your code. Firebug is an obvious example of this. Having worked with .NET 3.5 the last couple of months, I started using a great tool that made C# development much faster. The tool is LINQPad , written by Joseph Albahari. It lets you query your SQL Server database using LINQ. It is very easy to map your database, and immediately start writing code.

LINQPad supports everything in C# 3.0 and Framework 3.5:

  • LINQ to SQL
  • LINQ to Objects
  • LINQ to XML

It has code snippets for pretty much all LINQ constructs.

In the results pane of the LINQPad tool, you can not only see the results of your query, but also the lambda expression it was evaluated into, as well as the resulting SQL that was executed against the database.

Not only does it speed up development, testing your queries for correctness and performance is also much simpler.




Now that’s a cool table

April 2nd, 2008 by Raymond Velez

We worked with AT&T and the Surface folks to build this desktop application that will be showing up in AT&T locations across the company. Some of the fun features will be the interactive map, real-time phone comparisons by placing two phones on the table and lots more. We built the application using .Net 3.5 and the Windows Presentation Framework for the core application. For back-end connectivity we leveraged the Windows Communication Framework and linq. Check out the video below.




April 2nd, 2008 by Krish Kuruppath

Putting JCR into action – Sling and µJAX

During last couple of years the enterprise content management community has been noticing a steady rise in the popularity of JCR aka JSR170. A lot of CMS vendors and application server vendors have pledged support to this initiative. For those who are not familiar with JCR, it is the Content Repository API for Java Technology - a Java standard advocated by Day software. JCR provides a “JDBC” equivalent access to content so that the application code does not have to know the details of the underlying vendor implementation. JCR aims at providing an elegant solution to some of the content management challenges faced by organizations dealing with a profusion of content repositories and CMS products. JCR promises “best of both worlds” by providing a single API to access and modify content stored in a DB or in a file system.

I have been tracking the evolution of products based on JCR implementation for a while and was quite disappointed initially to see that other than Day (the proponent of JCR) none of the major ECM vendors provided any real support to JCR based repositories. However recently the situation is getting much better with Alfresco offering a JCR-170 compliant repository and Day supporting the Apache Sling initiative that exposes the JCR APIs via REST.

Exposing the JCR API via a set of RESTful services is a wonderful idea and Sling is one of the first RESTful open source web application frameworks built on top of JCR. Sling uses Apache JackRabbit as the JCR repository. JCR is a tree structured or hierarchical content store. So naturally it makes sense to map tree-structured URLs directly to the tree structure of JCR so that the nodes can be accessed just like a file system with static files.

Before looking at Sling, I tried to build a blogging tool using the evaluation of copy of CRX (Day’s Communiqué) and the µjax library that came with it. Unfortunately I didn’t make much progress with it because of lack of supporting documentation and missing files etc. Then I downloaded Sling Launchpad (a ready-to-run Sling configuration, with an embedded JCR content repository and web server with some Sling components). The maven build went fairly smooth, and I was up and running in less than 10 minutes or so. Initially I used the CURL to post content into the repository and later switched to an HTML form to post the content into the repository. Content in the repository can be rendered using ESP server side JavaScript module that comes with Launchpad.

The biggest plus I see with sling is that it handles the normal GET and PUT methods out of the box and translates them into corresponding JCR actions to retrieve and post content into the repository. The blogging tool is a very simple form of CMS, but it can be extended easily by writing servlet code. Although I used ESP to render the page, Sling supports other scripting languages supported by the Java Scripting framework (JSR-223).

I see a lot of potential for Sling. If we can build a good interface for posting and editing the content in the repository (I have been bugging Atul Kedar to post his custom JavaScript library for building advanced content entry forms into some open source repository) it could beat many of the CMS products out there in the areas of customizability and flexibility.




C# Query Expressions and 3.0 Features (Book Preview)

April 2nd, 2008 by Troy Sabin

Bruce Eckel and coauthor Jaime King have posted a sample of their upcoming book: C# Query Expressions and 3.0 Features

From the authors:

It’s become more common for authors to offer a few pages or sometimes a chapter of their text to the public as a means of marketing. Our aim is to not only provide a sample, but also a useful stand-alone text. By itself, this sample provides any C# 2.0 programmer a foundation in C# 3.0.

This is intended to be a useful mini-book on its own, not just a teaser: it’s 239 pages long and includes 82 exercises and solutions. The full book is filled with many more exercises and solutions.

The book covers:

  • Extension methods
    • Inheritance vs. extension methods
    • Utilities for this book
    • Extended delegates
    • Other rules
  • Implicitly-typed local variables
  • Automatic properties
  • Implicitly-typed arrays……
  • Object initializers
  • Collection initializers
  • Anonymous types
  • Lambda expressions
    • Func
  • Query Expressions
  • Basic LINQ
  • Translation
    • Degeneracy
    • Chained where clauses
  • Introduction to Deferred Execution
  • Multiple froms
  • Transparent identifiers
    • Iteration Variable Scope
  • More complex data
  • let clauses
  • Ordering data
  • Grouping data
  • Joining data
  • Nested Queries
    • into
    • let clause translations
    • let vs. into
    • joining into
    • Outer joins
  • Other query operators

Download the sample here.




Apple’s Leopard lasts ‘30 seconds’ in hack contest

March 29th, 2008 by Paras Wadehra

Apple’s Leopard has been hacked within 30 seconds using a flaw in Safari, with rival operating systems Ubuntu and Windows Vista so far remaining impenetrable in the CanSecWest PWN to Own competition.

Security firm Independent Security Evaluators (ISE) — the same company that discovered the first iPhone bug last year — has successfully compromised a fully patched Apple MacBook Air at the CanSecWest competition, winning $10,000 as a result.

Charlie Miller, a principal analyst with ISE, said that it took just 30 seconds and was achieved using a previously unknown flaw in Apple’s Web browser Safari.

Competitors in the hacking race were allowed to choose either a Sony laptop running Ubuntu 7.10, a Fujitsu laptop running Vista Ultimate SP1 or a MacBook Air running OS X 10.5.2.

“We could have chosen any of those three but had to make a judgement call on which would be the easiest and decided it would be Leopard,” Miller said.

“Every time I look for [a flaw in Leopard] I find one. I can’t say the same for Linux or Windows. I found the iPhone bug a year ago and that was a Safari bug as well. I’ve also found other bugs in QuickTime.”




RIAs and Content Management

March 26th, 2008 by Raymond Velez

Forrester recently published a report on Rich Internet Applications and Content Management. The report covers some of the key topics in this area such as organic Search Engine Optimization, changes in build and release management, and how to change Content Management to better support RIA. The content for the report came from interviews across to folks managing and building sites with these technologies. Mike Scafidi’s architecture around Search Optimized Flash Architecture (SOFA) gets a mention.




Microsoft partners with social networks for contact data portability

March 25th, 2008 by Paras Wadehra

Microsoft has partnered with some of the world’s top social networks on contact data portability. Starting today, Microsoft will be working with Facebook, Bebo, Hi5, Tagged and LinkedIn to exchange functionally-similar Contacts APIs, allowing them to create a safe, secure two-way street for users to move their relationships between their respective services. Along with these collaborations, Microsoft is introducing a new website at www.invite2messenger.net that people can visit to invite their friends from their partner social networks to join their Windows Live Messenger contact list.

The collaborations with Facebook, Bebo, Hi5, LinkedIn and Tagged will make it easier, safer, and more secure for people to have access to their contacts and relationships from more places on the web. These networks will be adopting the Windows Live Contacts API instead of “screen-scraping.”  Starting today, you can visit www.facebook.com and www.bebo.com to find your friends using the Windows Live Contacts API.  Hi5, Tagged and LinkedIn will be live in the coming months.




Share Google Spreadsheets via Google Gadgets

March 24th, 2008 by Raymond Velez

This is kind of neat, now you can share parts of your collaborative spreadsheets via a Google Gadgets. So, it can show up on your iGoogle page and other places. Neat way to pull folks into looking at your exciting number crunching;). Google also launched spreadsheet notifications. Tools lik eZoho Docs and Google Docs are very cool, no with the ability to syndicate more easily that should help adoption.

Read more here: http://googledocs.blogspot.com/2008/03/collaboration-goes-one-level-deeper.html There’s also some cool gadgets around visualization.




highscalability.com looking under the covers..

March 19th, 2008 by Raymond Velez

A very cool site that gives us a look under the covers at what some of the super high-volume sites out there are doing to get their content and functionality to people. It’s amazing to see how some of the highest volume sites out there leverage open source so effectively. YouTube’s architecture looks very interesting. There’s also an interesting summary of the Microsoft Cloud plan.




“Beautiful Code: Leading Programmers Explain How They Think”

March 19th, 2008 by Keith Fitzgerald

“Beautiful Code: Leading Programmers Explain How They Think” is yet-another-excellent book put out by O’Reilly Books. It contains 33 essays written by respected members of the Software Development community and each essay is a variation on the theme of how we define “Beautiful Code”. The range of topics is vast and includes subjects like “A Regular Expression Matcher”, “Distributed Programming with MapReduce”, “Python’s Dictionary Implementation”, and [one my favorites] “The Most Beautiful Code I Never Wrote”. Each of the authors does a fantastic job of being as concise as possible without sacrificing an accurate presentation and solution of the covered problem. 

Although the authors certainly deserve applause, the editors Andy Oram and Greg Wilson are truly the unsung heroes in this publication. I can imagine it was a difficult task to make these separately written essays feel more like a book and less like a collection of chapters. How they accomplished this, however, may not be immediately apparent.  What I found was that within each of the 33 individual essays, lies a unique engineering principle that will emerge in successful software development endeavors. Moving beyond each of those principles within each of those essays, I realized that it is only the developer who grasps these tenets who is capable of writing Beautiful Code. 

Before moving on, I would like to point out that “Beautiful Code” is a book written for advanced developers. If you do not have some degree of familiarity with topics like: Finite Automata, C Programming, Concurrency Problems, Protocol Stacks, Haskell, Cryptography, Algorithm Proof Techniques, and Kernel Development, this book is probably not for you. Even if you are comfortable with these topics, be prepared to encounter a few chapters that may need to be read twice or require a bit of internet sleuthing before you grok it. 

Below, I’d like to present an example of what I mean by “the essay” versus “the extracted principle”.

Chapter Three is titled “The Most Beautiful Code I Never Wrote”. It is written by Joe Bentley and it takes an unique look at the famed QuickSort algorithm. Without delving into the essay itself, Joe cleverly presents how the beauty of the famed QuickSort algorithm lies within the code that is not written at all. Two quotes I’ve highlighted from the chapter are:

“A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away” - Antoine de Saint-Exupery

“Simplicity does not precede complexity, but follows it” - Alan Perlis

I once overheard a seasoned developer say to a younger developer, “Develop a little, refactor a little. This is your mantra. Simple code simply works”. Developers who strive for simplicity, who strive to write code that not only “works” but “works well”, are developers who produce code with less bugs and require less maintenance. That is the extracted principle presented in this chapter and, ultimately, that is the difference between brute force workmanship and eloquent craftsmanship. 

Within each essay is a life lesson for anyone who is a practicing technologist and I highly recommend this book to anyone who fancies themselves as such. I suspect that “Beautiful Code” would fit nicely between “The Pragmatic Programmer” and “The Practice of Programming” on any development shop’s bookshelf.