Howdy, all. It's time for a thought on code cleanliness 1) It's probably a good idea for us to start documenting the functions we write and the APIs we create. For one, it's a reminder to think about what specific problems the function/API is solving. Beyond that, it helps someone unfamiliar with the code figure out what's going on, and it helps them avoid misusing a particular function. That will help keep the code clean because it'll decrease the likelihood that we have to disentangle two bits of code that shouldn't have been coupled in the first place. As mentioned in CODING, we use doxygen.
Note that my intention here isn't to have folks pick through the code and document _every last thing right now_. But rather, it's for people to document the code that they're working with, working on, and writing, as they do so. 2) We need to have a maximum line length. It can be long, sure, but it's pretty obscene when there are lines so long that they wrap on my 26" widescreen monitor (layout_util.c is a pretty bad offender). I'm going to suggest 160 characters; see * below. 3) Indentation. First, we should probably document the size of the tabs (currently 8 characters, at least from the one file I'm looking at). Secondly, it would take a lot of effort to switch, but I think we should at least consider a more compact indentation format. I'm personally a fan of 4 spaces. But I think that the width of our indents is a contributing factor to the immense lengths of lines in our code. * Below is a histogram of line lengths in our .c files. I think 160 characters is sufficiently long that it won't be _too_ much of a chore to shorten all of the super-long lines, but it's still short enough to be feasible on most of today's monitors. 16:28:27> [xsdg{intercal}@~/files/compile/photos/gitqi/src] $ruby -e 'lc = Hash.new{|h,k| h[k] = 0}; ARGV.each{|f| File.new(f).each_line{|l| l.gsub!(/\t/, " "*8); lc[l.length/10] += 1}}; csum = 0; lc.sort.each{|(x,y)| csum += y; printf "%3d-%3d: %s %d\n", 10*x, 10*(x+1)-1, y.to_s.ljust(5), csum}' *.c 0- 9: 26174 26174 10- 19: 8520 34694 20- 29: 12967 47661 30- 39: 11622 59283 40- 49: 7885 67168 50- 59: 6237 73405 60- 69: 5867 79272 70- 79: 5349 84621 80- 89: 3516 88137 90- 99: 1951 90088 100-109: 1120 91208 110-119: 579 91787 120-129: 313 92100 130-139: 93 92193 140-149: 43 92236 150-159: 21 92257 160-169: 20 92277 170-179: 18 92295 180-189: 23 92318 190-199: 36 92354 200-209: 59 92413 210-219: 39 92452 220-229: 5 92457 ** an expanded version of the ruby one-liner above: ruby -e 'counts = Hash.new{|h,k| h[k] = 0}; # default value of 0 ARGV.each{|fname| File.new(fname).each_line{|line| line.gsub!(/\t/, " "*8); # count a tab as 8 spaces counts[line.length/10] += 1 # histogram with bucket size 10 } }; csum = 0; # cumulative line counts counts.sort.each{|(range, count)| csum += count; printf("%3d-%3d: %s %d\n", 10*range, 10*(range+1)-1, count.to_s.ljust(5), csum) }' *.c --xsdg ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Geeqie-devel mailing list Geeqie-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geeqie-devel