
I decided to move my blog from WordPress to Jekyll. My new blog is here: http://gal-segal.net.
I decided to move my blog from WordPress to Jekyll. My new blog is here: http://gal-segal.net.
Log4Net is an industry standard for logging. Almost every developer uses it in some point in his/hers professional life. I am no exception, and I needed to write a LogManager wrapper and unit test it.
It is a common matter to have an operation in the server that requires few steps. Sometimes it is necessary that all the steps will complete successfully, and if one fails, a rollback should be made. SQL has the transaction term to support this kind of situation, and I’m about to show how it can be done in code.
OO Programmer tend to use inheritance as a way of code reuse, a best practice and for better maintainability. I am no exception. But there are times where inheritance can become your worst enemy, and instead of making your life easier, complicate stuff to the point you are lost.
WCF enables us to consume a service in 2 ways: adding a service reference or by creating the proxy yourself. Both methods do the same thing – create a proxy class and and using it with the channel factory. Both cases are good, and its a matter of preference which one you use. I tend to use the second one – I prefer creating my proxy and add reference to the service dlls in the consuming app.
Lately I was busy creating a new infrastructure for our logging system. I work on OpenBook – a website that gets a lot of traffic and involves with many different business processes. I started logging errors, info data and more with the excellent log4net to files, but has the logs got bigger and longer it became almost impossible to track it. We also use several IIS servers behind a load – balancer, and the result is a lot of logs on many different servers.
I wanted to create an infrastructure that will be able to have the lowest footprint on the production server, but still be able to log a lot of message to some storage (SQL server, NoSQL server, files..).
ReaderWriterLockSlim was introduced in .net 3.5 as a better and more stable locker that allows multiple reads and single write capabilities on a synced resource. Using it is fairly a simple task: for reader you wrap your resource with “EnterReadLock()” and “ExitReadLock()”, similar approach for writing. But problem lurk around the corner when it is not used correctly…
When moving a web application from WebForms to MVC framework I found sometimes “.aspx” and “.ashx” URLs from the old website sniking into my new clean and carved URLs. This issue can be addressed specifically by targeting the relevant “aspx” URLs and redirecting to a desired place, but it can get a bit messy. I found a more generic way of doing so by creating a new “Legacy Route” that will redirect all legacy requests to the new home page
MVC and Output Cache are a good match, and since MVC3 this match is even better. But there are some occasions where this match is not good enough. I recently discovered an unwelcome behavior when dealing with ajax and had to come up with a solution.
Many times I need a small piece of code that will help me map one object to another. I see it a lot when dealing with view models : taking a business object and modeling it to serve the needs of the presentation layer.
So I came up with a simple extension method: