#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    14
    Rep Power
    0

    Categorizing Code Snippets?


    Guys, is there a system for easily finding your code examples or does everyone just commit everything they learn to memory?

    In other words, it occurred to me that each piece of my code (while heavily commented) would benefit a classic "tagging" approach so that I could more easily find code examples going forward. For example, GW500SE was kind enough to just give me the solution of how to easily shorten a string that contains a month, dates (weekend) and year so that the month is reduced to 3 days instead of long form.

    I'd like to categorize that with a "shorten date string" tag so that, down the line, when I need to do that again, I can easily find it.

    Is there a standard approach people use to do such things today?
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    The example you gave, I could re-create from memory. Eventually, the list of things you'd have to go look up is small enough that you have that list memorized.

    Programming is not a lot of rote memorization in schools, but being a good programmer involves a lot of remembering the best way to do things (and constantly seeking out better ways).

    You could certainly look into PHPDocumentor though. Using @tags you can tag your code however you like, and generate a wiki of your own code automatically.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by ManiacDan
    but being a good programmer involves a lot of remembering the best way to do things (and constantly seeking out better ways).
    Yep, there's the rub. The issue is, there are many of us that will never do more than dabble. I coded in VB (going back to the BASIC interpreter, then QuickBasic into VB for MS-DOS and finally VB (I stopped just before .NET came on the scene). Even with all those years of coding I was lucky if I used it for more than 2 or 3 small projects a year. Doing it that sparingly means you're going to have a challenge remembering everything given the lack of repetition.

    One group I respect heavily are quality programmers. I used to own a game testing company and have personally met and worked with some of the most talented coders and the planet and, to me, they're as impressive as Mozart, Shakespeare or Walt Whitman. I simply do not have the natural instincts or inclination to be a coder.

    You could certainly look into PHPDocumentor though. Using @tags you can tag your code however you like, and generate a wiki of your own code automatically.
    Thanks. I'll look into that.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    That's the problem with every high-skilled task. There's no more of a way of memorizing PHP than there is of memorizing drafting, metal working, or car repair.

    You certainly have the right mindset, why do you think you can't be a great coder?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    14
    Rep Power
    0
    For one thing I'm 48 now so it's less likely. However, I am heavy into Wordpress and I like the idea of coding widgets and such in PHP if I can get there. A family member has a nice small business doing web design work and could use PHP coding help so, hey, you never know.

    However, the big thing I recall back in the 80's when I was coding much of my time (I was a network admin then) was that I got what I called "jello head" whenever I'd code for several hours on end. It was like being hung over. Headache, dull feeling, worn out. I never saw that with the "natural" coders I worked with. They could do it all day, all night and never have any such symptom.

    I think it boils doing to possibly the logic issue. All the great coders I know were great with logic puzzles. I'm okay at them but certainly not remarkable.

    For example, take the following puzzle:

    "You have 3 baskets, one with apples, one with oranges and one with both apples and oranges mixed. Each basket is closed and is labeled with ‘Apples’, ‘Oranges’ and ‘Mixed’. Unfortunately, all three boxes are mislabeled. How would you pick only one fruit from a basket to place the labels correctly on all the baskets?"

    When I do a tech interview I'll often ask that question. Good coders will generally answer a question like this almost immediately. I'll get the answer but I'll have to work it out and it's easier if I can have my white board handy to draw it out.
  10. #6
  11. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    Ah, yeah. I can see that. (Pick one from the mixed, that one is whatever is inside it, take the mixed label and place it on the box which you did not just steal a sign from, and move the last sign to the box originally labeled mixed)

    Maybe take some online logic courses to get your brain more into that mindset? Formal logic (fitch-style calculus, specifically) was a huge help for me.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo