Category Archive for Links

Win32 API from .Net application

When you use .Net, you sometimes need some old win32 api’s. Even if a managed environment is really appreciable and confortable, there are some part of windows you can’t access from C# or VB .net code. Then you often have no other choice than rely on old windows system calls.

This generally implies a lot of marshalling and interop to wrap unmanaged windows functions into nice managed .Net namespaces. And this is also true for mobile developpers interacting with Windows CE dll, see Interop for .Net Compact Framework.

I just discovered that  a couple of Win32 functionnalities are already bundled in the Microsoft.Win32 namespace of the .Net framework.

Another great resource for COM interop is the P/Invoke wiki !

And for those who are (still) more familiar with the old school windows functions, you can refer to this map to find your way in the .Net environment.

Groovy ecosystem

Among the devoxx 2008 university slides, you can find a Groovy/Grails presentation. This document contains interesting references:

  • Griffon is a Grails like application framework for developing desktop applications in Groovy. You can begin with the quick start guide.
  • Gradle is a build system like Ant, Maven or Ivy but trying to get the best from all. It supports multi-project build and  dependency management. And you still can use you old Ant tasks.
  • Easyb is Behavior Driven Development framework (BDD). It uses a specification based Domain Specific Language (DSL).  The main idea is to keep really close to the business needs all along the development process. With this tool you’ll have a readable documentation AND a unit-testing all-in-one. You may start by reading first this tutorial.
  • Compass is an open source project built on top of Lucene, to simplify the integration of search capabilities in your java applications .

And of course you can still refer to the Groovy and Grails websites.

.Net auto update application

I’m looking for a way to insert an auto-update functionnality in a .Net application.  So far, I found only 3 approaches to easily update an application:

  1. Microsoft Patterns & Practices provide an Updater Application Block v2.0. An application block is a kind of reusable and extensible module. This specific application block provide a quick and easy mean to add self updating capabilities to .NET-based smart client solutions, like Windows Forms applications. Here you can find the Introduction, the Design overview and an article on how to use this application block.
  2. Sharp AutoUpdater is a library providing an auto-update feature for .NET applications. It relies on XML configuration files and handles the detection of a new version, downloads, unzips, and installation of the new files.
  3. Microsoft also has a ClickOnce deployment solution that handles updates. It is similar to the  java webstart solution. You can find more information here, in this article or among the wikipedia external links

ClickOnce seems fully integrated in a .Net environment, but as far as I know there is no solution to use a standard webserver (not IIS) to handle updates. I should definitely give it a try and see if IIS is really mandatory or if you can use some workaround.

Do you know other methods? Sometimes deployment tools include auto-update container to bundle an generic updater with your application (like install4J).

Mad Money with Eric Schmidt

Hello ! I just wanted to share a video on CNBC – Mad Money where Jim Cramer interviewed Eric Schmidt (Google CEO) about how US could “change”. They also talk about creation of new white color jobs since the tech employees are also highly impacted by the recession.

Eric Schmidt On Tech Jobs

Pex or automated white box testing .net

Microsoft Research - Pex automated testing .net

Yesterday, I randomly discovered a new tool for .Net to help developers with code testing. Microsoft Research has developed Pex, a test plugin which can be integrated to Visual Studio. So far nothing is really new, right ? But, say you’re as lazy as me when it’s about writing unit tests, you should definitely go look the official Pex homepage.
To be more specific, Pex automatically discovers interesting test paths. It finds interesting input-output values for each method and generate a test suite offering a pretty high code coverage. The keyword being “generate”, which means less time on testing and more on… (suit yourself).

At first sight, I must confess this may sounds a bit magical.  So how does it work?  Pex performs a systematic analysis, hunting for boundary conditions, exceptions and assertion failures, which you can debug right away. Bringing all this together, Pex offer a new approach to Parameterized Unit Testing and will hopefully reduce debug time and maintenance costs. This general test technique is also referred as  white box testing.

You will find extra information on this slideshow or on the Pex documentation section. Channel9 offers a “getting started” video as a tutorial on how to use Pex inside Visual Studio 2008. Microsoft Research has also a document about Parameterized Unit Tests.

Also let’s stay cautious: automated or generated tests are not THE solution to avoid code inspection and application stress. As a responsible developer, you should use tools to ease your life and make your products better. But never be too confident when it comes to magic black box software making your job ;)

Looking for a java html parser (or groovy)

I’m currently looking for a java library (or groovy one) to parse html. As you know, most of the time webpages are not as clean or valid as they should be, so the ideal tool should be somewhat tolerant to poor html code. After some initial homework, here is a list of potentially useful libraries:

  • Jericho HTML Parser is a java library allowing analysis and manipulation of parts of an HTML document, including server-side tags, while reproducing verbatim any unrecognised or invalid HTML. It also provides high-level HTML form manipulation functions.
  • MozillaParser is a Java Html parser based on mozilla’s html parser. it acts as a bridge from java classes to Mozilla’s classes and outputs a java Document object from a raw ( and dirty) HTML input.
  • HTML Parser is a Java library used to parse HTML in either a linear or nested fashion. Primarily used for transformation or extraction, it features filters, visitors, custom tags and easy to use JavaBeans.
  • NekoHTML is a simple HTML scanner and tag balancer that enables application programmers to parse HTML documents and access the information using standard XML interfaces.
  • JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML.
  • HtmlCleaner is open-source HTML parser written in Java. From a (dirty) HTML document, HtmlCleaner reorders individual elements and produces well-formed XML. The process is like the creation Document Object Model (DOM) in browsers. But you can provide custom tag and rule set for tag filtering and balancing.
  • TagSoup is a SAX-compliant parser written in Java able to parse wild or nasty HTML as found on the web. A C++ port of the library is also avalaible.

The last 3 items are more cleaning tools intended to output well-formed balanced HTML code. Anyway, as JTidy have to build a DOM object of the HTML, you may use this to elegantly access data from your raw/dirty html source.
So for the time being, I would probably focus on Jericho HTML Parser and HTML Parser who seem the best candidates for the job. Moreover, they offer documentation and samples to get quickly started. I you already tried any of these, I would be happy to hear your recommandations.

On the other hand, if you need a generic parser, I would recommend JavaCC or JParsec. And if you are not satisfied yet, you may still look on java-source.net directory.

Now, let’s also talk a bit about Groovy, I only find 2 basic articles about parsing HTML in a Groovy way:

  • http://groovy.codehaus.org/Testing+Web+Applications
  • http://blog.foosion.org/2008/06/09/parse-html-the-groovy-way/

… which seems quite limited, so I should probably import some of this POJA (Plain Old Java API).  Or maybe you can point me other references?