Archive for February, 2013

When should you use CQRS or event sourcing?

February 28th, 2013

I am currently in the process of helping migrate our current legacy application to an event sourced system, also known as a CQRS (Command Query Responsibility Segregation) system.  We have had some pitfalls for sure and I wanted to outline some of that in this post.  We went with the LOKAD system which can be found here: Lokad Project.  It has hooks into the Microsoft Azure cloud solution so it was a great starter for us to get rolling with that.

The system actually ran fine for quite a while just getting data in and out, things were working perfectly until we decided to throw a lot of commands at the server and see how that processes that.  Rinat Abdullin, the creator of LOKAD outlines that here: Lokad Event Store is slow, we were using the azure blob storage and all that serialization/deserialization causes some serious performance issues when you multiply that by n number of times.  We have moved to the Event Store written by Greg Young found here: Event Store.  This speeds up the writes of the LOKAD system when it comes to the events but still didn’t solve the problem of our read models and how this system likes to make these projections.

If you have been following some of my blog posts in the past, you would know that I have done some research with couchdb, well a co-worker at my work place has been doing a lot of research into Couchbase which leverages couchdb with memcache.  I already liked it cause they used couchdb and I knew how performant that was, what I didn’t know was that it caches a lot of the calls and data, so its in memory and extremely performant.  Our plan is to replace our current readmodels being stored in the azure blobs, which can get quite large, so the serialization/deserialization in some situations can bring performance down to a crawl, to be stored in couchbase.

Anyway, back to my original question, When should you use CQRS or Event Sourcing?  My advice would be to analyze your companies requirements and ask yourself if a system like this would truly give you a reward worth the investment?  My personal opinion is for most business applications it is not needed or necessary to track the intentions or actions on data.  There are some business use cases that I could see it being good for, take banking for instance, its critical to know how the money got from point A to B, or accounting, again mission critical.  Greg Young says he does not like Case Studies, that they are too gimmicky, read his post here: Greg Young Case Studies So I still cannot find a really good case study but I did come across this guys blog post which pretty much sums my overall views on the pattern: A Year in review with cqrs he pretty much came to the conclusion that he doesn’t use the pattern for its intent and a key/value store would have done the job just as well.

There are people out there that think most all applications should be written with this pattern, all I am saying is look at what your needs are and make a judgment call there. I am potentially looking at making a mobile version of a website I worked on with a friend, there is no way I would implement an event sourced system in this situation, it won’t make sense and my client is not going to pay for it, you have to factor in the time it takes to model out the domains and figure out what actions are to be performed on the data.

If you are currently implementing a system like this, I welcome your comments, feel free to leave em, you won’t hurt my feelings. I too am trying to see the real value in a system like this.

Google 2013 IO Conference

February 25th, 2013

Awesome!! It looks like my company has ok’ed me to attend this years Google IO 2013 conference. Each year Google does a conference for developers covering a wide range of topics from Android development to web development. I am particularly interested in the web development of course. I hope this year they do it just like last year, break the sessions up into tracks, you either choose to take the Google related tracks or you can choose to take the web development tracks. And of course its rumored that all attendees will be receiving Google’s first phone code named X. The biggest problem from what I have read about the conference is that it sells out so fast its really hard to get a ticket, and last year the system went down during registration so a lot of people did not get to attend. Here’s to hoping that I do get to attend so I can come back and blog all about it :).

Here is a link to the registration page: Google IO 2013

Error trying to run C# SDK for Couchbase

February 20th, 2013

If you are going through the tutorial on this page: Couchbase Tutorial and you get an error right off the bat trying to instantiate the CouchbaseClient with just a simple call like: var client = new CouchbaseClient(); then you probably have your app.config in the wrong order. Contrary to what they are saying on the couchbase site, refer to my config file below to get your stuff up and running correctly.

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
  </configSections>
  <couchbase>
    <servers bucket="default" bucketPassword="">
      <add uri="http://127.0.0.1:8091/pools"/>
    </servers>
  </couchbase>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
</configuration>

The big gotcha is the where I had the runtime line placed, if I had it at the top, it would throw the error, but if you have it as I am showing here, it seems to work fine.

Select2 3.2 Add Custom Clickable item to dropdown.

February 15th, 2013

There are a few folks asking how they can insert something to the bottom of the Select2 javascript control and I have came up with a solution as shown below in my jsfiddle.  All I am doing is making use of the query function that select2 provides as outlined here: Select2 Documentation.  Also take note of what I am returning in the results, basically I am making use of select2’s ability to create grouped headers and use a “children” parameter to show that list.  All I had to do was add in whatever I wanted my bottom link to say and voila, I have an entry to allow the user to click on and perform an action.

