-
C# and the StringBuilder class
This morning I was working on a project at work. It's a Web Application using the ASP .NET 2.0 framework and C# as a code behind language. My friend Ioannis came over to see what was I doing and when he saw I was appending some strings together he asked me this question: "are you using a StringBuilder to use those strings?". And I replied with this answer: "no, I am not". This kind of stupid dialog came over because last week we were discussing about using StringBuilders instead of the default String class operators to append strings each other in Java. It seemed using the StringBuilder class resulted in an overall performance gain. It was then when I asked: "don't tell me this happens with C#, too?". And he answered: "yes, it does!".
So, what's the matter with StringBuilders in C#?
-
Repeatable read and deadlocks in SQL Server
This week we had a bug report of one of our products regarding some strange deadlocks in our database access. For those of you who don't know what a deadlock is, I'll try to summarize here what a transaction is in a relational database environment and why those transactions might lead to those nasty errors, and try to explain what was causing this deadlock in our SQL Server 2005 engine.
-
Killing all rails logs with one Ctrl+C?
Well, this is my first post after holidays and it won't be very long.
Imagine you are developing a rails application. Usually you have:
- a terminal with the server to see what petitions are received.
- a terminal with a tail of development.log to see what happens with the database.
- a terminal with a tail of test.log if you are testing something.
This are a lot of windows... And the other day one friends was very happy and after asking for a while I discovered that the reason was the simple line showed above... With only one Ctrl+C you can kill all this processes :-)
script/server & tail -f log/development.log & tail -f log/test.log & tail -f ; jobs -p | awk '{print "kill -2 " $0}' | sh
-
The Double Check Design Pattern
One of the deficiencies of actual programming languages, specially those ones still widely used that are old, such as C or C++, is that they were designed having in mind the sequential programming paradigm. This usually means that those languages don't have standard ways to work with multithreading features, and you usually have to rely on third party libraries to develop thread safe software.
Today I'll be discussing a design pattern called Double Check, which can be widely used to manage the resource access, elimination and initialization in a safe thread way.
-
Ruby Quiz
Maybe one of the best ways to learn a new programming language is playing with it. Nowadays if you don't code in Ruby you aren't cool. I have to recognize that programming in Ruby is funnier than in other language and for the moment I don't have anything bad to say about it.
Well, I want to introduce Ruby Quiz. It is a collection of minigames prepared to learn Ruby (or to improve your skills). Every week they publish one game, and if you are brave you can send your solution to them and it will be public. I think it's one of the best ways to learn because you can compare solutions and find were you are weak in Ruby and redo your solution doing it smarter.