0

What’s Wrong With This Code (#23)

Posted by K. Scott Allen on Oct 18, 2009 in Dotnet  | View Original Article
 

Keith Dahlby started a discussion with his post “Is Functional Abstraction Too Clever?” Read Keith’s post for the background, but I would agree with all the comments I’ve read so far and I say the functional approach is a good solution to the problem.

Keith’s post did get me thinking of things that could go wrong in the hands of a developer who doesn’t understand how in-memory LINQ is working.

As an example, let’s use Keith’s Values extension method …

public static IEnumerable<int> Values(
    this Random random, 
    int minValue, int maxValue)
{
    while (true)
        yield return random.Next(minValue, maxValue);
}

… and let’s say a developer is using the above to satisfy the following requirements.

  1. Give me an array of 10 random numbers between 1 and 100
  2. The 10 numbers should be unique
  3. The 10 numbers should be appear in order from lowest value to highest value

What’s wrong with the following code?

var values =
    new Random().Values(1, 100)
                .Distinct()
                .OrderBy(value => value)
                .Take(10)
                .ToArray();

Do you think it’s a subtle problem?

What’s an easy fix?

 
0

jTimepicker: jQuery Time Picker Plugin

Posted by W3Avenue Team on Oct 18, 2009 in Javascript  | View Original Article
 

jTimepicker is a jQuery plugin that allows users to set hours, minutes and seconds individually with jQuery UI Slider. You can easily implement it in your own forms using very simple markup. The plugin will automatically generates the required code for time picker control.

jTimepicker can be easily customized using CSS and several configuration options. It is cross browser plugin and has been tested to successfully work on the following browsers: Internet Explorer 6+, FireFox 3.5, Google Chrome 3.0 and Safari 4.0.

Developed by Radoslav Dimov; jTimepicker Plugin is available for download under MIT and GPL Licenses.  You can find further information, demo & download on jTimepicker Websiter.

Similar Posts:

You can also stay updated by following us on Twitter, becoming a fan on Facebook or by subscribing to our FriendFeed.

Tags: , , , ,

 
0

WCF extensibility guide

Posted by cibrax on Oct 18, 2009 in Dotnet  | View Original Article
 

The first chapter of the WCF extensibility guide that Jesus and I have been working on during the last few months went live in MSDN this weekend. You can find it here, http://msdn.microsoft.com/en-us/library/ee672186.aspx 

The first chapter gives an overview of the channel layer, and some of the extensibility points you can find there to implement custom channels.

Enjoy!!

Tags: ,

Copyright © 2010 Answer My Query All rights reserved. Maintained by Orange Brains .