misnamed function printStackTrace() #68

Closed
vladtscripts opened this Issue Jan 30, 2014 · 6 comments

Comments

6 participants
@vladtscripts

The printStackTrace() method doesn't do what it says it does. To print a stack trace means to display it to the user. A method that merely returns a value is called a getter, not a printer. In other words, printStackTrace() acts the way a function called getStackTrace() should act. A function's name shouldn't contradict what the function does. Anyone reading the words printStackTrace() should legitimately conclude that a stack trace is being printed. Obscure identifiers are awful enough, but a policy of naming methods in a way that contradicts what the methods actually do is devastating to a programmer's understanding of code. I prefer to keep such poisons out of my projects on general principle. Though this one specific issue is minor enough to ignore this time, that doesn't make misnaming methods an acceptable policy. This is not subjective or arbitrary, there is a real, objective difference between the concepts print and get.

@WanderingZombie

This comment has been minimized.

Show comment Hide comment
@WanderingZombie

WanderingZombie Jan 30, 2014

It's always confused me too. Time to rename the function as getStackTrace() and then include a deprecated message with a printStackTrace() wrapper that calls it so existing code doesn't break.

It's always confused me too. Time to rename the function as getStackTrace() and then include a deprecated message with a printStackTrace() wrapper that calls it so existing code doesn't break.

@HNygard

This comment has been minimized.

Show comment Hide comment
@HNygard

HNygard Feb 5, 2014

+1

HNygard commented Feb 5, 2014

+1

@vjpr

This comment has been minimized.

Show comment Hide comment
@vjpr

vjpr Feb 19, 2014

+1

vjpr commented Feb 19, 2014

+1

@styfle

This comment has been minimized.

Show comment Hide comment
@styfle

styfle Mar 24, 2014

👍

I saw the first example and got confused.

var trace = printStackTrace();
alert(trace.join('\n\n')); // Output however you want!

At first I thought the trace was a string but it is probably an array due to the join call.

styfle commented Mar 24, 2014

👍

I saw the first example and got confused.

var trace = printStackTrace();
alert(trace.join('\n\n')); // Output however you want!

At first I thought the trace was a string but it is probably an array due to the join call.

@eriwen

This comment has been minimized.

Show comment Hide comment
@eriwen

eriwen Aug 16, 2014

Owner

I agree with you guys wholeheartedly. This'll be addressed in v1.0.0

Owner

eriwen commented Aug 16, 2014

I agree with you guys wholeheartedly. This'll be addressed in v1.0.0

@eriwen eriwen added this to the 1.0 milestone Sep 1, 2014

@eriwen

This comment has been minimized.

Show comment Hide comment
@eriwen

eriwen Oct 7, 2014

Owner

The new APIs will be: new StackTrace().get() and new StackTrace().fromError(). Fixed by commit 1a3adc4

Owner

eriwen commented Oct 7, 2014

The new APIs will be: new StackTrace().get() and new StackTrace().fromError(). Fixed by commit 1a3adc4

@eriwen eriwen closed this Oct 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment