Code Smells

יום שני, ינואר 3, 2011

If you like practicing in identifying code smells, then you can find below a short class called TimerManager. public class TimerManager { public delegate void TimerCallback(object data); private static readonly object _sync = new object(); private readonly Dictionary<int, Timer> timers = new Dictionary<int, Timer>(); private readonly Dictionary<int, TimerCallback> callbacks = new Dictionary<int, TimerCallback>(); public void SetTimeout(TimerCallback timerCallback, int snooze) { var timer = new Timer(snooze); ...

Writing Readable Code – Complex Object Construction

יום שישי, אפריל 16, 2010

Once upon a time, there was a class called Invoice. Its responsibility was to calculate a final price being presented to the customer. Time went on; The autumn passed, the winter fade out and the spring was already at the door and our class started to rust. Each time a developer found a new set of relevant parameters (that should have been passed to the Invoice class) he added a new constructor, to support them. And so it happened, that after...
3 תגובות

One pattern to rule them all

יום ראשון, יולי 26, 2009

Well, there is none... Simply to put, there is no silver bullet. Yet, while designing an application, there are several well known extremes: "Heavy weighted design" - Such a design will use almost each and every pattern described in the bible of "Design Patterns" - by the Gang of Four. However, squeezing as much as possible patterns into your design has a bad smell. Here is what Erich Gamma has to say on the matter: ...
2 תגובות

Dude, I blew up the Demo!

יום שישי, אפריל 24, 2009

I am sure, we are ALL familiar with the situation: Morning… The sun is shining, the birds are chirping… You are sitting in front of your computer, sipping a delicious cup of coffee. Then, in the corner of your eye, you spot movement; your VP Marketing approaches you with a big smile on his face: “Jonathan”, he says, “Just got important news, we have a big opportunity! We have been requested to demonstrate our super complex web analysis capabilities to a huge potential client. Could we build a quick demo?” You sigh and start coding… You don't sleep neither eat; you copy...
3 תגובות