tag:blogger.com,1999:blog-7101933101966798446.post2059766569533661337..comments2024-03-28T10:33:06.910-07:00Comments on The View from Aristeia: The Line-Length ProblemScott Meyershttp://www.blogger.com/profile/05280964633768289328noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-7101933101966798446.post-26018425046828464592013-04-15T04:07:49.434-07:002013-04-15T04:07:49.434-07:00Having returned a number of great programming book...Having returned a number of great programming books because of the formatting. The effort you're putting in will be greatly appreciated.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-56690343055071337082013-03-20T10:01:17.181-07:002013-03-20T10:01:17.181-07:00@Bart Vandewoestyne: McConnell's objections to...@Bart Vandewoestyne: McConnell's objections to endline comments are reasonable for real code, but they are less appropriate for code in books designed to explain things. For example, the time needed to format the comments at the end of the line is no different from time taken to format anything else for maximum clarity, and the demands of maintaining the comments in a code base (the book) that is unlikely to change over time can be ignored. Furthermore, real code is generally viewed on computer screens where the content can be scrolled so that the viewer sees the context that is most important. Printed books have no such capability, and even digital books are often broken into unscrollable pages. This means that the best way to minimize the likelihood that a page break occurs in a bad place is to eliminate techniques that spread code across too many lines. Endline comments are one way to achieve that.<br /><br />As I noted in a previous comment, writing code for production software and writing code for books are two different tasks, and techniques suitable for one may not be suitable for the other.Scott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-62651860392008264682013-03-20T03:16:47.880-07:002013-03-20T03:16:47.880-07:00I vote for only one version of the code, the one w...I vote for only one version of the code, the one with the comments above the code instead of in the form of endline comments.<br /><br />Chapter '32.5 Commenting Techniques' in Steve McConnell's Code Complete, 2nd edition, has a nice discussion on why endline comments are less preferable. I quite agree with what he writes.Bart Vandewoestynehttps://www.blogger.com/profile/15864107848559392386noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-61654885203725558272013-03-16T18:22:50.411-07:002013-03-16T18:22:50.411-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-43485134755382515632013-03-16T16:40:53.172-07:002013-03-16T16:40:53.172-07:00I vote for both line lengths. I find the wide vers...I vote for both line lengths. I find the wide version much more readable. I would also probably want access to both formats: wide for my iPad, and narrow for my Nexus 4, since I read programming books on both.Tom Panninghttps://www.blogger.com/profile/03246173249356394513noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-20778465908410059452013-03-14T10:50:55.103-07:002013-03-14T10:50:55.103-07:00Either choice seems equally fine to me as long as ...Either choice seems equally fine to me as long as there is no horizontal scrolling or line breaks. I always prefer portrait mode anyway.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-65098158333243684992013-03-14T10:20:38.559-07:002013-03-14T10:20:38.559-07:00@Anonymous: Whether it's worth the trouble to ...@Anonymous: Whether it's worth the trouble to format code displays twice is something I'm trying to decide :-)Scott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-5867017692362863142013-03-14T10:18:53.838-07:002013-03-14T10:18:53.838-07:00@Zahir: Do you mean that trailing comments did not...@Zahir: Do you mean that trailing comments did not display properly on your Kindle? If so, was the problem that they wrapped?<br /><br />I can't speak for other authors, but I can tell you that my books were designed to look good in only one context: print (or PDF, which is essentially the same as print, in terms of appearance). It's thus no surprise that they don't necessarily look good in other contexts, e.g, narrower layout formats. Hence my goal for this project to increase the likelihood that the book will look good in a range of reading contexts.Scott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-48881635759599350372013-03-14T10:15:17.871-07:002013-03-14T10:15:17.871-07:00@Neil: A printed book is a wide platform, so if th...@Neil: A printed book is a wide platform, so if there is special support for wide platforms, the book will get it. If we decide to go with a single width code display for all platforms, the printed book will get the same width as all other platforms. Practically speaking, there is one document (the manuscript I produce), and there are multiple output devices (platforms). I'm trying to figure out what needs to go into the document such that it displays well on out all output devices. Print books are not special. They're just one of several target output devices.<br /><br />Regarding fields and macros, I have looked into them a bit, but my impression is that they would be hard to work with for code displays. I definitely want to edit the source code in the document, because I need to apply formatting, plus I chose line breaks and even identifier names based on what will fit in the available horizontal space. Writing code for a book is not the same as writing code for a software project, because code for a book (1) has to fit in the available horizontal space, (2) should avoid bad page breaks, and (3) should correspond to and support the surrounding prose. Code in a real project has as its primary goal to have the desired behavior. Code in a book has as its primary goal to explain something. Scott Meyershttps://www.blogger.com/profile/05280964633768289328noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-69694748020385137652013-03-14T08:16:52.167-07:002013-03-14T08:16:52.167-07:00I generally read in portrait mode on my iPad, and ...I generally read in portrait mode on my iPad, and would definitely prefer the 60+ chars/line formatting.<br /><br />The trailing comments on the same line are a big help to my understanding code examples in books.<br />Shon's Bloghttps://www.blogger.com/profile/11155783264756086526noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-51513200428505519232013-03-14T03:18:52.686-07:002013-03-14T03:18:52.686-07:00The 60 characters is 14 lines the 45 characters is...The 60 characters is 14 lines the 45 characters is 15 lines. Is the extra work really worth it ?<br /><br />I think I'll stick to portrait mode on my kindle. I prefer to be able to have code and comment on the same page than have beautiful code and comment on the next page.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-44802757296654493712013-03-13T23:55:37.772-07:002013-03-13T23:55:37.772-07:00I really don't know about the formatting; but,...I really don't know about the formatting; but, trailing comments were the real reason I gave up on Kindle version and went for the hard copy.Zahirhttps://www.blogger.com/profile/04915673855138700742noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-54970475598301624152013-03-13T21:49:10.177-07:002013-03-13T21:49:10.177-07:00I'd be disappointed with a 45-char length if m...I'd be disappointed with a 45-char length if my device supported longer. Though I will be purchasing the printed book, so I'm not sure it matters. (I'm assuming you'll make full use of the printed book's available space.)<br /><br />As for the Word conditional-text problem, have you looked into fields and macros? I'm wondering if you could have placeholder fields throughout the document for all the code listings, and then run a macro which would insert the appropriate text into each field based on some condition, such as user input or some document property.<br /><br />Once you run the macro once, the text would stay in the fields so you would be able to see the code listings in whatever format you most recently ran the macro for, rather than having to imagine what code listing goes where.<br /><br />The macro could read the actual code text from some other file or database to keep it manageable, since I doubt you'd want to embed the code strings into the macro!Neilnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-72380444837490927102013-03-13T21:47:22.383-07:002013-03-13T21:47:22.383-07:00Yes, two formats would be worthwhile. Since Word ...Yes, two formats would be worthwhile. Since Word is a given, you could mark code sections by style and loop through them, calling out to an indenter (and a syntax highlighter like VS if needed) to reformat them according to the new settings you want. You could adapt this approach to check for syntax errors as well.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-67691334708454279472013-03-13T20:34:36.967-07:002013-03-13T20:34:36.967-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/17140612538396442509noreply@blogger.comtag:blogger.com,1999:blog-7101933101966798446.post-48125553324664092922013-03-13T16:22:39.498-07:002013-03-13T16:22:39.498-07:00I absolutely think that formatting your code again...I absolutely think that formatting your code again for 60+char users would be appreciated. I don't know exactly how much effort goes into a reformatting, but it is very frustrating to have large viewing areas and not be able to make good use of them, as presumably the user paid additional money for a larger device.DeadMGhttp://codepuppy.co.uknoreply@blogger.com