Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Lines of code per method

Name: Anonymous 2006-04-29 12:01

What is your average loc/m?

For my current Ruby project, that number is now 10. The number is slowly decreasing as I refactor. One of my goals is to get it down to about 4-5 (with most methods being 1-2 lines) which I hear is the Ruby way.

I use <http://dev.rubyonrails.org/svn/rails/trunk/railties/lib/code_statistics.rb>; for counting. Rakefile task:
task :stats do
        require "util/code_statistics.rb"
        CodeStatistics.new(
                ["Code", "src"],
                ["Units", "test"],
                ["Utils", "util"]
        ).to_s
end

Name: Anonymous 2006-04-29 14:09

"Ruby way"? Sounds like what Pythonic is for Python.

Anyways, are you sane? 1-2 lines of method may sound like a good idea to somebody writing a book on OO and wanking to it, but in practice, methods this short do nothing, so you need hundreds of them to do shit, which means you create a huge, blOOated interface anybody trying to work with your shit has to read through to get going. I disagree with the trend to make so many tiny methods because it leads to interface complication and bloat. This doesn't mean I agree with huge ones either. Just use common sense.

Name: Anonymous 2006-04-29 14:30

It just goes to show that you aren't doing anything really useful.

Name: Anonymous 2006-04-29 20:39

>>2
Are you kidding? Super tiny methods are awesome! We must have methods so short it takes more lines to define them and string them all together! All hail the useless methods!

Name: Anonymous 2006-04-30 0:28

I'm working on a Java project right now, and due to the requirements for logging and exception handling, the average method is around 100 lines.  Is this considered too big?

Name: Anonymous 2006-04-30 4:02

If a method is one or two screens long, or max three levels of indentation, that's fine. It's a matter of opinion though.

Also, "Ruby way" sounds fagtastic. Everyone hates "Pythonic", so let's not bring similar stupidity to Ruby.

Name: Anonymous 2006-04-30 6:38

>>6
Two screens? Get out, tard. I hope I never have to work on any projects with you.

Name: Anonymous 2006-04-30 7:05 (sage)

>>5
If you don't have to scroll all over the damn place or keep bouncing between files (ala spring, hibernate, ibatis, just about nearly every java framework), it's all good. If you're using one of those said frameworks, now is a good time to stop abusing XML and stop wasting time producing goop. In fact, it's a good time to just stop using Java in general.

If someone tells you you're not following best practices, throw them out the window.

Name: Anonymous 2006-04-30 9:58

>>5
100 lines is too big. Just look at your methods and I'm sure you'll find that you can cut them in 3 or 4 smaller functions, it's always been like that for me.

Name: Anonymous 2006-04-30 18:37

I agree that two screens or 100 lines is too big 99% of the times. I try them to be 10 to 50 lines, with an average of 15.

>>8
Every second is a good time to stop fapping to XML and using Java.

Name: Anonymous 2006-04-30 19:35

try them to be 10 to 50 lines,

24 * 2 = 48

Uh, that is two screens, at least by the traditional definiton.

Name: Anonymous 2006-05-01 12:28

The ruby way is the way that doesn't gracefully handle errors.

Name: Anonymous 2006-05-01 12:55

>>12
NO way gracefully handles errors.

Name: Anonymous 2006-05-01 13:52

>>12
Ruby code does not generate errors because the Ruby Way is test-driven.

Name: Anonymous 2006-05-01 16:26

>>11
My screens are 32 lines tall, duh. Measuring code in "screens" is about as retarded as measuring length in feet or inches. OH SHI-

Name: Anonymous 2006-05-01 21:16 (sage)

>>15
Measuring code in "screens"
has worked fine for years.

measuring length in feet or inches
has worked fine for centuries.

Name: Anonymous 2006-05-02 20:59

Anyone who claims test driven means no errors is absolutely stupid.

Name: Anonymous 2006-05-02 22:03

>>17 Or in marketing

Name: Anonymous 2006-05-04 9:38

>>14
I really like Ruby but you have to write the tests yourself and they can't cover all the situations. Ruby code does not generate errors because it's highly-dynamic, but it's really TOO dynamic for some projects. And errors are called "duck-typing" in Ruby, that's why it crashes in your face without warning because you've misspelt something.

Name: Anonymous 2006-05-04 10:02

>>16
gb2/NASCAR

>>18
>>17 already covered this possibility

>>19
Duck-typing has nothing to do with default variable values or typos. Typos can happen in any language, and if you misspell a variable into another of the same type the same will happen even in strictly typed languages. And I don't know how's Ruby, but Python will raise an exception if you try to use a variable before setting it to something first. Perl and PHP will provide default values though.

Name: Anonymous 2006-05-04 11:25

>>20
Objects default to nil in Ruby. In most cases when I misspell a variable, I invoke a method on it, such as +, and then a NoMethodError is thrown because nil has no + method. If the nil is on the RHS, a conversion error is raised.

Name: Anonymous 2006-05-04 12:27

>>20
with Ruby, duck-typing and default values sometimes hide errors, that's why it can be dangerous

Name: Anonymous 2006-05-04 21:39

I'd like Ruby to implement something like Perl's strict mode with my().

Name: Anonymous 2006-05-05 11:49 (sage)

ruby doesn't have a strict mode?

Name: Anonymous 2006-05-06 9:33 (sage)

>>23
great idea, I was thinking something like that

Name: Anonymous 2008-06-18 17:17

computer, I

Moonspeak: watashi no konpyuta
Lojban:    le skami pe mi
also       le mi skami, without the auxiliary words

And yeah, I mean the possessives with the pe construct, the pe-less version doesn't follow the analogy.

Name: Anonymous 2010-06-07 6:39

Hi, I can spam /prog/ too, you faggot.

Also, smoke weed everyday.

Name: Anonymous 2010-12-05 20:49

+

Name: Anonymous 2010-12-05 20:50

Name: Anonymous 2010-12-05 20:51

¨

Name: Anonymous 2010-12-05 20:52

Name: Anonymous 2010-12-05 20:55

sage

Name: Anonymous 2010-12-05 20:55

sage

Name: Anonymous 2010-12-05 20:55

sage

Name: Anonymous 2010-12-05 20:55

sage

Name: Anonymous 2010-12-05 20:55

sage

Name: Anonymous 2010-12-05 20:56

sage

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:58

 

Name: Anonymous 2010-12-05 20:59

 

Name: Anonymous 2010-12-21 9:12

Name: Anonymous 2011-02-03 7:37

Name: Anonymous 2011-02-04 12:13

Name: Anonymous 2012-03-28 2:21

my farts burn my anus
it hurts
in a good way

Don't change these.
Name: Email:
Entire Thread Thread List