My dear visitors

Hi my dear visitors,

Some of you seem to like (or fall by mistake in) my unfunny, unspiritual and crappy english speaking blog. I’m very glad you have such bad taste. You are more than 2 500 to come each month. You mostly come about some stuffs around the TC65, SVN, C# .Net or Sharepoint.

By the way, you consumed more than 200 GB of bandwidth this month, mostly on downloading the TC65 SDK. I’m really surprised, I guess a lot of people use this chip even if nearly nobody writes about it.

The waspmote

For those of you that take an interest in M2M and/or embedded things. You should look at the Waspmote.

This is a generic hardware that can be customized to fit any need.

  • Communication : GPRS / Wifi / ZigBee / USB
  • Location : GPS
  • Power usage : Low consuption, battery or solar as power input
  • Storage : SD Card (2GB), no other storage memory
  • Sensors : Everything you might need (really impressive set of sensors)

I looked at the API and it’s in C (pretty low level, you have to free everything) but everything seems to be handled at a high level. It’s sometimes better to have a smart C API rather than a dumb Java API. Look at the examples, they are really easy to read, you don’t need to be a skilled C developer to understand everything.

If the API seems great, the IDE doesn’t. But still I have just downloaded and tested it very quickly. It made me feel I was back on an AMSTRAD except that I didn’t have to put line numbers.

It seems the WaspMote is sold $100 for each card when bought in a package of 5.

Note : I know this look like some stupid buzz syndrome or planned viral advertisement but it’s not. It’s just a product that I’ve been interested in for years. This is the perfect product if you’re an M2M company. What ever you or your client wants, you can do it with this product.

Push (Comet) or pull ?

What is it ?
Most of the modern web applications display recently updated data, and to do that they need to get he latest data very frequently. Some of them even include some real-time chat (Gmail Chat, Facebook chat).

How ?
That’s the interesting part.

  • Pull is pretty dumb. You do a request very frequently and you see if anything new appeared. This consumes some bandwidth, some resources (because server has to check if data has actually changed).
  • Push is going back to the source : Once you’ve made the request on the server, it doesn’t reply instantly. It will wait for something before sending anything. So push over HTTP is in fact a pull with a sleeping response. Using push over HTTP is called Comet.

So pushing data isn’t very complex, it just requires a special server to transmit some data (text, html, xml, or image) over an already opened HTTP connection.

Why do we need some special servers ? Because our current servers aren’t build to make people wait. Some geeks made some example of PHP code being able to make some Comet response but they all use looping usleep. If you used it, you would end up totally killing your server with the growing number of clients.
This is the very interesting part of Comet : It doesn’t consumes more resources, it just requires additional server software.

Two types of push
They are two types of push :

  • The multiple limited time push requests or long poll mode : You make a request and each time you get the response the connection is closed and you have to make an other pull. It’s easier to implement but you could end up doing a lot of http requests, which means generating quite some data.
  • The streaming push mode : You open the connection once, and then data comes asynchronously, and the connection is never closed. If it “accidentally” closes, the client reopens it.

How do do some push enabled web applications
You rethink your software so that it uses the push server.

On PHP, you can use The Ajax Push Engine.
On pure .Net environnement, you can use WCF WsDualHttpBinding to serve data.
The CometD is a stable opensource comet server project. JQuery and Dojo can consume it.
You have LightStreamer, a commercial product with a free license. It can be connected with nearly anything (the only unsupported type of server seems to be PHP) or StreamHub which has a very restrictive free license.

Why some people still use Flex ou SilverLight ?
Http push / Comet requires a complex parallel server infrastructure and it only solves the push (server to client realtime data transmission) problem. When data is received, you still have to treat and display it. Managing this is a lot harder with javascript than it is in Flex ou SilverLight.

By the way, on flex, silverlight, flash, java applets you can use your own sockets to transmit data. This is a very good solution, there a good chance it will consume less bandwidth. But you have to remember that not using the HTTP protocol can create some problems as some companies block every other protocols on their internet gateways.

W3C is on it !
W3C is thinking about adding a WebSocket specification. This could be a very good thing as it would standardize this non-standardized part of the web.

Push outside the web
Push isn’t a web specific concept. Any instant messaging service (like MSN, Jabber, Yahoo or ICQ) does support push.

Any system supporting sockets enables you to make push enabled applications. If you consider the mobile OSes, they all support socket, so they all support push. Androïd supports push by socket, J2ME supports push by sockets, iPhone supports push by Apple push system or sockets and it seems BlackBerry supports it by the BlackBerry push service or sockets.

SVN : Go further

I’m not a huge fan of SVN. It’s crappy for file transfers and it easily locks. But still, it works pretty well for my relatively small needs and it’s super easy to setup. I’d like to talk a little bit about the things you might not know about SVN…

Hooks on the SVN Server
You might not know this but you can add a lot of personalized actions on your repository. You just have to add script files to the “hooks” directory of your repository. For a complete list of hooks file name, look here.
The two most important files you should consider adding are :

  • post-commit : This file is executed each time something is commited. With it you can send the change made during the last commit.
  • pre-revprop-change : This file controls what property you allow to change on your published files. It’s really useful when you want to allow people to edit some already committed logs.

Useful SVN properties on files and directories
SVN properties can be attached to files and directory to define special behaviors on the other clients or on the server. For a complete list of the SVN properties, look here. Here are for me the most important SVN properties :

  • svn:externals : Reference to an external SVN source. This is very useful, you can have the same files copied.
  • svn:needs-lock : This will force you to lock file(s) before committing them. This should be only use for special files like binary file that can’t be merged (Word can merge concurrent versions of the same file).

Quick note : A very bad idea I had was to put my SVN files within my dropbox folder. It creates a lot more locks than SVN normally does.

Displeased with 1And1

I’m really displeased with my 1And1 virtual server. I took it because I didn’t want to spend time on some potential disk failures. And since the Oct, 19 2009 2:00 AM, i’ve seen my load average totally exploding. I guess the disk was totally busy with an other virtual server.
I called them and they did a really awesome test : the PING test and even the web page test. I tried to explain them that this wasn’t the best way to test if the server was working, but well they told me that maybe I just messed up my configuration.

I managed to deal with my anger against 1&1 by watching some libdubs.
And today, two days later, the problem is fixed. Load average came back to some good values “0.00, 0.01, 0.00”.

By the way, you might not know what is the load of an UNIX / Linux server : It’s the number of running processes of the system. It should be inferior to the number of processors. The load is averaged by 1, 5 and 15 minutes.

Here are some sample libdubs just in case you’re too lazy to check :




NDepend

Patrick Smacchia gave me a professional license of NDepend v2.12 so that I could write some stuff about it if I liked it. As it was a gift (yes it is), I decided to force myself to look into this software. And after having looked much of its functionalities, I kind of like it. It’s not THE ultimate tool you have to use, but it’s a little bit like the other (resharper, reflector, etc.), it gives you a better insight of what you have in hand.

It’s a little bit like Resharper, it helps you see what you might have done wrong. Except Resharper tells it when you’re editing the code and NDepend helps you make a full review of the code.

Everything in this software goes around the Code Query Language (CQL). I thought this was some sort of commercial concept to sell more but it turns out that we can do a lot of things with it. It seems like a sensible idea, it’s SQL for the code. And the CQL textbox supports for auto-completion makes the CQL writing process pretty easy.

Don’t make it your judgment tool
I guess the most risky think to do would be to give NDepend to dumb people (like code quality reviewers that don’t understand much of what they do). They would end up getting on everybody’s nevers. Because I don’t think that all the code creating query warnings could be changed. I’ve taken the simple stripped down method example of the StreamRipper app :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private static Boolean ParseArgs( String[] args, Parameters parameters ) {
	try {
		for ( int i = 0; i < args.Length; i++ ) {
			switch ( args[ i ] ) {
				case "--url":
				case "-u":
					parameters.Urls.Add( args[ ++i ] );
					break;
 
				case "--user-agent":
				case "-a":
					parameters.UserAgent = args[ ++i ];
					break;
 
				case "--reconnect-attempts":
				case "-r":
					parameters.MaxReconnectionTries = int.Parse( args[ ++i ] );
					break;
			}
		}
		return true;
	}
	catch ( Exception ) {
		Console.Error.WriteLine( "Arguments error ! " );
		return false;
	}
}

This code will create a cyclomatic complexity warning (as it would in Resharper 5.0 [I should talk about this someday] with the cyclomatic complexity addin). So, for me, it’s clear you have to accept to have a lot of warnings. It’s not like resharper where you can solve all the warnings by accepting every little things he tells you to do (sometimes I’m resharper’s slave but I like it).

BUT, if you really want to make it your judgment call tool, you should really stick to this diagram :

You can see that in this project some of the projets are in the zone of pain and the zone of uselessness. Don’t worry. In the zone of uselessness we have the WCF contracts. It’s quite normal they are totally abstract. And close to the zone of pain, we have low level libraries. So, nothing to worry about.

If you WANT a quick and dirty rule : If your business logic core code is in one of these two red zones, you have a problem.

What I think it does well
I think it gives you a quick view of the software you’re working on : What are the main projects, classes and methods. What quality of work you should expect from it. The graphical view isn’t pretty but it gives you a good simplified view :

And anytime you have a doubt, you just double-click on the method and it opens it in Visual Studio.

You have the dependency graphical view :

It doesn’t look very useful like this. But within Visual NDepend, it displays the parent and child assemblies when you move your mouse over a project :

Evolution of your project
NDepend also saves the results of all previous analysis and allows you to show the evolution of your product. You can see easily what methods have been modified / added / deleted from one analysis to an other. Each analysis you do is saved and can be compared to any other later. This can be done on simple .Net assembly. This will allow you to see what has been changed between two version of an assembly. And with the help of reflector, you can see precisely what has been fixed/improved.

You can see a pretty good example by Patrick Smacchia : Comparison of .Net Bêta 1 and 2 with NDepend.

My thoughts
I think it gives you a quick and simplified view of the organization and size of a project. It’s great .Net tool, I would recommend to any company having big .Net projects. But you shouldn’t spend too much time on trying to comply with all its default CQL query checks as they are a little bit constrictive. If you do, you might want to increase the threshold values. And please take extra care before making judgment calls (it might be tempting).