Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. New Snippets Site

New Snippets Site

Scheduled Pinned Locked Moved The Lounge
visual-studiocom
22 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tonster101
    wrote on last edited by
    #1

    I just came across a site that has huge potential for sharing VS 2005 code snippets, check it out at: http://www.gotcodesnippets.com [^] ~Tony Y.

    M M R 3 Replies Last reply
    0
    • T Tonster101

      I just came across a site that has huge potential for sharing VS 2005 code snippets, check it out at: http://www.gotcodesnippets.com [^] ~Tony Y.

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      Tonster101 wrote:

      that has huge potential for sharing VS 2005 code snippets

      If it uses a single line format that cuts off the full description and requires clicking to see what the snippet looks like, then no, I can't imagine, even with search features, that this will be usable. With code snippets, Microsoft has unleashed a monster. Several, in fact. The first monster is, useful as they are, how do you organize your own snippets, as, over the years, you probably accumulate hundreds. Second, how do easily search other people's snippets, which will be in the tens of thousands. Third, snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices, here's a snippet to solve our immediate problem! Granted, some of the snippets make sense. Others, however, well, don't. Take, for example, this one.[^] Why is an improved property? Because of prefix support? We can only guess, because the author doesn't actually explain what's improved, and why he/she feels it's an improvement. Nor does everyone buy into the m_ (or whatever prefix you might want) concept. What I love about all these property code snippets, btw, is that not one of them, that I've seen, supports creating an event delegate and calling the event when the value changes, which is required for data binding. Note that typing in "property event" resulted in a list that was no different than the unfiltered list. That search engine is mighty broken. So. Organization. Searching. Quality. Engineering. I see a new industry segment in the making! Marc VS2005 Tips & Tricks -- contributions welcome!

      P C T F 4 Replies Last reply
      0
      • M Marc Clifton

        Tonster101 wrote:

        that has huge potential for sharing VS 2005 code snippets

        If it uses a single line format that cuts off the full description and requires clicking to see what the snippet looks like, then no, I can't imagine, even with search features, that this will be usable. With code snippets, Microsoft has unleashed a monster. Several, in fact. The first monster is, useful as they are, how do you organize your own snippets, as, over the years, you probably accumulate hundreds. Second, how do easily search other people's snippets, which will be in the tens of thousands. Third, snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices, here's a snippet to solve our immediate problem! Granted, some of the snippets make sense. Others, however, well, don't. Take, for example, this one.[^] Why is an improved property? Because of prefix support? We can only guess, because the author doesn't actually explain what's improved, and why he/she feels it's an improvement. Nor does everyone buy into the m_ (or whatever prefix you might want) concept. What I love about all these property code snippets, btw, is that not one of them, that I've seen, supports creating an event delegate and calling the event when the value changes, which is required for data binding. Note that typing in "property event" resulted in a list that was no different than the unfiltered list. That search engine is mighty broken. So. Organization. Searching. Quality. Engineering. I see a new industry segment in the making! Marc VS2005 Tips & Tricks -- contributions welcome!

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Marc Clifton wrote:

        snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices

        Good point, it is a scary thought that good design practices are at risk. Paul

        1 Reply Last reply
        0
        • M Marc Clifton

          Tonster101 wrote:

          that has huge potential for sharing VS 2005 code snippets

          If it uses a single line format that cuts off the full description and requires clicking to see what the snippet looks like, then no, I can't imagine, even with search features, that this will be usable. With code snippets, Microsoft has unleashed a monster. Several, in fact. The first monster is, useful as they are, how do you organize your own snippets, as, over the years, you probably accumulate hundreds. Second, how do easily search other people's snippets, which will be in the tens of thousands. Third, snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices, here's a snippet to solve our immediate problem! Granted, some of the snippets make sense. Others, however, well, don't. Take, for example, this one.[^] Why is an improved property? Because of prefix support? We can only guess, because the author doesn't actually explain what's improved, and why he/she feels it's an improvement. Nor does everyone buy into the m_ (or whatever prefix you might want) concept. What I love about all these property code snippets, btw, is that not one of them, that I've seen, supports creating an event delegate and calling the event when the value changes, which is required for data binding. Note that typing in "property event" resulted in a list that was no different than the unfiltered list. That search engine is mighty broken. So. Organization. Searching. Quality. Engineering. I see a new industry segment in the making! Marc VS2005 Tips & Tricks -- contributions welcome!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          C'mon, lets face the truth here. How many people are going to go in search of snippets, and what is the demographic going to be ? I could care less about snippets. I don't even use the built in ones, I plain don't see the point. I'm sure as hell not going to be bothered downloading any. I see snippets as a great tool for the hobbyist, because they help them to write code when they're not sure how to. Here's the other thing - by and large, good design is lost to most people writing code today. At least, it seems lost to a lot of the people who go looking for help online, who seem to me to be the people most likely to go nuts downloading snippets. Christian Graus - Microsoft MVP - C++

          M P 2 Replies Last reply
          0
          • C Christian Graus

            C'mon, lets face the truth here. How many people are going to go in search of snippets, and what is the demographic going to be ? I could care less about snippets. I don't even use the built in ones, I plain don't see the point. I'm sure as hell not going to be bothered downloading any. I see snippets as a great tool for the hobbyist, because they help them to write code when they're not sure how to. Here's the other thing - by and large, good design is lost to most people writing code today. At least, it seems lost to a lot of the people who go looking for help online, who seem to me to be the people most likely to go nuts downloading snippets. Christian Graus - Microsoft MVP - C++

            M Offline
            M Offline
            Marc Clifton
            wrote on last edited by
            #5

            Christian Graus wrote:

            How many people are going to go in search of snippets, and what is the demographic going to be ?

            Lots of VB'ers. :)

            Christian Graus wrote:

            I plain don't see the point.

            Actually, I do. There's a lot of code that I write that could be automated with a good automation tool. I'm not sure snippets are it, seeing as they seem to be more like a glorified macro expansion. For example, I'd like like to be able to say "here's the event, here's the properties the event arg's class should handle, now make the delegate, the event, the class derived from EventArgs, the constructor, the fields, and the property getters." Not all the snippets are general purpose either. For example, I have an application which serializes command packets. The serialization/deserialization code is similar enough that some parts are handled in a base class, but other parts need to be handled by a custom derived class. However, even that fits a template that could be generated by a snippet.

            Christian Graus wrote:

            good design is lost to most people writing code today

            Quite true. Snippets will just make it worse, IMO.

            Christian Graus wrote:

            it seems lost to a lot of the people who go looking for help online

            Heck, I go online looking for help all the time! But I'm not looking for design help, just "how do I do this" help, then I fold the answer into my architecture. Marc VS2005 Tips & Tricks -- contributions welcome!

            C L 2 Replies Last reply
            0
            • M Marc Clifton

              Christian Graus wrote:

              How many people are going to go in search of snippets, and what is the demographic going to be ?

              Lots of VB'ers. :)

              Christian Graus wrote:

              I plain don't see the point.

              Actually, I do. There's a lot of code that I write that could be automated with a good automation tool. I'm not sure snippets are it, seeing as they seem to be more like a glorified macro expansion. For example, I'd like like to be able to say "here's the event, here's the properties the event arg's class should handle, now make the delegate, the event, the class derived from EventArgs, the constructor, the fields, and the property getters." Not all the snippets are general purpose either. For example, I have an application which serializes command packets. The serialization/deserialization code is similar enough that some parts are handled in a base class, but other parts need to be handled by a custom derived class. However, even that fits a template that could be generated by a snippet.

              Christian Graus wrote:

              good design is lost to most people writing code today

              Quite true. Snippets will just make it worse, IMO.

              Christian Graus wrote:

              it seems lost to a lot of the people who go looking for help online

              Heck, I go online looking for help all the time! But I'm not looking for design help, just "how do I do this" help, then I fold the answer into my architecture. Marc VS2005 Tips & Tricks -- contributions welcome!

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Marc Clifton wrote:

              There's a lot of code that I write that could be automated with a good automation tool.

              Yes, I'd love what you go on to describe as well. There is some cross class monkey work that I'd love to automate.

              Marc Clifton wrote:

              However, even that fits a template that could be generated by a snippet.

              I guess the question is, do you use it often enough to create a snippet ? I need to create a snippet for the core image processing work that I do over and over, that will be the one snippet I ever use, because it's a lot of code that I type often.

              Marc Clifton wrote:

              Heck, I go online looking for help all the time!

              Sure - me too.

              Marc Clifton wrote:

              But I'm not looking for design help

              Not many people ask for design help, but often, I come to the conclusion that they should :-) Christian Graus - Microsoft MVP - C++

              C S 2 Replies Last reply
              0
              • C Christian Graus

                Marc Clifton wrote:

                There's a lot of code that I write that could be automated with a good automation tool.

                Yes, I'd love what you go on to describe as well. There is some cross class monkey work that I'd love to automate.

                Marc Clifton wrote:

                However, even that fits a template that could be generated by a snippet.

                I guess the question is, do you use it often enough to create a snippet ? I need to create a snippet for the core image processing work that I do over and over, that will be the one snippet I ever use, because it's a lot of code that I type often.

                Marc Clifton wrote:

                Heck, I go online looking for help all the time!

                Sure - me too.

                Marc Clifton wrote:

                But I'm not looking for design help

                Not many people ask for design help, but often, I come to the conclusion that they should :-) Christian Graus - Microsoft MVP - C++

                C Offline
                C Offline
                code frog 0
                wrote on last edited by
                #7

                Christian Graus wrote:

                Not many people ask for design help, but often, I come to the conclusion that they should

                People who ask for design help realize the need for good design. But honestly when you are contemplating design. It's most likely a large scale system. You are not going to get much help other than links to books on design. I think the net has good essays on design but you're not going to get a "quick-fix-hit" for design anywhere. It's complex in most cases. I think that's why we don't see it when we think we should. When I have a design question I usually pull open one of only 2 books I keep on hand a Grady & Booch and a Design Patterns and then I sit down with a potent caffeinated drink and plan on parking some hours into a think-session almost always with a yellow pad and a mechanical #2 pencil and a huge white eraser. To me design is a brain-bender when you first start out. Lot's of erasing. But then things start to connect and that's where it gets fun. I remember when I first got exposure to RUP. I never wanted to think about design again... Yellow pad and pencil kicks butt on RUP. {my humble opinion only of course} :-D

                Some assembly required. Code-frog System Architects, Inc.

                1 Reply Last reply
                0
                • C Christian Graus

                  C'mon, lets face the truth here. How many people are going to go in search of snippets, and what is the demographic going to be ? I could care less about snippets. I don't even use the built in ones, I plain don't see the point. I'm sure as hell not going to be bothered downloading any. I see snippets as a great tool for the hobbyist, because they help them to write code when they're not sure how to. Here's the other thing - by and large, good design is lost to most people writing code today. At least, it seems lost to a lot of the people who go looking for help online, who seem to me to be the people most likely to go nuts downloading snippets. Christian Graus - Microsoft MVP - C++

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #8

                  Christian Graus wrote:

                  I could care less about snippets. I don't even use the built in ones, I plain don't see the point.

                  I agree with you. Paul

                  1 Reply Last reply
                  0
                  • T Tonster101

                    I just came across a site that has huge potential for sharing VS 2005 code snippets, check it out at: http://www.gotcodesnippets.com [^] ~Tony Y.

                    M Offline
                    M Offline
                    Michael P Butler
                    wrote on last edited by
                    #9

                    Maybe CP will see less crappy articles now. Those who just want to get their name out-there have a new place to dump their useless code :-D Michael CP Blog [^] Development Blog [^]

                    S 1 Reply Last reply
                    0
                    • C Christian Graus

                      Marc Clifton wrote:

                      There's a lot of code that I write that could be automated with a good automation tool.

                      Yes, I'd love what you go on to describe as well. There is some cross class monkey work that I'd love to automate.

                      Marc Clifton wrote:

                      However, even that fits a template that could be generated by a snippet.

                      I guess the question is, do you use it often enough to create a snippet ? I need to create a snippet for the core image processing work that I do over and over, that will be the one snippet I ever use, because it's a lot of code that I type often.

                      Marc Clifton wrote:

                      Heck, I go online looking for help all the time!

                      Sure - me too.

                      Marc Clifton wrote:

                      But I'm not looking for design help

                      Not many people ask for design help, but often, I come to the conclusion that they should :-) Christian Graus - Microsoft MVP - C++

                      S Offline
                      S Offline
                      S Douglas
                      wrote on last edited by
                      #10

                      Christian Graus wrote:

                      Not many people ask for design help, but often, I come to the conclusion that they should

                      The problem with asking design questions on the forums the is the inherit complexity, not to mention what would probably be a five, ten minute conversation turns into a mess when trying to hammer it all out so others can understand the dilemma and help. The one issue that I have the most trouble with is good flexible design. Finding information on solving the specific problems I need to is hard to come by (not that anything I'm creating is complex but more repetitive, it’s all db stuff).


                      ZeePain! wrote:

                      This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                      thedailywtf.com[^]

                      1 Reply Last reply
                      0
                      • M Michael P Butler

                        Maybe CP will see less crappy articles now. Those who just want to get their name out-there have a new place to dump their useless code :-D Michael CP Blog [^] Development Blog [^]

                        S Offline
                        S Offline
                        S Douglas
                        wrote on last edited by
                        #11

                        Michael P Butler wrote:

                        Maybe CP will see less crappy articles now. Those who just want to get their name out-there have a new place to dump their useless code

                        Would you consider fairly simple classes that address one issue amongst that “Crappy Code” selection? Not everyone has the time to write the next killer app like .dan.g’s to do list[^].


                        ZeePain! wrote:

                        This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                        thedailywtf.com[^]

                        M 1 Reply Last reply
                        0
                        • M Marc Clifton

                          Tonster101 wrote:

                          that has huge potential for sharing VS 2005 code snippets

                          If it uses a single line format that cuts off the full description and requires clicking to see what the snippet looks like, then no, I can't imagine, even with search features, that this will be usable. With code snippets, Microsoft has unleashed a monster. Several, in fact. The first monster is, useful as they are, how do you organize your own snippets, as, over the years, you probably accumulate hundreds. Second, how do easily search other people's snippets, which will be in the tens of thousands. Third, snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices, here's a snippet to solve our immediate problem! Granted, some of the snippets make sense. Others, however, well, don't. Take, for example, this one.[^] Why is an improved property? Because of prefix support? We can only guess, because the author doesn't actually explain what's improved, and why he/she feels it's an improvement. Nor does everyone buy into the m_ (or whatever prefix you might want) concept. What I love about all these property code snippets, btw, is that not one of them, that I've seen, supports creating an event delegate and calling the event when the value changes, which is required for data binding. Note that typing in "property event" resulted in a list that was no different than the unfiltered list. That search engine is mighty broken. So. Organization. Searching. Quality. Engineering. I see a new industry segment in the making! Marc VS2005 Tips & Tricks -- contributions welcome!

                          T Offline
                          T Offline
                          Tonster101
                          wrote on last edited by
                          #12

                          Very true, through and through... First and foremost the gotsnippets site needs a lot of work, buy hey, it looks like those folks are just getting it off the ground... Like CP hasn't had it's share of growing pains? Please. I get busy errors one in eight clicks on CP and it's generally slow, but I don't 'complain', because it is a great concept and useful collaboration tool. 'Granted, some of the snippets make sense. Others, however, well, don't.' Your right about that, and we are certainly are not being forced to use the ones we don't like, just like we're not forced to use all the bad article and tips found here on CP, but it's great to share and give & get feedback. And if you don't like them, create you own! If you think they are using bad patterns and practices, write a good one and share it. ~Tony Y.

                          1 Reply Last reply
                          0
                          • M Marc Clifton

                            Christian Graus wrote:

                            How many people are going to go in search of snippets, and what is the demographic going to be ?

                            Lots of VB'ers. :)

                            Christian Graus wrote:

                            I plain don't see the point.

                            Actually, I do. There's a lot of code that I write that could be automated with a good automation tool. I'm not sure snippets are it, seeing as they seem to be more like a glorified macro expansion. For example, I'd like like to be able to say "here's the event, here's the properties the event arg's class should handle, now make the delegate, the event, the class derived from EventArgs, the constructor, the fields, and the property getters." Not all the snippets are general purpose either. For example, I have an application which serializes command packets. The serialization/deserialization code is similar enough that some parts are handled in a base class, but other parts need to be handled by a custom derived class. However, even that fits a template that could be generated by a snippet.

                            Christian Graus wrote:

                            good design is lost to most people writing code today

                            Quite true. Snippets will just make it worse, IMO.

                            Christian Graus wrote:

                            it seems lost to a lot of the people who go looking for help online

                            Heck, I go online looking for help all the time! But I'm not looking for design help, just "how do I do this" help, then I fold the answer into my architecture. Marc VS2005 Tips & Tricks -- contributions welcome!

                            L Offline
                            L Offline
                            Leslie Sanford
                            wrote on last edited by
                            #13

                            Marc Clifton wrote:

                            Christian Graus wrote: good design is lost to most people writing code today Quite true. Snippets will just make it worse, IMO.

                            Hmm, maybe snippets could be used to enforce, or at least guide, one to use good coding practises? I was playing around with creating my own snippets the other day, and one of the first ones I created was a "DesignByContract" snippet that automates placing Require, Ensure, and Invariant regions within a method. You then fill in the preconditions requirements in the Require region, check the postconditions in the Ensure region, and finally check the class invariants in the Invariant region. Granted, this example doesn't buy you a lot that you couldn't write by hand very quickly, but just having the snippet there makes me think about the method I'm writing. Do I need to enforce any preconditions? What are the post conditions? And how about the class invariants? Another example is that I get really tired of writing the same event raising code. Something like this:

                            EventHandler handler = MyEvent;

                            if(handler != null)
                            {
                            handler(this, EventArgs.Empty);
                            }

                            (there's a subtle multithreading issue here that makes it safer to create the handler variable and check it against null rather than using the event directly). This can easily be automated with a snippit with delimiters place here and there for you to fill in your own event type/names, etc. Perhaps over time patterns of good coding/design snippets will evolve and gain dominance.

                            M 1 Reply Last reply
                            0
                            • S S Douglas

                              Michael P Butler wrote:

                              Maybe CP will see less crappy articles now. Those who just want to get their name out-there have a new place to dump their useless code

                              Would you consider fairly simple classes that address one issue amongst that “Crappy Code” selection? Not everyone has the time to write the next killer app like .dan.g’s to do list[^].


                              ZeePain! wrote:

                              This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                              thedailywtf.com[^]

                              M Offline
                              M Offline
                              Michael P Butler
                              wrote on last edited by
                              #14

                              sfdougl wrote:

                              Would you consider fairly simple classes that address one issue amongst that “Crappy Code” selection? Not everyone has the time to write the next killer app like .dan.g’s to do list[^].

                              As long as their is some article content and not just a few lines with a link to down the source-code then I'm happy. I don't expect full blown apps, but I do expect an article to have some meat to it. Michael CP Blog [^] Development Blog [^]

                              S 1 Reply Last reply
                              0
                              • L Leslie Sanford

                                Marc Clifton wrote:

                                Christian Graus wrote: good design is lost to most people writing code today Quite true. Snippets will just make it worse, IMO.

                                Hmm, maybe snippets could be used to enforce, or at least guide, one to use good coding practises? I was playing around with creating my own snippets the other day, and one of the first ones I created was a "DesignByContract" snippet that automates placing Require, Ensure, and Invariant regions within a method. You then fill in the preconditions requirements in the Require region, check the postconditions in the Ensure region, and finally check the class invariants in the Invariant region. Granted, this example doesn't buy you a lot that you couldn't write by hand very quickly, but just having the snippet there makes me think about the method I'm writing. Do I need to enforce any preconditions? What are the post conditions? And how about the class invariants? Another example is that I get really tired of writing the same event raising code. Something like this:

                                EventHandler handler = MyEvent;

                                if(handler != null)
                                {
                                handler(this, EventArgs.Empty);
                                }

                                (there's a subtle multithreading issue here that makes it safer to create the handler variable and check it against null rather than using the event directly). This can easily be automated with a snippit with delimiters place here and there for you to fill in your own event type/names, etc. Perhaps over time patterns of good coding/design snippets will evolve and gain dominance.

                                M Offline
                                M Offline
                                Marc Clifton
                                wrote on last edited by
                                #15

                                Leslie Sanford wrote:

                                one to use good coding practises?

                                That's an excellent point! I like your design by contract example, BTW.

                                Leslie Sanford wrote:

                                (there's a subtle multithreading issue here that makes it safer to create the handler variable and check it against null rather than using the event directly).

                                Interesting. Can you explain that some more? Marc VS2005 Tips & Tricks -- contributions welcome!

                                L 1 Reply Last reply
                                0
                                • M Michael P Butler

                                  sfdougl wrote:

                                  Would you consider fairly simple classes that address one issue amongst that “Crappy Code” selection? Not everyone has the time to write the next killer app like .dan.g’s to do list[^].

                                  As long as their is some article content and not just a few lines with a link to down the source-code then I'm happy. I don't expect full blown apps, but I do expect an article to have some meat to it. Michael CP Blog [^] Development Blog [^]

                                  S Offline
                                  S Offline
                                  S Douglas
                                  wrote on last edited by
                                  #16

                                  Michael P Butler wrote:

                                  As long as their is some article content and not just a few lines with a link to down the source-code then I'm happy.

                                  Okay, fair enough, pretty much what I had thought. Like everyone I’m sure, I have a few classes floating around that have served a purpose or two and lately I have been thinking about gathering some thoughts about their intent and usage for posting here. I would like to give something back to the community which has severed me well. While I don’t often ask for help, (don’t really need to as most of my questions can be answered with a quick search of the forums or studying others code) the layout and plethora of information at CP has helped immensely. One question what about say some scripts for backing up a Subversion server? I have a little VB Script to take care of this for me, or is something like that better served in my blog area? Thing is there really isn’t much to write about other than its usage, which is really “here fill in the location of the directors and how many days you would like to keep” and this is how to make set it up to run every night with the AT command, done. Yea know, are there any members of CP that offer editorial services? My writing skills are terrible; perhaps a little pre-post editorial could cut down on the “Crappy Code”. Or at least someone to say yea this code will fit in well with the site or take it back to the drawing board.


                                  ZeePain! wrote:

                                  This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                                  thedailywtf.com[^]

                                  1 Reply Last reply
                                  0
                                  • M Marc Clifton

                                    Tonster101 wrote:

                                    that has huge potential for sharing VS 2005 code snippets

                                    If it uses a single line format that cuts off the full description and requires clicking to see what the snippet looks like, then no, I can't imagine, even with search features, that this will be usable. With code snippets, Microsoft has unleashed a monster. Several, in fact. The first monster is, useful as they are, how do you organize your own snippets, as, over the years, you probably accumulate hundreds. Second, how do easily search other people's snippets, which will be in the tens of thousands. Third, snippets are great, but it worries me that the VB cut&paste mentality is going to become even more dumbed down--no longer do we need to think about good design practices, here's a snippet to solve our immediate problem! Granted, some of the snippets make sense. Others, however, well, don't. Take, for example, this one.[^] Why is an improved property? Because of prefix support? We can only guess, because the author doesn't actually explain what's improved, and why he/she feels it's an improvement. Nor does everyone buy into the m_ (or whatever prefix you might want) concept. What I love about all these property code snippets, btw, is that not one of them, that I've seen, supports creating an event delegate and calling the event when the value changes, which is required for data binding. Note that typing in "property event" resulted in a list that was no different than the unfiltered list. That search engine is mighty broken. So. Organization. Searching. Quality. Engineering. I see a new industry segment in the making! Marc VS2005 Tips & Tricks -- contributions welcome!

                                    F Offline
                                    F Offline
                                    feline_dracoform
                                    wrote on last edited by
                                    #17

                                    work are threatening to move us across to VS2005 "soon", but until that happens we are still with VS2003, so if i am about to show off my ignorance of VS2005 snippets then so be it :-O in Visual Assist there is a feature that sounds quite a lot like snippets to me, Autotext. type in a trigger and it will suggest the piece of code for you. it is tempting to think about grand code blocks, 10's or lines longer, or bigger. having used Autotext for a couple of years i find that it is most useful for short pieces of code that make my life easier, not big pieces that i should be thinking about. a good example is: #if 0 //{{AFX_COMMENTED_OUT #endif //}}AFX_COMMENTED_OUT the number of times i want to wrap some code in #if 0, #endif and have it coloured as a comment... using this you can ask the IDE to colour the block in its own distinct colour, which is ideal for my needs :-D so i made myself an Autotext where "#if" and "#en" are the triggers for these two lines. there is no clever code here, instead it saves me typing, effort, and having to commit the exact syntax to memory. so i can see a lot of use for code snippets with such "simple" things, but it does require that code snippets are well intigrated into the IDE, fast and easy to use, and you still need to think of simple and useful bits of code to use. of course the flip side is that my must frequently used "code snippets" are not worth uploading to a site, since they look pointlessly simple and basic, until you stop and think just how many times a day you want to type these... :) zen is the art of being at one with the two'ness

                                    1 Reply Last reply
                                    0
                                    • T Tonster101

                                      I just came across a site that has huge potential for sharing VS 2005 code snippets, check it out at: http://www.gotcodesnippets.com [^] ~Tony Y.

                                      R Offline
                                      R Offline
                                      Rocky Moore
                                      wrote on last edited by
                                      #18

                                      Thanks for the link.. I currenty only use a handful (and use them often), but you never know what handy snippet you will run across :) Rocky <>< Latest Post: SQL2005 Server Managemnet Studio timeouts! Blog: www.RockyMoore.com/TheCoder/[^]

                                      1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        Leslie Sanford wrote:

                                        one to use good coding practises?

                                        That's an excellent point! I like your design by contract example, BTW.

                                        Leslie Sanford wrote:

                                        (there's a subtle multithreading issue here that makes it safer to create the handler variable and check it against null rather than using the event directly).

                                        Interesting. Can you explain that some more? Marc VS2005 Tips & Tricks -- contributions welcome!

                                        L Offline
                                        L Offline
                                        Leslie Sanford
                                        wrote on last edited by
                                        #19

                                        Marc Clifton wrote:

                                        Interesting. Can you explain that some more?

                                        Say you did this:

                                        if(MyEvent != null)
                                        {
                                        // There's a chance here that another thread has
                                        // removed the last event handler from MyEvent.

                                        // Could be null at this point.
                                        MyEvent(this, EventArgs.Empty);
                                        

                                        }

                                        On the other hand:

                                        // Basically, we're taking a snapshot of the invocation
                                        // list at this time.
                                        EventHandler handler = MyEvent;

                                        if(handler != null)
                                        {
                                        // Even if the last event handler is removed from MyEvent
                                        // at this point, the handler delegate is not
                                        // affected.
                                        handler(this, EventArgs.Empty);
                                        }

                                        Here's a webpage[^] that goes into a little detail. Actually, Jon goes a bit further than my example to ensure thread safety. This gets mentioned from time to time on microsoft.public.dotnet.languages.csharp, but I'm not sure if it's documented any where on MSDN. Probably is; I just haven't run across it.

                                        M 1 Reply Last reply
                                        0
                                        • L Leslie Sanford

                                          Marc Clifton wrote:

                                          Interesting. Can you explain that some more?

                                          Say you did this:

                                          if(MyEvent != null)
                                          {
                                          // There's a chance here that another thread has
                                          // removed the last event handler from MyEvent.

                                          // Could be null at this point.
                                          MyEvent(this, EventArgs.Empty);
                                          

                                          }

                                          On the other hand:

                                          // Basically, we're taking a snapshot of the invocation
                                          // list at this time.
                                          EventHandler handler = MyEvent;

                                          if(handler != null)
                                          {
                                          // Even if the last event handler is removed from MyEvent
                                          // at this point, the handler delegate is not
                                          // affected.
                                          handler(this, EventArgs.Empty);
                                          }

                                          Here's a webpage[^] that goes into a little detail. Actually, Jon goes a bit further than my example to ensure thread safety. This gets mentioned from time to time on microsoft.public.dotnet.languages.csharp, but I'm not sure if it's documented any where on MSDN. Probably is; I just haven't run across it.

                                          M Offline
                                          M Offline
                                          Marc Clifton
                                          wrote on last edited by
                                          #20

                                          Leslie Sanford wrote:

                                          Here's a webpage[^] that goes into a little detail.

                                          That's quite interesting! Thanks for the link. But what I don't understand is, why isn't:

                                          EventHandler handler = MyEvent;

                                          just a reference copy of the invocation list? Marc VS2005 Tips & Tricks -- contributions welcome!

                                          L 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups