Search Results

Search found 2 results on 1 pages for 'mcwise'.

Page 1/1 | 1 

  • Is it bad style to redundantly check a condition?

    - by mcwise
    I often get to positions in my code where I find myself checking a specific condition over and over again. I want to give you a small example: suppose there is a text file which contains lines starting with "a", lines starting with "b" and other lines and I actually only want to work with the first two sort of lines. My code would look something like this (using python, but read it as pseudocode): # ... clear_lines() # removes every other line than those starting with "a" or "b" for line in lines: if (line.startsWith("a")): # do stuff if (line.startsWith("b")): # magic else: # this else is redundant, I already made sure there is no else-case # by using clear_lines() # ... You can imagine I won't only check this condition here, but maybe also in other functions and so on. Do you think of it as noise or does it add some value to my code?

    Read the article

  • General programming techniques to speed up coding time

    - by mcwise
    I am preparing for a programming contest in C++ where it is all about producing working code in a short time. An example would be to use a macro to get the minimum of two ints(but I was told that you shouldn't use macros as they are not type-safe) or using memsets to initialize arrays (but I was told that you shouldn't use memsets in C++). This leads to the question, what kind of coding techniques exist to use at a real job?

    Read the article

1