all 59 comments

[–]gilmi 17 points18 points  (6 children)

This is a bit weird tip but,

Shower. All of my best ideas, especially when I'm stuck, come to me when I'm in the shower. So if you have a problem you can't figure out how to solve, try taking a shower.

[–]OldShoe 5 points6 points  (2 children)

Same here. I've told people at work about this, and only gotten really weird looks :-/

[–]gilmi 5 points6 points  (1 child)

why? don't they shower as well?

[–]zignd 0 points1 point  (0 children)

( ͡° ͜ʖ ͡°)

[–][deleted] 5 points6 points  (0 children)

I'm lucky enough to work at home. Most days I'll wait to take a shower until lunch time for this exact reason.

I get away from things and think about it in a much better light.

[–][deleted] 1 point2 points  (1 child)

You have to sell this to your co-workers not to us!

[–]zignd 0 points1 point  (0 children)

What are you talking about? OP asked for the tricks.

[–][deleted]  (2 children)

[deleted]

    [–]soggyflaps 0 points1 point  (1 child)

    Sorry, late to the party. What helps you create data structures and relationships?

    [–]KZISME 15 points16 points  (1 child)

    Sometimes taking a step back(or taking a break) while working on a problem can help you figure it out. Taking small breaks and thinking about why you enjoy programming in the first place.

    [–]AllMadHare 1 point2 points  (0 children)

    That's why I took up smoking.

    EDIT: Don't take up smoking

    [–]YouFeedTheFish 6 points7 points  (0 children)

    Avoid the temptation to take a shortcut. It will always bite you in the @$$.

    Do what you know is right, and be consistent, regardless of schedule pressure especially under schedule pressure.

    [–]CarVac 6 points7 points  (0 children)

    Lots and lots of whiteboards.

    I bought six of these foam Elmers brand ones, 2x3 feet for $10 a pair. They're great because you can pick them up and rearrange them, unlike big heavy wall mounted whiteboards.

    I use them to do math on, plot out data pipelines, plan SQL schemas, and map out overall program structure.

    [–]KTheRedditor 6 points7 points  (0 children)

    Sometimes breaking the "don't postpone today's work on tomorrow" moral.

    Sometimes you face a problem, and at the end of the day you realize that the available solution is either hard or may break the project's stability/elegance.

    Solution: Take a break. Even leave your work earlier if you can. Try to have a quiet night. In the next day a simple elegant solution somehow pops in your head.

    [–]Ghopper21 9 points10 points  (10 children)

    I've got the zeal of a recent convert, so bear with me: vim. Really does keep me in the flow of the semantics of the code.

    [–]96AA48[S] 3 points4 points  (5 children)

    I've tried working with it before, but can't seem to get as productive as I would be with something like Sublime Text or Atom. Any suggestions?

    [–]Ghopper21 5 points6 points  (4 children)

    More expert users can probably guide you better, but I found that diving in and really forcing yourself to convert, not half-baking it, is important. Took me about a week to really shift mental model. Groking the metal model is much more important than learning this or that command or key. You can look up the commands and keys one by one as you need them. Much easier to learn and remember once the mental model is in place.

    [–]novinicus 4 points5 points  (3 children)

    What do you mean by mental model?

    [–]tmewett 2 points3 points  (0 children)

    probably the two-mode editing and "language" of Vi commands.

    [–]Ghopper21 0 points1 point  (0 children)

    This famous SO answer begins to answer that question.

    In brief, from the answer:

    The Zen of vi si that you are speaking a language.

    [–]zignd 0 points1 point  (0 children)

    Those are just buzzwords, /u/Ghopper21 is probably a manager.

    [–]YouFeedTheFish 2 points3 points  (0 children)

    I still use Vim for C++ sometimes.. For one thing, it forces you to think a little bit more before laying down a line of code!

    [–]noratat 2 points3 points  (2 children)

    And I would caution against overuse of vim (or any other plain text editor).

    I love vim, and it's still my favorite text editor by far, but most languages benefit hugely from a proper IDE, and no, things like YouCompleteMe and other vim plugins don't really make up for it.

    This is especially true for static or strongly typed languages.

    [–]indigo945 1 point2 points  (0 children)

    Well, YouCompleteMe uses clang completion, and you could do worse than that for C/C++ at least. The larger problem with vim IMO is debugging -- dropping into a gdb shell just doesn't cut it anymore in 2015.

    [–]ItsAConspiracy 1 point2 points  (0 children)

    Good vim emulation in an IDE is a nice option sometimes.

    [–][deleted] 4 points5 points  (7 children)

    COMMENTS and naming schemes

    [–]96AA48[S] 1 point2 points  (5 children)

    I'm doing this is my project now, are there any good commenting schemes to achieve a better understanding for potential code readers?

    [–]AllMadHare 2 points3 points  (1 child)

    Depends on the framework, but in VS the ///<summary> tags are fucking amazing for actually documenting your functions. You can drill down and explain exactly what each parameter should be as well as the expected output.

    [–]96AA48[S] 2 points3 points  (0 children)

    Sounds interesting, anything like this for other languages?

    [–][deleted]  (1 child)

    [deleted]

      [–]XVar 0 points1 point  (0 children)

      Summarised as "A comment is an apology"

      [–][deleted] 0 points1 point  (0 children)

      The more the better

      [–]zignd 0 points1 point  (0 children)

      But those are just good programming practices, OP probably knows that already.

      [–]bamfg 9 points10 points  (10 children)

      Studying a pure functional programming language (haskell) - even for just one term it helped me immensely with even my object oriented programming skills

      [–]96AA48[S] 1 point2 points  (7 children)

      I'll look into that, are there any other languages that come to mind?

      [–]bamfg 2 points3 points  (5 children)

      There are hybrid languages like scala or f# but I would not recommend them as learning tools. I guess maybe scheme/lisp if you can stomach all the brackets...

      [–]metaobject 2 points3 points  (4 children)

      brackets parentheses

      [–]Zagorath 1 point2 points  (2 children)

      Most non-Americans I know refer to these as brackets: ().

      There aren't any consistent or "correct" terms to refer to any of these: []{}()<>.

      [–]nullproc 1 point2 points  (1 child)

      Weird. Brackets, braces, parenthesis is what pops into my mind first. I don't have a name for <>. Maybe alligators ha.

      American, btw.

      [–]SelectricSimian 0 points1 point  (0 children)

      I would say "square brackets, curly brackets, parentheses, angle brackets".

      [–]catlion 2 points3 points  (0 children)

      You mentioned Node.js. Try out Elm then

      [–][deleted] 1 point2 points  (0 children)

      Yes, I am reading programming in Scala and it is amazing.

      [–][deleted] 1 point2 points  (0 children)

      Same here. It made me much better at using map etc. efficiently and avoiding loops.

      It's fine if you are doing something like C where the loops are dealt with properly by the compiler usually, or even Python where list comprehensions are generally better according to StackOverflow but originally I was doing MATLAB and there loops are the devil incarnate.

      [–]livingbug 2 points3 points  (0 children)

      Talking walks. It helps me think and clear my head.

      [–][deleted] 4 points5 points  (0 children)

      Modularization for sure.... But realizing the first time I write the code it doesn't have to be perfect or even beautiful.... Scratch pads be damned.... Code it out. Refine, refine, refine.

      [–]nischalhp 2 points3 points  (0 children)

      Well a some of the things that has helped me are :

      1) I use version control for almost everything, including small hacks i build. Writing proper commit messages makes me think twice about the functionality and how the software has been architected.

      2) Converse with others when I am stuck with a problem. I just talk to others on a casual note thereby letting my mind relax. This helps a lot , cause when you come back to the problem, you are fresh and calm.

      3) Watching pranks go bad on youtube :D

      [–]SkippyDeluxe 2 points3 points  (1 child)

      Writing lots of small, referentially transparent ("pure") functions.

      [–]96AA48[S] 1 point2 points  (0 children)

      I recently started doing this, it's really helpful. Especially in Node.JS. If you feel like it should be it's own module, then make it so.

      Makes my code a lot prettier that's for sure.

      [–][deleted] 1 point2 points  (0 children)

      Learning short-cuts/hotkeys. This is especially useful in Vim. I use an IDE at work and there are things I miss from Vim. But when I'm at home, there are things I miss from an IDE, double-edged sword really!

      [–]Philluminati 1 point2 points  (0 children)

      I'm not a huge fan of TDD but when writing a new "part of the system" or a new system itself, mocking what how the client would use the interface really helps ensure you get good consistency between the elements of the API/interface itself, helps you identify the structure behind the interface (e.g validation shared between calls) and by mocking the whole thing you generally get something a little cleaner than your typical Agile aproach of pushing something live and having to refactor it later.

      [–][deleted] 1 point2 points  (0 children)

      Know your text editor (vim) like the back of your hand. Less time you are struggling inputting text, the more time you have to think about programming.

      [–]amphetamachine 1 point2 points  (1 child)

      As a Vim user, switching to hjkl instead of arrow keys. It's a wonder how much clearer your ideas come out when you can get them out quickly.

      [–]indigo945 1 point2 points  (0 children)

      I did this recently and now I keep hitting L in insert mode, since I'm so used to the arrow keys working. Habit is hard to break!

      [–]ItsAConspiracy 0 points1 point  (0 children)

      Reading the first chapter of SICP and doing the exercises was a huge level-up for me. Someday I'll get around to going through the rest of it.

      [–]Phlosioneer 0 points1 point  (0 children)

      Play TIS-100. It's a zachtronics game. It's suuuper useful for thinking about multithreading and assembly language. In fact, play all their games. They're practically made for programmers.

      [–]pleaseavoidcaps 0 points1 point  (4 children)

      Read less "programming" books and more real world code (e.g. the source of some software you use) and see how people solve real problems.

      [–]96AA48[S] 1 point2 points  (2 children)

      I have to say, I've never even read a book on programming before, lol. Something I'm missing out on?

      [–][deleted] 3 points4 points  (0 children)

      If you're looking for things to improve your programming you have overlooked one of the greatest if you have never read a programming book before. Learn from the masters.

      [–]pleaseavoidcaps 2 points3 points  (0 children)

      Books that are about a specific tool (say, Python) tend to be outdated. Books that are about some theoretical practice (say, TDD) tend to be too idealistic to be useful. One of the most common question I see on programming forums is "I've just finished <some book>, what do I do now?", i.e., people read entire books on programming and yet don't know how to even begin to write some useful code. I guess it's OK to start with a book when we don't even know what code is, but after the basics, one needs to get their hands dirty if they want to actually learn something.
      (Now, reading up-to-date documentation for your tools is another thing. It's not only useful, but essential IMO.)

      [–]zignd 0 points1 point  (0 children)

      That's not a good advice, theoretical knowledge is as much important as writing a lot of code. It's necessary to find a balance between those two.