1. Re: Coding style (was Subversion Repository for Euphoria)
- Posted by Chris Bensler <bensler at nt.net> Nov 27, 2006
- 537 views
Robert Craig wrote: > > > Of course, style guidelines can be imposed for the project, but I think it > > would > > be more practical to create a tool that reformats any contributed code in a > > standard way. > > Perhaps we could run a C and/or Euphoria "beautifier" on the code > once in a while. I read that there are some negatives for running > a beautifer script on each SVN check-in. Also, we might want > certain standards that go beyond what a beautifier can handle. Maybe a maintenance schedule should be considered. It would include things like making sure documentation is properly updated, code styling, cleanup and review, and a testing regiment. > > Second, what is the purpose of so much whitespace anyways? > > Why do most people agree on 4 space TAB. What's wrong with 2 or 3 spaces? > > I've used 3, 8 and for the last several years, 4. > It's purely a subjective thing, but I find that > with 8 you have a lot of lines running off the right > side of the screen. With 2, it's visually harder to line up > the levels of indentation over a long routine. Especially > in C, where '}' is the only block terminator, not "end if" > "end while" etc. Good point. I use 2 space tabs. Though I've never noticed any real problem with lining up code. I use the bracket matching function in my editor when it's more convenient. Collapsable code eidtors would also eliminate that issue. Probably more than 75% of large routines should be reevaluated anyway. I'm a firm beleiver in modularity and maintainability even if it's at the expense of efficiency. But that's just my opinion and an entirely different religious programming war and modularity is not always appropriate :) In C you can use inlined functions or macros to segregate code functionality and retain efficiency. > > What about varying size based on context and purpose? > > I've never seen much point in varying the indent size. > Consistency promotes readability. I think you misunderstood what I meant about varying size. For example, I indent elements of a comma separated list and continued (long) lines with 3 tabs, so even if it's buried among other code, it's evident what statement a line of code belongs to. I also indent variable declarations within routines with a single space, making it visually evident at a glance that they are declarations and not executable code. This style habit is probably why I prefer 2 space tabs. With larger tabs, a triple indent would be inappropriate and 2 would be confused with a block indent. Anyway, I don't expect to convince anyone, but I find it helpful. Maybe someone else will too. Or maybe someone could tell me why I shouldn't do it that way. Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria