Comments on: Developing at the speed of thought http://compsci.ca/blog/developing-at-the-speed-of-thought/ Programming, Education, Computer Science Wed, 30 Sep 2020 08:31:44 -0400 http://wordpress.org/?v=2.8.4 hourly 1 By: David Keech http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100930 David Keech Sat, 12 Jan 2008 20:43:38 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100930 Aaaaiiiieeee ! I just read through all 4600 lines of that Sudoku program. I now understand how he managed to get so many lines. Loop ? What's a loop ? This function could well be submitted as a CSOTD to worsethanfailure.com: //unique solution number public static long solutionTime () { long enterMilliSec = System.currentTimeMillis (); long checkMilliSec = System.currentTimeMillis (); checkMilliSec = System.currentTimeMillis (); return checkMilliSec; } Not only is it not unique (Hello "race condition") but checkMilliSec is assigned twice and enterMilleSec isn't even used. It's a good thing Java has garbage collection. Several of the methods he HAS written could be replaced by a single line. Also, the convertToString() method should be called toString(). Aaaaiiiieeee ! I just read through all 4600 lines of that Sudoku program. I now understand how he managed to get so many lines. Loop ? What’s a loop ?

This function could well be submitted as a CSOTD to worsethanfailure.com:

//unique solution number

public static long solutionTime ()

{

long enterMilliSec = System.currentTimeMillis ();

long checkMilliSec = System.currentTimeMillis ();

checkMilliSec = System.currentTimeMillis ();

return checkMilliSec;

}

Not only is it not unique (Hello “race condition”) but checkMilliSec is assigned twice and enterMilleSec isn’t even used. It’s a good thing Java has garbage collection.

Several of the methods he HAS written could be replaced by a single line. Also, the convertToString() method should be called toString().

]]>
By: David Keech http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100928 David Keech Sat, 12 Jan 2008 20:13:48 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100928 4600 lines ! How the hell did they manage to write 4600 lines that does nothing but create Sudoku puzzles. I just had a quick look through the Sudoku solver that I wrote a while back and it comes in at 382 lines. That includes all the HTML and display code. Modifying it so that it creates new puzzles would only add 20 or so lines... and creating the new puzzles EFFECIENTLY would only take about 40 or 50. I keep meaning to add those 40 or 50 lines but it requires so much THINKING before hand that I never have enough time in one stretch to do it. That said, I do occasionally find myself spending more time coding than thinking. Or, more accurately, more time debugging than thinking. The reason for this is mostly due to inexperience with the language in question. Being a Sysadmin now, rather than a dedicated coder, I tend to switch from Perl to PHP to bash to C to C to Java depending on what is needed. Frequently, the language that is most appropriate is one that I haven't used before or haven't used for a long time. Most of the programs I write these days are exceedingly simple and don't require all that much thought anyway. I also tend to have to debug other people's code when they put it on the live server and it breaks everything. I don't get the luxury of "thinking time"... I have the CEO or my line manager on my back asking when things will be working again. There's a great book called "The Pragmatic Programmer" that discusses a lot of this stuff. They mention the "DRY" principle and go into detail about many other things that affect real-world coding. Definitely worth a read. 4600 lines ! How the hell did they manage to write 4600 lines that does nothing but create Sudoku puzzles. I just had a quick look through the Sudoku solver that I wrote a while back and it comes in at 382 lines. That includes all the HTML and display code. Modifying it so that it creates new puzzles would only add 20 or so lines… and creating the new puzzles EFFECIENTLY would only take about 40 or 50.
I keep meaning to add those 40 or 50 lines but it requires so much THINKING before hand that I never have enough time in one stretch to do it.

That said, I do occasionally find myself spending more time coding than thinking. Or, more accurately, more time debugging than thinking. The reason for this is mostly due to inexperience with the language in question. Being a Sysadmin now, rather than a dedicated coder, I tend to switch from Perl to PHP to bash to C to C to Java depending on what is needed. Frequently, the language that is most appropriate is one that I haven’t used before or haven’t used for a long time. Most of the programs I write these days are exceedingly simple and don’t require all that much thought anyway. I also tend to have to debug other people’s code when they put it on the live server and it breaks everything. I don’t get the luxury of “thinking time”… I have the CEO or my line manager on my back asking when things will be working again.

There’s a great book called “The Pragmatic Programmer” that discusses a lot of this stuff. They mention the “DRY” principle and go into detail about many other things that affect real-world coding. Definitely worth a read.

]]>
By: Tony http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100824 Tony Tue, 01 Jan 2008 22:45:27 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100824 @David - that's really cool that a VP <em>really</em> understands what you are doing. Developing software is a lot of mental labour, which is difficult for people outside the field to understand. After completing a task I've set out for myself, I like to go out for short walks -- get some fresh air, relax my eyes, refresh the mind. 5 minutes out does absolute wonders. Actually if I'm stuck at a problem, same also helps to think from a new perspective. Though back when I was working for a not-so-technical department at a University, they were pretty strict about such things. I was supposed to be on the clock and in the cubicle 9 to 5, actual results came second. Naturally I've made a decision to never come back to such kind of establishments, they are completely missing the point of what they are hiring developers for. @David – that’s really cool that a VP really understands what you are doing.

Developing software is a lot of mental labour, which is difficult for people outside the field to understand. After completing a task I’ve set out for myself, I like to go out for short walks — get some fresh air, relax my eyes, refresh the mind. 5 minutes out does absolute wonders. Actually if I’m stuck at a problem, same also helps to think from a new perspective.

Though back when I was working for a not-so-technical department at a University, they were pretty strict about such things. I was supposed to be on the clock and in the cubicle 9 to 5, actual results came second. Naturally I’ve made a decision to never come back to such kind of establishments, they are completely missing the point of what they are hiring developers for.

]]>
By: David Mills http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100823 David Mills Tue, 01 Jan 2008 21:48:24 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100823 It depends upon one's ability to think, of course, but generally one should spend more time thinking than typing. The director of operations, at a company where I once worked as an engineer, went to the VP, Engineering and said, "Every time I walk past David's office, he has his feet on the desk and his hands laced behind his head." The VP said, "Good, that's when he's doing his best work." It depends upon one’s ability to think, of course, but generally one should spend more time thinking than typing.

The director of operations, at a company where I once worked as an engineer, went to the VP, Engineering and said, “Every time I walk past David’s office, he has his feet on the desk and his hands laced behind his head.” The VP said, “Good, that’s when he’s doing his best work.”

]]>
By: Labnotes » Rounded Corners - 180 (Tea-Pot Controversies, 2007) http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100789 Labnotes » Rounded Corners - 180 (Tea-Pot Controversies, 2007) Sun, 30 Dec 2007 11:14:04 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100789 [...] then typing. Guilty as charged: If you are spending more time writing code, than thinking about what code you should write - you [...] [...] then typing. Guilty as charged: If you are spending more time writing code, than thinking about what code you should write – you [...]

]]>
By: Dafydd Harries http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100775 Dafydd Harries Sat, 29 Dec 2007 08:18:43 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100775 “IIf you ever catch yourself copying a part of your code to paste it elsewhere in your application - stop. Refactor. Step back and think about your design.“ While I think DRY is a Good Thing, I don't think immediate refactoring is necessarily good. The danger is that the two things turn out to be not quite the same, and then you have to introduce some conditionals, and you end up spending more time making your abstraction work than making your program work. I think it's better to copy the code and only refactor once you know it works. Premature refactoring can lead to wonky abstractions. “IIf you ever catch yourself copying a part of your code to paste it elsewhere in your application – stop. Refactor. Step back and think about your design.“

While I think DRY is a Good Thing, I don’t think immediate refactoring is necessarily good. The danger is that the two things turn out to be not quite the same, and then you have to introduce some conditionals, and you end up spending more time making your abstraction work than making your program work. I think it’s better to copy the code and only refactor once you know it works. Premature refactoring can lead to wonky abstractions.

]]>
By: Joe Campbell http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100765 Joe Campbell Fri, 28 Dec 2007 18:16:47 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100765 In reference to the first post in this comment thread I wrote a piece on taking time off what you are doing to step back and innovate. Might be an interesting read for some folk. http://ponderousprog.blogspot.com/2007/11/taking-time-out-pause-innovates.html In reference to the first post in this comment thread I wrote a piece on taking time off what you are doing to step back and innovate. Might be an interesting read for some folk.

http://ponderousprog.blogspot.com/2007/11/taking-time-out-pause-innovates.html

]]>
By: Slippy Lane http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100758 Slippy Lane Fri, 28 Dec 2007 13:03:00 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100758 Heh, I guess that's why I dropped out during the first year of my BSc. I'm definitely a "code now, structure later" type of coder. In fact, I tend to write programs the way I write stories. First comes the rough draft, then comes the first re-write, THEN I design the structure and layout, then comes the second re-write. Then I start thinking about trimming down my code. It may not be efficient, but it's fun! Heh, I guess that’s why I dropped out during the first year of my BSc. I’m definitely a “code now, structure later” type of coder.

In fact, I tend to write programs the way I write stories. First comes the rough draft, then comes the first re-write, THEN I design the structure and layout, then comes the second re-write.

Then I start thinking about trimming down my code.

It may not be efficient, but it’s fun!

]]>
By: Alan http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100753 Alan Fri, 28 Dec 2007 06:22:38 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100753 The quality of the thinking in those 3 hours has to be of a certain quality for this advice to have any merit. I don't think it is as simple as saying if you think more, you will spend less time coding. Without talking about that thought and analysis process to follow, you may very we'll just see students spend more time thinking, but no less time coding. The quality of the thinking in those 3 hours has to be of a certain quality for this advice to have any merit. I don’t think it is as simple as saying if you think more, you will spend less time coding. Without talking about that thought and analysis process to follow, you may very we’ll just see students spend more time thinking, but no less time coding.

]]>
By: Sandro Magi http://compsci.ca/blog/developing-at-the-speed-of-thought/comment-page-1/#comment-100752 Sandro Magi Fri, 28 Dec 2007 04:02:46 +0000 http://compsci.ca/blog/developing-at-the-speed-of-thought/#comment-100752 I disagree Will Johnson. Web apps are very complex, as they are essentially a distributed system, which implies all sorts of critical issues which have to be properly balanced. Issues such as latency, security (replay attacks, access control, etc.), robustness (fail over, availability, etc.), parallelism, data and code migration, and so on. It's just that the space "modern" web apps cut out is a very small piece of the space of possible web programs, simply because most web frameworks are so limited and unsafe. See the <a href="http://www.waterken.com/dev/Web/" rel="nofollow">web-calculus</a> for a idea of the hidden potential that web apps can fulfill. The web-calculus handles just about all of the above issues in a Java server environment. I disagree Will Johnson. Web apps are very complex, as they are essentially a distributed system, which implies all sorts of critical issues which have to be properly balanced. Issues such as latency, security (replay attacks, access control, etc.), robustness (fail over, availability, etc.), parallelism, data and code migration, and so on. It’s just that the space “modern” web apps cut out is a very small piece of the space of possible web programs, simply because most web frameworks are so limited and unsafe. See the web-calculus for a idea of the hidden potential that web apps can fulfill. The web-calculus handles just about all of the above issues in a Java server environment.

]]>