SmoothFriction.nl

posts - 39, comments - 20, trackbacks - 0

November 2009 Entries

ASP.NET MVC: Tricky modelbinding feature (?)

I just ran into a situation which could lead to very annoying latent bugs in your web application. Observe the following code. The view: <form method="post" action="Photo/Save"> <input type="text" name="Photo" /> <input type="text" name="Title" /> </form> The Controller action: public ActionResult Save(PhotoDTO photo) { // do something with the object return RedirectToAction("Index"); } The class: public class PhotoDTO { public string Photo { get; set; } public string Title { get; set; } }   At first sight, there’s nothing wrong with this code. You’d say when the form is posted, the PhotoDTO object gets...

posted @ Thursday, November 26, 2009 12:24 AM | Feedback (0) | Filed Under [ c# asp.net mvc ]

.Less twitter love

I just checked our analytics after I noticed a bit of retweeting going on after Jon Galloway picked up .Less. Can you spot at which points in our graph twitter was flooded with .Less tweets? I thought so ;-) I’d like to use this oppportunity to thank everyone for bringing us extra publicity! Thanks!

posted @ Monday, November 23, 2009 3:33 PM | Feedback (1) | Filed Under [ general .less ]

About the .Less project

I had a short twitter conversation with Aaron Jensen on the decisions we made developing .Less. As I’ve blogged about before, for me personally it was more of a learning project than something with a set goal, at first. That aside, I had one thing in mind: being able to use less during development, without having to worry about it, add a handler and go! Less.Net, v0.1 My first solution was to simply install ruby and wrap the whole system call in a HttpHandler. Very clunky, but it worked! I blogged about this a while ago: Using LessCSS...

posted @ Sunday, November 22, 2009 10:30 PM | Feedback (2) | Filed Under [ general c# asp.net .less ]

The importance of specifying your locales

Lately I’ve run into several bugs which were caused by developers incorrectly assuming that the default locale settings were good enough for parsing a value. I’ll show you what I mean. Case 1 Consider the following snippet: .something { width: 21.4em; } This is a simple CSS rule, making all elements with class ‘something’ have a width of 21.4em. In .Less, we parsed this without an explicit locale. The output would only show 21em, truncating the value from the implied decimal separator onwards. Once we set the locale to Invariant (who needs specific locales in CSS?),...

posted @ Saturday, November 21, 2009 1:24 AM | Feedback (0) | Filed Under [ general localization ]

Getting started with TeamCity : Installing

For .Less we use TeamCity by JetBrains for continuous integration. Whenever one of us commits to the master branch, the server notices, runs the tests and produces the binaries we need. When one or more tests fail, the committer gets an e-mail to make sure build errors are noticed as soon as possible. Working like this reduces the friction a lot when working with a team: members of the team are getting direct feedback if something goes wrong, AND there’s always a source for the latest binaries for anyone who likes to run on the bleeding edge. Daniel set...

posted @ Thursday, November 19, 2009 5:54 PM | Feedback (0) | Filed Under [ Continuous integration TeamCity ]

Introducing the Smooth Friction testdata generator (v0.1)

Between work, .Less and other things, I’ve been working a bit on a tool I would personally use. How many times did you just need a big set of test data for an application? How many times did you resort to simply dumping randomly generated data into your tables? Well, I’ve did that a few times, and one of the biggest annoyances is that the generated data is usually not really ‘real’, if you know what I mean. Say I have an application which has keeps customer records. I’d have a name, address, maybe some dates, something numeric and...

posted @ Thursday, November 12, 2009 12:27 AM | Feedback (4) | Filed Under [ general testing ]

A tricky situation with the IEnumerable<T> interface

Recently I ran into a situation which isn't very obvious at first glance if you don't know how the Linq to objects extension methods work in C#. If you know how the IEnumerable<T> works in combination with the various extension methods in the System.Linq namespace however, you’ll quickly see what'll go wrong. Observe the following snippet: List<int> source = new List<int> { 1, 2, 3, 4, 5, 6 }; var filter = source.Where(x => x > 4); foreach(var listitem in filter) { // do something with the value // source.Remove(listitem); } This will throw an InvalidOperationException, stating that the collection has been changed. If you don’t...

posted @ Friday, November 06, 2009 5:29 PM | Feedback (0) | Filed Under [ c# ]