NOTE:  Newer versions > 3.2 do not show html as output, the newer version of the control is overriding the output somehow and just rendering the text, I was too lazy to figure out what is going on so I just thought I would give a heads up.

UPDATE:  The Select2 (currently at 3.4.5) control has been updated with the escapeMarkup parameter, simply add a line like this to your options of your select2 element:  “escapeMarkup: function (m) { return m; }” and you can have clickable links back in your dropdown.

Here is the pull request for it: https://github.com/ivaynberg/select2/pull/1817?source=cc

Value cannot be null. Parameter name: instance regarding active reports

February 14th, 2013

Are you getting a error screen when you try to open your Active Report design files similar to this one?
screenshot

I was beating my head into the wall trying to figure this one out and finally simply removing all the active report references I had in my project and adding them back in, then doing a Build->Rebuild Solution did the trick, hope this helps.

Need a simple CSS layout for messages?

February 12th, 2013

I am working on a phonegap side project and I have a need to display a list of messages that users will be entering into a system and I couldn’t really find a good example online so I wrote one using pure CSS and Javascript. All you need to do now is hook it into a templating library and you got what you need, enjoy!!

http://jsfiddle.net/eddie_d_2000/WNyPt/embedded/result/

Dynamically assigning css properties within the razor syntax.

February 9th, 2013

You may already know this, but I thought I would share anyways.  When you are writing asp.net webpages and you are loading the data dynamically through the razor syntax, it isn’t enough to just wrap your logic inside a <div> that has a class applied to it, you need to assign the css class within in the razor syntax.  The snippet below is an example of how you can assign a css class within the razor syntax:

@Html.CheckBoxFor(x => data.Selected, new { @class = "checkbox" })

The thing to focus on is the end of the snippet, the “, new { @class = “checkbox” }”  in that example I am setting the class name of the checkbox to a css class I have that styles the checkbox the way I want it to.  I couldn’t really locate an extensive list of these HTMLAttributes, so if you know of anything, please send me a link and I will update this article, thanks!!

 

A script in this movie is causing Adobe Flash Player to run slowly, in Google Chrome

February 7th, 2013

flasherror

You may be getting this error when you try to go to a website or if you are testing a web app and have a UI that has several clicks and this pops up.  Well, this error was randomly popping up on me and for the life of me I couldn’t figure out what was causing it, I am still not sure if what I have done fixed my problem but so far it hasn’t come back and I have tested it pretty hard to make sure it doesn’t.  To fix this issue in chrome all I did was go to the settings by clicking on the top right corner and clicking on settings and then going to “Extensions” and looking down thru that list and either unchecking the box for “Enabled” or just clicking the trash can to delete it.  As I said, I haven’t had anymore problems out of it so far, so everything seems cool.

How to delete your Web SQL databases in Google Chrome

February 7th, 2013

I am working on a project that makes use of the local web browser storage to cache some items and I noticed when I am in webkit in chrome there is no way to delete my Web SQL database, well I have finally figured out how to at least get rid of them for testing purposes.  Just simply open the run command and put this in there %USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\databases, that is the directory you want to clean out to start over again with your local databases.  Don’t forget to shut down all instances of chrome, you may need to go to the Task Manager and end all the chrome processes if you try to delete the contents of that folder and it doesn’t allow you to.

Need a COBOL job??

February 6th, 2013

Screen Shot 2013-02-06 at 8.21.14 AM
I post this out of humor for my fellow software developer friends cause I know how most feel about writing in COBOL.  I keep thinking its a dying language but here is someone looking to hire me to write this stuff.  I know its a proven language and it runs on mainframes and you can trust it, thus why banks are still using it to this day, (this is actually a banking company that uses this).  I just would have thought by now (30 years later) that companies like this would be doing this kind of computing in some other fashion, is this the best there is for data processing?  I have talked to some of the people that work at this company and they say that its gotten better to write COBOL, meaning the IDE and tools are getting better, not the language.

If you need a job, here is a posting for one, just leave me your contact info and I will pass it along.  This job should pay good since there just aren’t many out there that are wanting to do COBOL development and I am sure colleges are still teaching it for this reason.  I know I wouldn’t want this job, unless it paid truckloads of money and I could retire in a year, which I highly doubt it does.