Wednesday, October 05, 2011

I've never been a fun of "Apple" as a company but I feel very sad. For the man, for the epoch, for something that is gone forever.
The introduction of the iPhone 4S which stirred so much controversy yesterday, looks almost like a spiritual act now.

Wednesday, September 07, 2011

Just found an awesome site which explains how to make everything from something else - Instructables.
If you ever had a desire to heat your house with DIY solar batteries, become a proud owner of a magnet-swallowing pulp or wondered, what old Altoids box is good for - and you have some spare time and persistent curiosity - that's your place.

Thursday, May 12, 2011

Great news! Jet Brains, the magicians behind Resharper and Team City, are out on a quest to save us from misery show us the light. dotPeek is their brand new .NET decompiler, still in early build, but live and kicking. I sincerely mourned the Reflector’s untimely “departure” and the timing couldn’t be better! The new tool is free-of-charge, which is against any commercial sense, according to the Red Gate. And I am pretty sure that Jet Brains will figure out some smart licensing, as they did with the awesome Team City (even if it won’t be free in the future, I’d rather pay for dotPeek, than Reflector).
The interface is pretty slick and should look familiar to Resharper users – it even has the same Usage windows! Tabs in the code window is definitely a welcomed addition. There are tons of other features which I didn’t have time to explore yet.
The only thing I am missing so far is the Reflector-style navigation using type names as links. There are few bugs, but remembering Resharper early days I am perfectly OK with it – Jet Brains proved that they can quickly react on user’s feedback. Application size is noticeably bigger, than Reflector but it will be probably eventually optimized down.
Undeniably the best part in this news – we have a choice again.

Saturday, May 07, 2011

