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
  1. Home
  2. General Programming
  3. C#
  4. a little help on "most used" codes !

a little help on "most used" codes !

Scheduled Pinned Locked Moved C#
questionhtmlhelp
21 Posts 10 Posters 1 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.
  • _ Offline
    _ Offline
    _Q12_
    wrote on last edited by
    #1

    "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

    J P L D L 6 Replies Last reply
    0
    • _ _Q12_

      "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      I don't do what you are suggesting in any form. The vast amount of code is not generic. It has a specific purpose that has little if no meaning elsewhere. Code that actually usable, as is, in multiple places is managed as a library. Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it. And finally your suggestion of the internet is problematic from a moralistic and legal perspective. Most of my code is written for an employer. They own the code not me. I cannot use it for any purpose except to the owners betterment. So I can't use it on my personal projects nor for any other employer. So there would not be any point in having it accessible from the internet.

      _ 1 Reply Last reply
      0
      • _ _Q12_

        "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        You mean like an ASCII table? I usually refer to my VT101 user guide.

        L _ 2 Replies Last reply
        0
        • _ _Q12_

          "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          You have a strange view on the subject. Source code is kept in source files, not in docx or HTML documents. And reusable code should be built and its executable code should reside in DLL files. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          _ 1 Reply Last reply
          0
          • P PIEBALDconsult

            You mean like an ASCII table? I usually refer to my VT101 user guide.

            L Offline
            L Offline
            loyal ginger
            wrote on last edited by
            #5

            Very funny. BTW, putting pieces of code in a document file is really not a bad idea. The document can then be sent to a publisher to make a book titled something like: "A Cook Book for Every Programmer."

            1 Reply Last reply
            0
            • J jschell

              I don't do what you are suggesting in any form. The vast amount of code is not generic. It has a specific purpose that has little if no meaning elsewhere. Code that actually usable, as is, in multiple places is managed as a library. Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it. And finally your suggestion of the internet is problematic from a moralistic and legal perspective. Most of my code is written for an employer. They own the code not me. I cannot use it for any purpose except to the owners betterment. So I can't use it on my personal projects nor for any other employer. So there would not be any point in having it accessible from the internet.

              _ Offline
              _ Offline
              _Q12_
              wrote on last edited by
              #6

              //"The vast amount of code is not generic. It has a specific purpose that has little if no meaning elsewhere."

              Yes I know that, and I agree. In essence is as you say.

              //"Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it."

              Well, suppose you make 5 year ago a very good code (for yourself) and now you remember that you have that code, you have a similar application to make (some modification is required but at the base that code from 5 years ago remain the same at the core). You have the project from 5 years ago, saved into a 30G Hdd somewhere in your house? You make, back then for yourself, a library (as you suggested in your response)? 1-the simplest form of what is to store is like this: [this is a pure example -I don't want critics about this code here!] //IndexOf usage with string; Benchmark result String version: 1154 ms int i = s.IndexOf("a"); //Finds first "a" string in s. //IndexOf usage with char; Benchmark result Char version: 172 ms int i = s.IndexOf('a'); //Finds first 'a' char in s. 2-the complex form are entire programs, objects,methods, even controls. (You made them for your simplification in coding for later uses, as reminders or as core codes.) Thank you. Your response is the closest of what I intend to know. I hope that with your help I can decipher this mystery I am in to.

              J 1 Reply Last reply
              0
              • P PIEBALDconsult

                You mean like an ASCII table? I usually refer to my VT101 user guide.

                _ Offline
                _ Offline
                _Q12_
                wrote on last edited by
                #7

                Your response is a little cryptic but i will adapt it to my needs. The ASCII table(like this one: http://www.hobbyprojects.com/ascii-table/ascii-table.html[^]) is a very good way to look at simplest forms of code storage. And yes, is a very good way visually to remember tricks and hints, special code usage, or even the basic usage of methods and rules in general. Why I could not think of that? :) thanks man- you give me a nice idea about how to implement it. 1-the simplest form of what is to store is like this: [this is a pure example -I don't want critics about this code here!] //IndexOf usage with string; Benchmark result String version: 1154 ms int i = s.IndexOf("a"); //Finds first "a" string in s. //IndexOf usage with char; Benchmark result Char version: 172 ms int i = s.IndexOf('a'); //Finds first 'a' char in s. 2-the complex form are entire programs, objects,methods, even controls. (You made them for your simplification in coding for later uses, as reminders or as core codes.) The "VT101 user guide" is more complicated to achieve(programatically). It is a treeview at core, and the page you must edit(add new codes) is a bit complex and require a lot of attention and patience. I need something easy to edit and then something easy to view/search into. Both your suggestions are great. Thanks. But I didn't try your "like ASCII" model implementation. If you have an example of your "like ASCII" model to inspire from, it will be very nice. I need to see others how they did it. Maybe I can come with something useful to what I see. Thank you again.

                1 Reply Last reply
                0
                • L Luc Pattyn

                  You have a strange view on the subject. Source code is kept in source files, not in docx or HTML documents. And reusable code should be built and its executable code should reside in DLL files. :)

                  Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  _ Offline
                  _ Offline
                  _Q12_
                  wrote on last edited by
                  #8

                  //"Source code is kept in source files"

                  I have done that. Is the wright way, of course but it won't helped me. Ok, I will repeat from what I write in last responses. 1-the simplest form of what is to store is like this: [this is a pure example -I don't want critics about this code here!] //IndexOf usage with string; Benchmark result String version: 1154 ms int i = s.IndexOf("a"); //Finds first "a" string in s. //IndexOf usage with char; Benchmark result Char version: 172 ms int i = s.IndexOf('a'); //Finds first 'a' char in s. 2-the complex form are entire programs, objects,methods, even controls. (You made them for your simplification in coding for later uses, as reminders or as core codes.)

                  //"And reusable code should be built and its executable code should reside in DLL files."

                  Yes, it can be store in a dll "the complex forms", but visually is hidden. I suppose you spent hours to look into all dlls to find a specific piece of code that must be adapted to your current needs / or find that special method that do some specific work. If you have 100 or maybe 1000 dll ; or 1 dll with 1000 methods/properties in it, I will, for example, spent hours to search for them. Maybe after lots of usages you learn it and you have a easy way on looking at it...its possible. But yes, its a right way with making a dll. I am not accustom with making it. I know how to make it, but its usage I dont find it easily for my needs. I need a solution for something fast to look/search/edit visually and explicitly.

                  1 Reply Last reply
                  0
                  • _ _Q12_

                    "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

                    D Offline
                    D Offline
                    dan sh
                    wrote on last edited by
                    #9

                    I always have a solution called Reusables in my computer. It has very well structured set of classes where I keep the code. It has a variety of things I have felt like keeping in last five years. As Luc said, code should be in source files and not anywhere else.

                    "Your code will never work, Luc's always will.", Richard MacCutchan[^]

                    _ 1 Reply Last reply
                    0
                    • D dan sh

                      I always have a solution called Reusables in my computer. It has very well structured set of classes where I keep the code. It has a variety of things I have felt like keeping in last five years. As Luc said, code should be in source files and not anywhere else.

                      "Your code will never work, Luc's always will.", Richard MacCutchan[^]

                      _ Offline
                      _ Offline
                      _Q12_
                      wrote on last edited by
                      #10

                      As I responded to Luc, I need a solution for something fast to look/search/edit visually and explicitly. I did what you say, I have made a solution and inside it stored lots of pieces of codes. As a editable and storage way is a good way, yes, but if i have to search (visually and/or explicitly) inside them, well..., I have to guess a lot to find what i need(and i usually repeat a lot of codes to find them more easily). As I said, I done this type of storage, but for me is not the right way. Its a good idea to keep in mind, you must accustom with it and finally adapt to it. Thanks for your response. Its a good one...but unfortunately not what I need. Maybe others will find it ok for them.

                      D 1 Reply Last reply
                      0
                      • _ _Q12_

                        As I responded to Luc, I need a solution for something fast to look/search/edit visually and explicitly. I did what you say, I have made a solution and inside it stored lots of pieces of codes. As a editable and storage way is a good way, yes, but if i have to search (visually and/or explicitly) inside them, well..., I have to guess a lot to find what i need(and i usually repeat a lot of codes to find them more easily). As I said, I done this type of storage, but for me is not the right way. Its a good idea to keep in mind, you must accustom with it and finally adapt to it. Thanks for your response. Its a good one...but unfortunately not what I need. Maybe others will find it ok for them.

                        D Offline
                        D Offline
                        dan sh
                        wrote on last edited by
                        #11

                        A well designed solution should be good Maybe you can try some source control software. I personally, name classes appropriately so I do not have to search a lot for what I need.

                        "Your code will never work, Luc's always will.", Richard MacCutchan[^]

                        1 Reply Last reply
                        0
                        • _ _Q12_

                          "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          Sometimes as a simple .snippet[^]-file, or as an item-template[^] if it's a complete class. One can share the locations to these snippets and paths in a team :) If both categories don't fit, I'll most likely write another article; since an article would describe the problem that's being solved and probably would have example-code.

                          I are Troll :suss:

                          1 Reply Last reply
                          0
                          • _ _Q12_

                            "Most used" codes are the ones that you as a programmer put them away in a safe directory and from time to time peak at them when you are in trouble. You put them there and you know their order and meanings just enough to came in handy when you most in need of them. My question is: -How you people do this collection? ... more specific, in what form do you save these "most used" codes of yours? (my presumption is: You have a bunch of docx files with ton of codes inside them? You have some html pages saved from internet and stored somewhere safe? A bunch of simple text files, each one containing codes?)

                            A Offline
                            A Offline
                            Abhinav S
                            wrote on last edited by
                            #13

                            Tons of simple notepad files. However, this is a very generic topic and not an ideal topic for discussion in the C# forum.

                            The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                            _ 1 Reply Last reply
                            0
                            • A Abhinav S

                              Tons of simple notepad files. However, this is a very generic topic and not an ideal topic for discussion in the C# forum.

                              The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                              _ Offline
                              _ Offline
                              _Q12_
                              wrote on last edited by
                              #14

                              yes, I am actually using this idea with txt files. But I also search for alternatives...that's why this topic. I am not sure if im doing it right, but at some level it seem that is the best way of storing my custom codes. I am curious if anybody have such a code library in the txt file format.... I wish to see how you do it. An example is great. thx.

                              R 1 Reply Last reply
                              0
                              • _ _Q12_

                                yes, I am actually using this idea with txt files. But I also search for alternatives...that's why this topic. I am not sure if im doing it right, but at some level it seem that is the best way of storing my custom codes. I am curious if anybody have such a code library in the txt file format.... I wish to see how you do it. An example is great. thx.

                                R Offline
                                R Offline
                                RobScripta
                                wrote on last edited by
                                #15

                                I think what you are looking for is what I use, it's a program called notetab (www.notetab.com). It's not free but cheap, and the best advantage is that you can create outline files. In an outline file you have at the left the table of content and you can jump to that page. If you organise your notes in appropiate outlines (tabbed at the top of the page) you can quickly jump to the correct note. I use this tool for "howto's" like push this button, and choose this checkbox etc. An example of this; if I need to display PDF's in a solution I choose my csharp outline, and click the page "pdf", there I have collected all my notes on how to handle pdf files (including links to my FTP notes). As I use a version of about 10 years old, I can't advise between the standard and pro version of the tool, but you definiately need outlines. Pure reusable code I have in a utilities DLL that is linked to every project. E.g. I use MySql as a database in almost all my projects, so code to connect to the database and manage the connection is all in the utilities DLL. Hope this helps. Rob

                                _ 1 Reply Last reply
                                0
                                • _ _Q12_

                                  //"The vast amount of code is not generic. It has a specific purpose that has little if no meaning elsewhere."

                                  Yes I know that, and I agree. In essence is as you say.

                                  //"Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it."

                                  Well, suppose you make 5 year ago a very good code (for yourself) and now you remember that you have that code, you have a similar application to make (some modification is required but at the base that code from 5 years ago remain the same at the core). You have the project from 5 years ago, saved into a 30G Hdd somewhere in your house? You make, back then for yourself, a library (as you suggested in your response)? 1-the simplest form of what is to store is like this: [this is a pure example -I don't want critics about this code here!] //IndexOf usage with string; Benchmark result String version: 1154 ms int i = s.IndexOf("a"); //Finds first "a" string in s. //IndexOf usage with char; Benchmark result Char version: 172 ms int i = s.IndexOf('a'); //Finds first 'a' char in s. 2-the complex form are entire programs, objects,methods, even controls. (You made them for your simplification in coding for later uses, as reminders or as core codes.) Thank you. Your response is the closest of what I intend to know. I hope that with your help I can decipher this mystery I am in to.

                                  J Offline
                                  J Offline
                                  jschell
                                  wrote on last edited by
                                  #16

                                  merlinq12 wrote:

                                  //"Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it."

                                  Well, suppose you make 5 year ago a very good code (for yourself) and now you remember that you have that code, you have a similar application to make (some modification is required but at the base that code from 5 years ago remain the same at the core). You have the project from 5 years ago, saved into a 30G Hdd somewhere in your house? You make, back then for yourself, a library (as you suggested in your response)?

                                  I create lots of good code. How would I know that when I created that code that I would want to use it 5 years from now?

                                  _ 1 Reply Last reply
                                  0
                                  • J jschell

                                    merlinq12 wrote:

                                    //"Code copying is done when code has a relationship to new functionality but requires modification. In those case I know where the original code is so I just go get it."

                                    Well, suppose you make 5 year ago a very good code (for yourself) and now you remember that you have that code, you have a similar application to make (some modification is required but at the base that code from 5 years ago remain the same at the core). You have the project from 5 years ago, saved into a 30G Hdd somewhere in your house? You make, back then for yourself, a library (as you suggested in your response)?

                                    I create lots of good code. How would I know that when I created that code that I would want to use it 5 years from now?

                                    _ Offline
                                    _ Offline
                                    _Q12_
                                    wrote on last edited by
                                    #17

                                    Well, the idea is not how you will know, because you never know what you will need in 10 minutes or 10 years from now on. The idea is how you find some very good code write sometime ago by you and put it to use (in the same direction or an alternative one with slight modifications). Lets presume...that you work on a game now, and after 5 years you will have a similar project somewhere else...it wont be beneficial if you will be able to take the entire or a part of "AI" from this game and reproduce it to the future one? (its just an example-but who knows). The really important blocks of codes from a big project or a small one, is not worth to copy it away in some deposit known only by you? The code and some nice directions/explanations, etc. But in the same time to be able to browse with no headache, search in a currently page or in all files at once and re/edit it as you go very fast and no headache involved also. To achieve this, the file format that you storage must be very well choose. thanks.

                                    M 1 Reply Last reply
                                    0
                                    • R RobScripta

                                      I think what you are looking for is what I use, it's a program called notetab (www.notetab.com). It's not free but cheap, and the best advantage is that you can create outline files. In an outline file you have at the left the table of content and you can jump to that page. If you organise your notes in appropiate outlines (tabbed at the top of the page) you can quickly jump to the correct note. I use this tool for "howto's" like push this button, and choose this checkbox etc. An example of this; if I need to display PDF's in a solution I choose my csharp outline, and click the page "pdf", there I have collected all my notes on how to handle pdf files (including links to my FTP notes). As I use a version of about 10 years old, I can't advise between the standard and pro version of the tool, but you definiately need outlines. Pure reusable code I have in a utilities DLL that is linked to every project. E.g. I use MySql as a database in almost all my projects, so code to connect to the database and manage the connection is all in the utilities DLL. Hope this helps. Rob

                                      _ Offline
                                      _ Offline
                                      _Q12_
                                      wrote on last edited by
                                      #18

                                      Notetab definitely is a great help. Thank you for pointing it to me. I was trying a lot of editing software (MS.Word, MindManager, Dreamweaver,ysitebuilder,html editors even C#-as a editing tool , but in time i give up and I return to the old txt files.) Why? -Because I needed a fast way to look/search/edit visually and explicitly. Changing the subject from notetab a bit,...The best wysiwyg software I encounter until now remain MS.Word - I have worked with it a lot and tried other variants of wysiwyg's but Word remain the no# 1...for me. So, if they could manage to make some search capabilities between docx files (not only infile)... then I will be not so stressed...but until that will appear, I'll stick with the oldies. Why I specify about that, is because the txt files are the inexpensive files for search inside them with minimum of hardware stress and with great speed (manual or automatic). That is the only reason I come back for them...though my heart is crying after wysiwyg friendliness. This is my "of".

                                      1 Reply Last reply
                                      0
                                      • _ _Q12_

                                        Well, the idea is not how you will know, because you never know what you will need in 10 minutes or 10 years from now on. The idea is how you find some very good code write sometime ago by you and put it to use (in the same direction or an alternative one with slight modifications). Lets presume...that you work on a game now, and after 5 years you will have a similar project somewhere else...it wont be beneficial if you will be able to take the entire or a part of "AI" from this game and reproduce it to the future one? (its just an example-but who knows). The really important blocks of codes from a big project or a small one, is not worth to copy it away in some deposit known only by you? The code and some nice directions/explanations, etc. But in the same time to be able to browse with no headache, search in a currently page or in all files at once and re/edit it as you go very fast and no headache involved also. To achieve this, the file format that you storage must be very well choose. thanks.

                                        M Offline
                                        M Offline
                                        Michael9000
                                        wrote on last edited by
                                        #19

                                        When I started programming I created a lot of small code-samples to the the hang of the more complex things, and they are zipped with search-tags in their filenames. Now I'm doing the same for the abandoned projects thats worth saving.

                                        _ 1 Reply Last reply
                                        0
                                        • M Michael9000

                                          When I started programming I created a lot of small code-samples to the the hang of the more complex things, and they are zipped with search-tags in their filenames. Now I'm doing the same for the abandoned projects thats worth saving.

                                          _ Offline
                                          _ Offline
                                          _Q12_
                                          wrote on last edited by
                                          #20

                                          Can you provide me with some examples of your search-tags for filenames you use? And what kind of files are you using for storage -txt,html,doc? -or it dont matter. Thank you.

                                          //I for example use this:
                                          MostUsedCodes .txt
                                          stringsCase-Insensitive Equals_b.txt
                                          stringsSearch Contains_b.txt
                                          stringsSearch IndexOf_i.txt
                                          stringsSearch IndexOfAny_i.txt
                                          stringsSearch LastIndexOf_i.txt
                                          stringsSearch LastIndexOfAny_i.txt
                                          stringsTest EndsWith_s.txt
                                          stringsTest StartsWith_s.txt
                                          //note: _s = string; _i=integer;

                                          M 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