вторник, 13 сентября 2011 г.

Calculate LOC with one line of code

Found a very useful tip on how to quickly estimate the size of a project with only one line of powershell script.
Navigate to the root directory of your project and in powershell type the following:
(dir -include *.cs,*.xaml -recurse | select-string .).Count

Thats it. 
Good luck!

четверг, 11 августа 2011 г.

Execute Caliburn coroutine in action pipeline without UI trigger

Seems rather easy, isn't it?

Just put it into Presenter's Execute method and the did is done. Well, should it be like that I wouldn't wake up in the night and write this stuff!
Let's see what's there in Execute:

So, it just packs every single coroutine it has in SequentialResult and execute 'em. No filters pipeline used, no routedMessage. None of your neat filters applied to these coroutines.

You might ask what is the difference with executing coroutines as a result of some UI action, be it a routed event or a command. The answer is in the Caliburn.PresentationFramework.Actions namespace.
To be prrecise it is an Action Execute overloaded method that in simple case of SynchronousAction does the following:

namely calls preprocessor filters, delegates a call to method that might be returning coroutine, handles errors with rescue filters, calls postprocessor filters. That is a filter pipeline I am talking about.
Well, seems that Caliburn has everything I need. And all I have to do is just use it.

As header states there is no UI trigger, i.e. I want to execute a coroutine when nobody clicked a button, but rather on some external trigger. As an example, consider model update with call to any data storage during Presenter initialization stage.

Enter DegenerateMessage. This intellectual piece of code is a data container that is being handed to participants on courutine call pipeline in order to hint what was the original method name called.

Another intellectual piece of code is DegenerateMessageTrigger. It is so damn smart that it knows that in order to trigger an action it has to pass a message to message handler!

And yet another piece is a DegenerateMessageHandler. It really shouldn't be called that way as it performs really complicated things. Namely, it creates an ActionHost and when Process is called converts DegenerateMessage to an ActionMessage and put it into the standard Caliburn action pipeline.

If it seems like dancing on your head, then know that you are not alone. But wait, there is another part I forgot to mention. It is a simple interface IResultExecutor aimed to hide all that smart code under two methods accepting Expressions with lambdas calling methods that return coroutines.

Oh, and there is yet another thing. With Caliburn Micro you can accomplish the same with only one line of code.


четверг, 4 августа 2011 г.

The best explanation to ESB ever.

I've finally managed to reread some of old Udi's articles and suddenly realized that following few lines are the best explanation of what ESB is all about, ever.

I never want to miss it again that is why I repost it right here in my blog.

"it’s all in the message. Forget about remote method invocations and pub-subbing events—down on the wire it’s all just messages. The trick is to think of your system as passing messages at the application level as well.

Asynchronous message passing over queues. It’s really quite simple.

Once you’ve packaged everything into the message, that message can be dynamically routed anywhere, and so can its responses. The application doesn’t need to bind against any specific endpoint—it just drops a message addressed to some logical location. Infrastructure can make sure that messages get to the logical recipient, even if they change physical locations.

That infrastructure is what brings about the “Bus” architectural style between your distributed components."

As Udi says, you have to reread it several dozens of times, until it strikes to you.

Good luck!

вторник, 19 июля 2011 г.

Git ftp deploy

With tools like git, NServiceBus, RoR and the rest, life seams to be better then ever.

With git I've managed to setup deployment with a matter of minutes. Just like this: http://blog.wekeroad.com/2009/11/23/deploying-a-web-application-with-git-and-ftp
There are other ways, probably even simplier: http://ayende.com/blog/4836/primitive-git-auto-deploy

Good luck!

воскресенье, 5 июня 2011 г.

Django newby frustrations.

As you might already guessed, I am currently in a process of discovering two technologies I had no experience with before.

This time I met a strange error running a Django tutorial web application: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0...

Good luck!

RoR newby frustrations

As usual, trying to adopt something new is really is a frustration. And though Rails is about to be "a breakthrough in lowering the barriers of entry to programming" you will defenitely meet some errors that might stop you on your way.

First thing I met was: "[rake --tasks] rake aborted! no such file to load -- sqlite3/sqlite3_native".
The solution is really simple. Rake is telling you that it can't find a native library for sqlite. Well, just do what you've been told. Give it a sqlite.dll/.so (depends on OS you are). Put it in $ruby_home\bin.
Next thing to immedeately pop up, after I gave it what it wanted was: "[rake --tasks] WARNING: Global access to Rake DSL methods is deprecated." This one is not as obvious as former. Solution to this one is desribed here: http://benwoodall.com/2011/06/rails-global-access-to-rake-dsl-methods-is-deprecated/

That's it for now.

Good luck!

среда, 1 июня 2011 г.

Installing rails on windows

If you tried to install rails with gems and failed with message "...No such file or directory" - dont woly be hapy. Just folllow these instructions: http://stackoverflow.com/questions/849660/how-to-stop-the-gem-utility-from-accessing-my-home-directory

Good luck!

вторник, 24 мая 2011 г.

JetBrains dotPeek to rescue.

I don't know how you faced the fact that Reflector is no longer free, but I for one was very-very dissapointed. Now, our favorite JetBrains team comes to rescue with their brand new tool called dotPeek.

Go and get it here.

PS. Five minutes later I found another tool that will compete to take Reflector's place - JustDecompile from Telerik. It is here.

PPS. Also, there is a work being done for Silverlight by Denis Vuyka and there is another OSS tool to compete for our souls - ILSpy.

PPPS. Life is good again.

Good luck.

понедельник, 16 мая 2011 г.

NServiceBus Saga Idempotency

Should your business entities had a natural identifier (I think even a surrogate one would do in this case), it would be trivial to ensure idempotency of sagas, that drive their processing.

Just store that Id in a temporal saga storage and enqueue a handler that will guard your sagas as the first handler in NServiceBus endpoint pipe. Something like this one:
And don't forget to specify message handling order:

Good luck!