How the heck does it work?! MSDN is surprisingly unhelpful on this matter (list of class members with couple of very obvious one-line snippets is a mockery of documentation).
Unfortunately, when configuring the IWorkflowInstanceManagement interface you have to be very precise. Let’s do it step by step, and while we are at that, let’s make the service implementation more WCF-compliant.1. Make your workflow service implement a contract. There won’t be a magic but rather a trick – the workflow service will think that it exposes an interface, name of which you typed in the ServiceContractName of your Receive shapes after {http://tempuri.org} (if you didn’t – do it) and it accidentally matches the interface with the same name in your code (or something similar to that).
In our case let’s name the XAML interface {http://TeddyBearStore.com/Contracts/}ITeddyBearService and our “artificial interface” - TeddyBearStore.Contracts.ITeddyBearService

2. Make WF service look like good old WCF. By default WF service, hosted in IIS is exposed as a magic no-name service: service tag is completely missing and only nameless ServiceBehavior allows some primitive configuration.

Very, very important for the Workflow Control Client – the service name must match exactly the ConfigurationName property (can be found at the top of the XAML file or in the Properties window in the workflow designer window).

4. Add standard endpoint description. They might be accessible by default but I did not bother to test this assumption, so add them in the web.config anyway. This is your last step for the service side.

5. Add client endpoints, one for your service (remember the “artificial” TeddyBearStore.Contracts.ITeddyBearService contract?) and another - for the Workflow Control Client functionality, which is essentially gives you an access to the AppFabricesque goodness. Note that the latter has /wce added to the address because the XAML service will refuse to expose both contracts from the same address.

["free community 30-day trial"] – … isn't our plan. We bought the website sqlserversentral.com a couple of years ago and there was similar concern from the sql professional community then. Since then we've kept the site free, removed most of the ads, upped the quality and multiplied traffic by 3 - there are now more than 850,000 members up from ~200,000 at the time of purchase. We've not ironed out exactly what we'll do with Reflector (because we've not had a chance to interact with the Reflector user community) but we bought it because it is popular and has a passionate user base - we'd be fools to damage either of those things. Simon Galbraith Joint CEO Red Gate Software

As it turned out he spoke the truth: there is no plans for the “Free Community 30-days trial” there is a “14-day Trial” version, it is a big difference, folks. Neither I can deny that sqlserversentral.com is still around – as a marketing tool, collecting emails from subscribers (oh, wait! I remember the site now – it is in my Google excluded searches list, because when you are in a hurry to find an answer, it offers you to register).

Wednesday, May 04, 2011

Don’t optimize your NuGet package libraries until you know exactly what are you doing. I screwed something up eventually, so when I tried to use the awesome “Add Controller” wizard, I’ve got “The term ‘Get-Scaffolder’ is not recognized as the name of a cmdlet…” error.

Tuesday, May 03, 2011

I would be definitely long done should I use my hammer familiar tools for the work, but I would miss all the fun. I am positively in love with MVC3 – the Microsoft team is doing an amazing job! Elegance with which they embrace the latest C# additions makes my cry Bazinga! Let me list some lessons I’ve learned so far on Crazy Project.

MVC3 Scaffolding – not just for Entity Framework

I almost got ready to bitch about MVC team again but discovered a neat expansion (it is fully expandable!) for the MVC 3 Scaffolding – in addition to default EF-centric and empty view templates it can use repositories. All you need to do is navigate to View->Other Windows->Package Manager Console in Visual Studio and type Install-Package MvcScaffolding. It would be nice to have them installed by default - all it does is generate CRUD-compatible Views and Controller and it really needs to know only the underlying entity type. It could cover 99% scenarios out there, including EF one.

MVC validation and Java Script manipulations

Building an interactive (Java Script-backed) form I hit a problem with the built-in validation (generated from Model validation attributes) – I was hiding some fields with Java Script but the validation was still firing for them. Quick search provided a solution: the Form element can be told to exclude fields decorated with certain class from the validation:

$("#myform").validate({
ignore: ".ignore"
})

Which means that no validation should be performed for a field decorated with the class=”ignore” attribute.

Unfortunately this didn’t work for me after I added the code snippet to my document.ready event (I guess, that I just misused the functionality but I don’t know better yet and hope for my audience help). As an immediate measure I had to change a bit the jquery.validate.unobtrusive.min.js file which is included with MVC3 template: right after success: a.proxy(j, d) text I added ,ignore: “.ignore”.

Similarly it should work in a wider scale: when ignore: “:hidden” rule is used instead, all hidden fields will be excluded from validation – the jQuery is smart enough to consider field hidden if it is inside a hidden container, like div tag. Search the jquery.validate.unobtrusive.js file for an unscrambled version of the code to understand better what it does – the resulting function should look like this:

I am new to MVC and jQuery, so I am stepping on the same mines, which my more experienced colleagues know by heart. I had this as my first jQuery exercise, which was returning a JSON list using AJAX get:

And GetItems action, which does the job, accepts only HttpPost verb, while another one by the same name throws back a HttpNotFound result (back to the nature!). The solution is not perfect, as POST is not that difficult to hack (of course I have a security on top of it) but at least it won’t be stumbled upon accidentally.

Shaping workflow service to WCF

The default implementation of the WF4 service, which can be seen in 90% of presentations, uses Service Reference. If you ask me it is a part of Poor Man’s SOA Toolset - an ugly and inflexible technique. Here is an excellent post about how to avoid it – “How to make a WorkflowService implement a contract”. A couple tricks with ChannelFactory and you have a Service Reference-less project!

Workflow correlation

The sad discovery of the day – workflow can not use the same operation twice. Which kind of makes sense and doesn’t at the same time. It is all about correlation – the area where WF4 shares voodoo magic with BizTalk. This particular post helped me to get better understanding the WF4 correlation. At least the sample is not using string-based correlation handler, unlike many others.

Thursday, April 28, 2011

The kind of idiot short-sighted developer in Microsoft, who came up with the idea of smart USB/SD cards reading has probably never owned a digital camera. Or never thought of getting one. Or never thought period.
Nothing ever has come out good after using this functionality – I have already had to reformat two SD cards (including one right in the middle of Florence which spoiled otherwise jolly supper) and just screwed up third one. Thank god, the Microsoft oversmarts haven’t decided to “help” me with auto-reformatting – it’s only logical.

Sunday, April 24, 2011

RavenDb is a relatively new (maybe subjective - I’ve heard of it just few month ago) document database built on .NET and for .NET.

It is an extraordinary little (course from user’s point of view) thing which allows to start writing application without extensive database preparation and schema manipulations. It clicks perfectly with MVC, although I am still to discover a similarly elegant technique for Workflow Foundation. Raven Db recognizes property named “Id” (exactly capital “i” and lowercase “d”) as an entity identifier and has some optimization around it, so it is wise to make this field the entity’s identity field. It is even more wise to make it string and assign the value manually while inserting, e.g. using Guid, otherwise you will end up with engine-generated keys like “movies/323” which are deadly for MVC or REST services.
The only problem I’ve noticed so far (and the documentation is scarce on this) – decorating Raven-served documents as a WCF service contracts. I found that some of my workflow variables, which I store in DB, often require to be service contracts.

It worked perfectly fine in the code until all the sudden I’ve started receiving errors when trying to retrieve the entity from the DB: Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: Required property 'Id' not found in JSON. With decoration removed, the entity retrieval worked perfectly well. What was strange is that in both cases the document stored looked exactly the same (Raven Db installation includes very helpful Management Studio executed in Silverlight):
The error seemed to only affect “Id” property, which is “invisible”. Obviously something was interfering with JSON deserialization of the object. The Raven API provides great deal of serialization customization but I decided to find laziest easier way to fix the problem.
As it turned out the DataMember attribute was the one to blame. I believe that it is more likely to do with Microsoft’s oversight in DataMember implementation (despite being a member of Serialization namespace it is not being recognized as Serializable) while RavenDb proved to have a perfect reason behind most peculiar decisions. The solution is to add an additional JsonProperty attribute to the troubled field:

Monday, April 18, 2011

I believe that learning is only effective when it is forced on you by a real need. So far the most efficient learning experience I remember was stimulated by a lunch-and-learn session, where I was supposed to deliver a topic I had no previous knowledge on. The session was scheduled to happen a week after I was notified about it, so since then I am expert in aware of existence of Design Patterns.
Armed with that experience I decided to use technologies, new to me, in my next project (thankfully, relatively small). I am Web Form/SQL Server/Subversion junky so the following was brought in to widen my horizons: Workflow Foundation 4.0 as a back-end engine, MVC 3 Razor as a front-end and Raven DB as a database storage. To cap it up the project will be stored in Mercurial SCR. The only treat I’ve allowed myself is the usage of the excellent (as usual) Windows shell extension – TortoiseHg.
A couple of days into the project it works as expected – deadline is approaching, I am panicking. Hopefully, the sweet fruits of knowledge will follow…