May 23, 2004Are code snippets evil?Posted 2293 days ago on May 23, 2004One of the new productivity features in Visual Studio .NET 2005 is code snippets. This is a library of reusable code that you can quickly insert into your VB project. Sounds good, but the danger is that it is used as a kind of persistent clipboard, encouraging developers to copy and paste blocks of code instead of creating their own class libraries. Copy and paste is at the root of many classic development problems, such as code bloat and bugs that need to be fixed in more than one place. I've noticed here at Tech Ed (in the press pre-briefing) that presenters are using code snippets as a handy way to paste their demo code. Fair enough, but will this be another case of the IDE actually encouraging poor practice? Are code snippets evil?Trackback from Lazycoder weblog Posted 2293 days ago • Reply
Scobleizer: Microsoft Geek Blogger Re: Are code snippets evil?Posted 2293 days ago by Addy Santo • • www • Reply
Code snippets are the root of all evil. In other related news, people don't kill - bullets do. Re: Are code snippets evil?Posted 2292 days ago by Christopher (Chris) Galas • • • Reply
Code snippets are essential to learning and getting use to the new paradyme. For each new version of the Visual Studio, a shift in the paradyme occurs. New features, new ways of debugging and new languages to learn are introduced in each new version of the developers tools. I'm not sure if anyone remembers the old IDE for v5.1 (which was the first one), but it was similar to the editor in DOS. Look how far that has progressed in 10 years? Are code snippets evil?Trackback from Reflective Surface Posted 2292 days ago • ReplyAre code snippets evil? Re: Are code snippets evil?Posted 2292 days ago by Sam Spencer • • • Reply
Like any feature, code snippets can be abused. |
Recent postsUsers plead with Borland to give up .NETIE7 to be released 18th October,... If Microsoft doesn't use UAC, why... Google's unsettling lack of direction Vista security: now prove it |
Re: Are code snippets evil?
Posted 2293 days ago by Tim Sneath • • www • ReplyI don't think they're inherently evil, but like almost any technology they have the potential to be abused. One of the challenges with the Base Class Libraries of the .NET Framework is the sheer scale of them - it's sometimes hard to find the method or function that you're after. Code snippets provide an alternative taxonomy to the namespace model that can make it easier to surface commonly-accessed tasks without distorting the overall structure.
Another usage for code snippets is to facilitate the wiring up of different components. For example, to send a mail using System.Web.Mail you need to set the SMTP server, create a message object and send it. This isn't necessarily the kind of thing you'd refactor into a separate method, but code snippets make the various required steps transparent.
But you're quite right that an abuse of code snippets would be to create a toolbox or function library - far better for maintenance to build a reusable object rather than repeatedly copy and paste code across multiple projects.