Lazycoder

24May/040

Are code snippets evil?

Scobleizer: Microsoft Geek Blogger

Are code snippets evil?

Regarding snippets: Are you going to study them or are you going to just use them and use the over and over again?

What happens if you discover a bug in the snippet and you’ve copy-pasted it in several different applications?

Instead of snippets, they should have created “mini-assemblies” that could be truly re-used and extended. Being able to compile code-fragments, even just a single method, could be useful. It could be a nightmare too. Imagine a program made up of several hundred mini-assemblies? Ick, what a nightmare to debug.

The kind of code that would get encapsulated in code snippets are what I call mini-design-patterns. They are ways of doing certain tasks, e.g. creating a WebMail object, setting the server, creating the message and sending it or iterating over a collection and storing the index of an object you are interested in retrieving, that don’t really fall into a full blown pattern but the steps are static enough that they fall into a pattern like format.

Share and Enjoy:
  • del.icio.us
  • DotNetKicks
  • DZone
  • Reddit
  • Digg
  • StumbleUpon
  • LinkedIn
  • Facebook
  • FriendFeed
  • HackerNews
  • Netvibes
  • Posterous
  • Tumblr
  • Twitter
Filed under: .NET Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.