386 reputation
410
bio website facebook.com/thenonsequitur
location New York, NY
age 31
visits member for 3 years, 6 months
seen Jul 7 at 21:56
puts 10.downto(1).each{ |i| puts i }
puts 'Blast off!'

puts (10.downto(1).map{ |i| i.to_s } + ['Blast Off!']).join("\n")

(1..10).to_a.reverse.each{ |i| puts i }
puts 'Blast off!'

Jul
7
comment Why is a private member accessible in a static method?
BTW, this isn't a feature of OOP across the board, but rather a particular style of OOP where factories are common. Ruby, for example, is a highly OOP paradigm but a port of the above code would not work, throwing an exception when attempting to use the private member accessors. And factories are a very rare phenomenon in Ruby code. Goes hand in hand.
Jul
3
comment Do Rails Join Models Get Controllers?
You outlined exactly the right approach.
May
8
comment Writing a PHP wrapper for Javascript to safely access REST API
(1) Yes. (2) StackExchange is not suitable for asking for tutorials. But here's a good place to start: codular.com/curl-with-php. That's how to make web requests using php.
Apr
8
comment Are there flavours of OOP where some or all of the SOLID principles are antithetical to clean code?
I agree. I think the correct principle(s) to follow clearly depend on the situation, but aside from hard performance requirements, which always rank above everything else (this matters especially in game development), I tend to think DRY and KISS are usually both more important than SOLID. Of course, the more clean you make the code the better, so if can follow all the principles without conflicts, all the better.
Apr
8
comment Why is “Select * from table” considered bad practice
Wow, the accepted answer was so poor at actually explaining anything that I down-voted it. Amazed that this isn't the accepted answer. +1.
Mar
10
comment Is it conventional to raise a NotImplementedError for methods whose implementation is pending, but not planned to be abstract?
+1, but I'd also add that for this kind of convention, a little documentation can go a long way. Like a one-line note in a dev wiki, repo readme, or style guideline -- something like that -- explaining what you use this exception for.
Feb
24
comment How did separation of code and data become a practice?
@cHao, I actually agree with you entirely. I was just trying to clarify Euphoric's point, since the discussion was sidetracked by a poor example. Even though I don't really agree with said point, it is a worthy of consideration, which is why I thought it was a good idea to clarify it.
Feb
24
comment How did separation of code and data become a practice?
@cHao, forget about i18n and the vowels example. The point is you'd be surprised how often something you think is constant to you program and will never change turns out to be something you need to be able to modify or configure.
Feb
23
comment Does this justify goto statements?
+1, was just about to post this answer, and believe this should be the accepted answer. I can't believe the accepted answer got accepted because that method only works for a specific subset of nested loop algorithms, and doesn't necessarily make the code much cleaner. The method in this answer works generally.
Jan
21
comment How has an increase in the complexity of systems affected successive generations of programmers?
@Euphoric, on top of the fact that there's nothing wrong with training "merely" decent programmers, and I think the world needs more of them, I don't even think what you propose is a reliable method for determining level of talent. If someone is new to programming and is scared away by C being their introduction, it does not necessarily follow that this person does not have the capacity to be a great programmer. And for the list of basics that you mentioned, C is a terrible language to start with. If your goal is just the basics, a modern high-level language is better -- like ruby or python.
Jan
7
comment Motivate developers to keep up with admin tasks
Besides, electronic has other nice advantages. People can comment on cards asynchronously, full recorded history, full-text search, etc... It really is way more productive.
Jan
7
comment Motivate developers to keep up with admin tasks
@IanGoldby, regarding "the problem is not really that it is too much effort, but I don't know what the problem is" -- I beg to differ. My team used to have a physical board and things rarely got updated, added, or moved around. We switched to Trello and it was like night and day. We all took to it immediately and it's always up-to-date. Honestly, trust your developers here. An all-electronic version is significantly more efficient, and I think the problem is that you are failing to recognize this significance.
Dec
31
comment Emotional detachment from bad code
@Telastyn, +1. Sorry for being so confrontational before. I blame the internet. After your edit, I actually pretty much agree with what you're saying, to a degree. I've always liked the saying, "Don't just clean up after yourself, leave things in a better state than you found them." I think this is something my dad told me when I was a kid and he was referring to me making a mess of the kitchen. However, I think it actually applies to a lot of things in life, including code. And interpreted this way, your answer makes a lot of sense. And I especially agree with your new last paragraph.
Dec
30
comment Emotional detachment from bad code
-1 You didn't actually answer the question. Not only is your entire answer extremely rude and a borderline rant, what you are wrote is not even good advice. It's not true that you can always fix up bad code. Like anything else in business you have to weigh the costs and the benefits, and in some cases it would be a foolish business decision to spend time fixing up old code.
Dec
30
comment Why is the copying instruction usually named MOV?
I doubt there's any way to find out why it was originally called a "move" instead of "copy", but speculating is fun. On the wikipedia page for assembly language, it describes MOV as an operation for "moving a copy of the data", which is an interesting interpretation. Another possibility is that in terms of actual usages of MOV, the operation is conceptually a movement of data; that we don't care about the source any more.
Nov
25
comment Why do modern websites still insist on archaic username/password requirements?
While those two reasons do exist, I think you left out by far the most common reason people put these restrictions in: "(3) Because they see other sites doing it." Seriously, I think in most cases that's all there is to it. They put absolutely no thought into it, and just copy what they've seen other people do. It's cargo cult programming at its worst.
Nov
25
comment Code repetition vs multi responsible method
@Chandranshu, that class name has nothing on Swing: InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNo‌​tFocusedState. From pushing-pixels.org/2007/11/07/…
Nov
20
comment What is the benefit of switching on Strings in Java 7?
Wow, I'm surprised (in a good way) to see the official proposal actively countering type bloat. That's refreshing. Type bloat is a huge problem in Java.
Nov
12
revised How can I tell if I am overusing multi-threading?
removed the note about the edit history. this doesn't add any value to the post, and really only makes sense as a comment in response to another comment, not part of the question.
Nov
12
comment How can I tell if I am overusing multi-threading?
@exhuma, I agree with this answer but I would add to it that if you are going to use threads for simplicity of code, that's fine, but be very careful that you understand thread-safety and potential gotchas with multiple threads. What might seem like a simple piece of multithreaded code could easily have hidden race conditions that could lead to an assortment of very-hard-to-track-down bugs.