397 reputation
410
bio website facebook.com/thenonsequitur
location New York, NY
age 31
visits member for 3 years, 10 months
seen Oct 31 at 17:02
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!'

Oct
21
comment Environment that enables variable constraint checking and
I think your first method you showed, before your progressions, was the best. I think you are vastly underestimating the power in simplicity here. I think that method is actually the most maintainable.
Jul
22
comment Started wrong with a project. Should I start over?
@Aaronaught, take it easy. Of course nobody takes that phrase at face value. It's just word play.
Jul
14
comment Designing database related methods, which is better to return: true/false or row affected?
That said, if your requirements change in the future end you do end up needing more information about the operation aside from success/failure, the method outlined in this answer is an excellent way to encapsulate the information.
Jul
14
revised Designing database related methods, which is better to return: true/false or row affected?
edited body
Jul
14
comment Designing database related methods, which is better to return: true/false or row affected?
@HoangTran, don't underestimate the cost of a "little more code". I downvoted this answer because that's actually one of the most costly things you can do. Even though in absolute terms the complexity here is not very much, compared to the possible alternatives this answer is actually significantly more complex. Image if you made everything this much more complex than you have to. Then you end up with a whole program significantly more complex than it has to be. This answer violates KISS and YAGNI and is not the right approach (see my answer for a more detailed explanation of this point).
Jul
14
answered Designing database related methods, which is better to return: true/false or row affected?
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 Single statement if block - braces or no?
I like ruby's approach here. It offers the perl style single-line <statement> if <condition> or a multiline block style if <condition> / <do something> / end (ruby avoids braces, so here the opening brace is implied by if and the end brace is replaced by a literal end). It doesn't even offer the weird multiline-but-really-just-single-line if statement.