May 2009 Blog Posts

Isolating the domain model from your view

When working with the ASP.NET MVC framework I have a strong urge to not pass my domain models directly to the view (and I feel that's a good thing). Actually, I should refine that. I do not pass my domain models to the view as a domain class. Let's investigate. My model at the moment consists of a class called Contact. It's very simple: public class Contact { public int Id { get; set; } public string LastName { get; set; } } This class is populated with data from my datasource (a static List<Contact> for now), and later on it'll be used...

posted @ Wednesday, May 13, 2009 10:30 AM

Moved! Well, sort of…

Okay, I’ve moved to my own host, using subtext as the blog engine. I’ve also renamed my blog to SmoothFriction.nl, to match the URL I am using right now. Thinking hard to come up with a good subtitle now, but the URL is here to stay. I’m also in the process of fixing the old posts which got a bit scrambled when moving here, as well as adding the SyntaxHighlighter javascript to get those really cool code blocks. Stay tuned! Note: If you're using feedburner on my blog, the url won't change. So you should still get the updates.

posted @ Tuesday, May 12, 2009 2:13 PM

A simple refactor step

Here's a short snippet from me to think about. Say we have a some code which retrieves a list of orders from a datasource. The part of the application using this functionality looks like this: public class OrderProvider { public ICollection<Order> GetOrdersFor(Customer someCustomer) { ICollection<Order> orders = CallSomethingHereToFetchOrders(); return orders; } } ICollection<Order> orderlist = OrderProvider.GetOrdersFor(someCustomer); if(orderlist == null || orderlist.Count == 0) { //something is happening here// } else { //something else is happening here// } At a glance, someone I showed this to said there was nothing inherently wrong to this snippet. I care to disagree. What's wrong here, in my opinion, is that the provider doesn't have a unambiguous behavior as far...

posted @ Tuesday, May 12, 2009 2:10 PM

What makes developing good PHP applications hard

Jeff Atwood (@codinghorror) recently twittered an url to a blogpost from the guys at OpenX.org about their optimization tactics used for their OpenAds framework. All I can say is that the state of PHP at this moment is abysmal. I'll explain why. The writer speaks about three rules they applied when optimizing their code, being: Forget about so-called 'common sense' and trust only a profiler; Use the minimalist approach; Optimize for real life scenarios. I can only agree with these rules, as they should count for...

posted @ Tuesday, May 12, 2009 2:05 PM

Why I hate developing in PHP

This is wrong at so many levels: if($this->mail_protocol == "pop3") { $port = "110"; } else { if($mods["imap"]["SSL Support"] == "enabled" && ($this->ssltype == "tls" || $this->ssltype == "ssl")) { $port = "993"; } else { $port = "143"; } } Whoever can name the most anti-patterns in this small snippet wins a honorable mention in the credits of this post.

posted @ Tuesday, May 12, 2009 2:03 PM

Taking a step back

So I recently started a personal project with a friend/developer, to try out serious development with ASP.NET MVC. Inspired by Rob Conery’s MVC Storefront/Kona series, we want to try out setting up all parts of a proper environment (automated builds, continuous integration, version control, the works basically). Learning by doing, more or less. So far, we’ve only just started. We assessed that we want to build an application for record keeping, contact records to be precise, as we’re both interested in keeping our client relations in check. Our first “milestone” is to create a system to insert, delete update...

posted @ Tuesday, May 12, 2009 1:39 AM