Podcast #6 - Project Design & The Future of C#

by Matt 1. December 2009 14:38

In this episode Chris, Matt and Eric discuss project design, Visual Studio 2010 Beta 2, ASP.NET MVC, the future of C#... and much more!

  • The guys start out by discussing some of the best practices for initial project design.
  • Chris and Matt used a Microsoft product called Sketchflow that is part of the Expression Blend family of products.  Another popular screen layout program is Balsamiq Mockups.
  • Writing specs can be an important part of the design process, even though some developers dislike this part.
  • Now that Chris and Matt have more experience with ASP.NET MVC, they talk about what they like and dislike about it, as well as how the repository pattern has helped with their current process.
  • Visual Studio 2010 Beta 2 is out now, and is a huge improvement over Beta 1.
  • One of things we like about C# is how much it evolves as a language, which is also one of the things a lot of developers dislike.  One of the articles discussed is K. Scott Allen's article about where C# is in the development lifecycle.
  • To wrap up the podcast, the guys discuss DJ Hero and The Beatles Rock Band.

If you have a question for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question in text form, or record it and send us the audio file.

Download Podcast #6 MP3

Podcast #5 - Agile Development & The Duct Tape Programmer

by Matt 27. October 2009 11:22

In this episode Chris, Matt and Eric welcome this week's guest, Michael, to the podcast.  Discussed this week are the pros and cons of Agile Development (SCRUM in particular) and concept of the duct tape programmer.

  • Three of us have used the SCRUM process (or a modified SCRUM process), but what we've really used it more for time tracking than anything.
  • The guys discuss the pros and cons of a duct tape programmer.
  • We coin a new term - the Scotch Tape Programmer - that is the programmer who just writes bad code.
  • The guys discuss all of the pointless domains that we own that we never do anything with.
  • If you are a student, get Window 7 for $29.99!

If you have a question for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question in text form, or record it and send us the audio file.

Download Podcast #5 MP3

Podcast #4 - iPhone Development & Digital Music

by Matt 5. October 2009 15:27

In this episode Chris, Matt and Eric welcome this week's guest, Bradley, to the podcast.  This week the guys discuss iPhone development, the app approval process, and MonoTouch.

Note: We apologize for Bradley's microphone not working for the first few minutes.

  • The guys start out by discussing Objective-C, and the differences between it and other similar languages.
  • To deploy apps to the App store, you have to buy the $99 developer license from Apple.  You can download the SDK at not cost.
  • MonoTouch allows writing C# that compiles down to run on an iPhone or iPod Touch.
  • Writing iPhone applications requires running OSX, plus the developer license from Apple.
  • Marketing is an important part of an iPhone app.  If no one knows about your app, you won't make very much money.
  • Lastly the guys discuss the state of music in the digital age.  Are CD's still relevant?
  • If you still think CD's are viable, send us an e-mail to podcast@craftycoders.com why you think so!  We'd love to hear from you.

If you have a question for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question in text form, or record it and send us the audio file.

Download Podcast #4 MP3

Podcast #3 - Interviewing Programmers

by Matt 8. September 2009 23:16

In this episode Chris, Matt and Eric discuss the process of interviewing programmers and the hiring process, as well as the importance of degrees and certifications.  Also discussed are the different tech conferences out there for programmers.

  • Programmers should be involved in interviewing other programmers.  But what questions should be asked?  We think that trivia type questions are pointless, and don't tell you anything about the programming knowledge of the interviewee.
  • Chris talks about when he was a technical interviewer, and the learning process that goes along with that.
  • Should interviewee's have to write code?  In the days of intellisense though, psuedocode should be fine.  We just want to make sure they have the knowledge to put together logic.
  • Joel Spolsky says: If you are going to hire a magician, you want to see them do a magic trick... If you are going to hire a developer, you want to make sure they can write some code.
  • It's not all about code though, because you do have to spend all day with this person.
  • We do not think that college degrees are a prerequisite for being a programmer.  The best developers are the ones that do not stop at 5:00.
  • If you don't have a college degree, make sure you don't sell yourself short in an interview.
  • Tech conferences can be a great place to learn new technologies and tools.  Some good conferences are TechEd, PDC, StackOverflow DevDays, or even Tulsa TechFest if you're in Oklahoma.
  • Lastly, we discuss Microsoft’s latest gaming technology, Project Natal.  View the demo on Late Night with Jimmy Fallon here.

If you have a question for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question in text form, or record it and send us the audio file.  Please keep audio files under a minute, and give us your name.

Download Podcast #3 MP3

Note: The podcast is now available on iTunes!  Enjoy!

Podcast #2 - Entity Framework, LINQ to SQL & Visual Studio 2010

by Matt 17. August 2009 16:20

In this episode, Chris and Matt discuss Microsoft's Entity Framework and LINQ to SQL.  They also discuss Visual Studio 2010 and the .NET 4.0 Framework, and what is coming in these new versions.

  • Chris and Matt discuss the pros and cons of the Entity Framework and LINQ to SQL.  There are also alternatives like NHibernate.  How should you code to these ORM models using an n-tier approach?
  • Also discussed is the differences between Entity Framework and LINQ to SQL.  We don't cover a lot of them in detail in the podcast, but you can find a good list here.
  • The System.IO.File class has been updated to expose IEnumerable in some methods.  A Crafty Coders post will be coming soon on this subject.
  • What is the new "dynamic" keyword, and what does it affect.  We're not quite sure what we would use it for right away.  It could definitely be overused for evil though.
  • More new stuff coming is: F# bundled in with Visual Studio, parallel processing updates, optional parameters and more.
  • Lastly, the guys discuss Swoopo.com... including what the site is, and who are the people that actually bid on the products!

If you have a question or comment for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question in text form, or record it and send us the audio file.

Download Podcast #2 MP3

"Using" Extension Methods in C#

by Matt 12. August 2009 11:08

Extension methods have become one of my favorite parts of C# as of late.  They can be very powerful and save you from writing some redundant code.  A great extension method I discovered a couple weeks ago was wrapping up the "using" statement like so:

public static void Use<T>(this T item, Action<T> action) where T : IDisposable
{
    using (item)
    {
        action(item);
    }
}

This allows you to write using statements using a Lambda expression like this:

void UseStream()
{
    string contents;

    new StreamReader(@"c:\file.txt").Use(s =>
        {
            contents = s.ReadToEnd();
        });

    // Do something with the contents
}

Instead of this:

void UseStream()
{
    string contents;

    using (StreamReader s = new StreamReader(@"c:\file.txt"))
    {
        contents = s.ReadToEnd();
    }

    // Do something with the contents
}

OK, so this really doesn't save you a lot of code, but it keeps you from writing a small amount of redundant code when instantiating what you are "using".  After about a week of using it, I modified it it to make it a little more powerful.  I created an additional extension method that looks like this:

public static TResult Use<T, TResult>(this T item, Func<T, TResult> action) where T : IDisposable
{
    using (item)
    {
        return action(item);
    }
}

This allows you to return a type from within your using statement very easily:

string ReturnStreamContents()
{
    return new StreamReader(@"c:\file.txt").Use(s =>
        {
            return s.ReadToEnd();
        });
}

Wrapping up a using statement this way could also allow you to perform any custom logic inside the extension method that you need to.

Podcast #1 - ASP.NET MVC & Windows 7

by Matt 6. August 2009 22:28

In the inaugural episode of the Crafty Coders podcast, Matt, Chris and Eric discuss ASP.NET MVC vs Web Forms, Windows 7, Chrome OS and Bing.

  • Chris and Matt discuss what the ASP.NET MVC framework is, and how it relates to Web Forms.  ASP.NET MVC is not a replacement for Web Forms.  A lot of people still think this.
  • Windows 7 is set for release in October.  Why do there have to be so many different versions?  In our opinion, Windows 7 is a great improvement over Microsoft's previous OS's.
  • Google recently announced ChromeOS, but have not set any type of release date.  What is ChromeOS, and will it affect the current market?
  • Microsoft recently rebranded Live search as Bing, and we assume they made changes to the searching algorithms.  While the Bing interface has some cool stuff, the results have not been near as good as Google.  You can search both side by side at http://www.bing-vs-google.com/.

If you have a question or comment for the podcast, please send an e-mail to podcast@craftycoders.com.  You can either send your question/comment in text form, or record it and send us the audio file.  If we do not have time to answer your question on the podcast, we will at least attempt to reply to you via e-mail.

Download Podcast #1 MP3

Note: The podcast is not yet available on iTunes, but will be soon!

Dictionary Key Case Sensitivity in C#

by Bradley 8. May 2009 16:26

By default you must make sure that a key used to look up a value in a dictionary matches the case of key used to store the value in a dictionary. Simply put, list["A"] would not return the same value as list["a"]. It would be safe to assume that the default behavior was selected for efficiency. After all would you want your code slowed down by doing list["a".ToUpper()], if you knew that the key used to look up a dictionary value would never have a different case than what was used to store it. With that in mind, if case were an issue, most of us would change our code to perform the ToUpper just described. Although this approach is functionally sound, your code could become unnecessarily cluttered. An equally functional approach that would keep your code uncluttered would be to use one of the alternate constructors for your dictionary, see example below.

using System.Collections.Generic;

Dictionary<string, string> list = 
    new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
list.Add("A", "Value");

if (list["A"] != null)
{
    Console.WriteLine("A can be A");
}

if (list["a"] != null)
{
    Console.WriteLine("a can also be A");
}

Tags: , ,

.NET | C#

jQuery Remote Validation with ASP.Net Webservices

by Chris 13. April 2009 08:57

Jörn Zaefferer has created a nice jQuery plugin for validating forms.  Along with the standard required and formatting validation, it also allows validation using remote calls.  Unfortunately for us .Net users, the plugin was not written to interface with ASP.Net webservices.  Below is an example how the plugin can be modified to retrieve results from an ASP.Net webservice.

Searching through the plugin source (example), you will find the below section of code that makes the remote call.  The validation extends the standard $.ajax call and checks whether the response is true or false. 

 // http://docs.jquery.com/Plugins/Validation/Methods/remote
 remote: function(value, element, param) 
{
   ...
   
   $.ajax($.extend(true,
   {
    url: param,
    mode: "abort",
    port: "validate" + element.name,
    dataType: "json",
    data: data,
    success: function(response)
    {
     if ( response )
     {
      var submitted = validator.formSubmitted;
      validator.prepareElement(element);
      validator.formSubmitted = submitted;
      validator.successList.push(element);
      validator.showErrors();
     } else
     {
      var errors = {};
      errors[element.name] =  response || validator.defaultMessage( element, "remote" );
      validator.showErrors(errors);
     }
     
     ... 

 

While this is valid for most languages, with ASP.Net 3.5 Microsoft modified the JSON response of webservices.  Webservices accessed under .Net 3.5 will have the JSON response within a .d attribute.  Because of this, any remote validation request against these types of webservices will generate a null exception.  To handle this new change, we need to extract the true JSON response from the response.  Adding the following line to the  $.ajax success function will now get the true response.

 

// http://docs.jquery.com/Plugins/Validation/Methods/remote
 remote: function(value, element, param) 
{
   ...
   
   $.ajax($.extend(true,
   {
    url: param,
    mode: "abort",
    port: "validate" + element.name,
    dataType: "json",
    data: data,
    success: function(response)
    {
      response = response.d
     
     if ( response )
     {
      var submitted = validator.formSubmitted;
      validator.prepareElement(element);
      validator.formSubmitted = submitted;
      validator.successList.push(element);
      validator.showErrors();
     } else
     {
      var errors = {};
      errors[element.name] =  response || validator.defaultMessage( element, "remote" );
      validator.showErrors(errors);
     }
     
     ... 
 

Sorting Files Using LINQ & Lambda Expressions

by Michael 30. December 2008 13:41


using System.Collections.Generic;
using System.IO;
using System.Linq;

class SortFiles
{
    public IEnumerable<FileInfo> Sort()
    {
        // Set the directory you want to search
        DirectoryInfo di = new DirectoryInfo(@"C:\"); 

        // Get all of the .jpg files from the directory and order
        // them by file name in descending order
        IEnumerable<FileInfo> files =
            di.GetFiles("*.jpg").OrderByDescending(e => e.Name); 

        return files;
    }
}

You can sort it by name, creation time, length, or any other FileInfo property.  You can find many other LINQ examples here:  http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

Tags: , ,

.NET | C# | LINQ

Powered by BlogEngine.NET 1.5.0.7
Original Theme by Mads Kristensen | Modified by Crafty Coders