Hacker News new | past | comments | ask | show | jobs | submit login

Great idea / initiative but I must ask, are you new to Ruby? I've rarely come across code that was so not idiomatic.



Thanks, yes, I'm ashamed of my code, this is my first project in ruby , my last programming work was 15 years ago, (Foxpro for DOS) so this is my comeback to programming.

I hope that being opensource will help it to improve.


No sweat, man. You are new to the language and you're putting yourself out there. Major kudos for that.

Now, for some low hanging fruits / pointers:

- $name is a global variable. Virtually unused in idiomatic Ruby.

- @name is an instance variable. So it's perfectly ok to use it... within a class.

- You should omit the 'then' after each if.

- I'd use find_words rather than busca_palabras.

- Except for rare edge cases, you can drop the .nil? from if my_var.nil?. If my_var is nil it will on its own make the condition false.

- I would use more spaces. 'a = 1' instead of 'a=1', 'b == 0' rather than 'b==0'.

- Use indentation consistently. 2 spaces.

- The else clause is indented at the same level as the leading if.

- Use && instead of 'and' in conditionals. Likewise || instead of 'or'. These short circuit the evaluation for you. So if the first argument is false && won't bother evaluating the second argument. Likewise, if the first argument is true || won't bother executing the second argument as it doesn't matter.

- Ruby is an Object-Oriented programming language. I would look into modules and classes to restructure the code in a less procedural way.


Thank you very much acangiano, I will review all the code with your guidelines at hand!.


I applaud you for putting it out there! Fear of negative feedback often keeps me from releasing code in situations like this.


At first I thought you might be being overly critical as can sometimes be the case here, but glad I checked the code. Your comment is spot-on.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: