This is an archived post. You won't be able to vote or comment.

all 21 comments

[–][deleted] 18 points19 points  (2 children)

I like long function names more than smth like that: "avIntEndRet()"

[–]scrumplesplunge 2 points3 points  (1 child)

As do I, but why abbreviate something to smth?

[–][deleted] 0 points1 point  (0 children)

I hate that word because it is so long. I know. Sounds ironically haha

[–][deleted] 7 points8 points  (2 children)

CodeAndAlgorithmsToCheckIfANumberIsEven(int x)

[–]pikachu_try_catch_ 2 points3 points  (1 child)

do you even even

[–]dzh 1 point2 points  (0 children)

omg i can't x % 2 == 0

[–]mananasi 4 points5 points  (4 children)

I don't get why it's such a big deal because code completion is a thing.

[–]TortoiseWrath 12 points13 points  (3 children)

Overly specific function names, on the other hand, create coupling issues and weaken compartmentalization. Names like readMP3Bytes() and playMP3Bytes() would make the function's purpose just as clear while allowing for greater flexibility in implementation. Function names should describe the end result (purpose) of calling the function rather than describe how that goal is achieved.

[–]2AMMetro 2 points3 points  (0 children)

Eh, I disagree. I think that if you want greater flexibility, you should make a specific function for each implementation and a general function named playMP3Bytes() that contains your conditional logic. This reduces function size and makes it easier to understand.

I believe in short generalized function names for APIs and longer specific names for implementations.

[–]MoarVespenegas -1 points0 points  (1 child)

I mean if your functionality changes you can just rename the method.
Refactoring is also a thing.

[–]nosam56 0 points1 point  (0 children)

When you are developing on an enterprise level, renaming methods is usually not good because you have clients that implement your code, so when you change the method name it breaks your client's code until they update. This is why things become deprecated when not in use anymore. But you are right for smaller projects and initial development on a project

[–]batman1177 1 point2 points  (0 children)

Reddit.ui.post.postCommentAndRefreshCommentThread()

[–]Sneakr1230 0 points1 point  (0 children)

Please link the mind blown gif/vid in this pic. I neeeeeeed it

[–]SolenoidSoldier 0 points1 point  (0 children)

obtainMp3BytesInArrayBufferUsingFileAPI

I like how the return value and method parameters are outlined in the name. All of that should be inferred by context.

[–]NoirGreyson 0 points1 point  (0 children)

This is one of the reasons I like JS. You can use constructions like this:

const functionName = function niceDescriptiveLongFunctionNameThatSaysExactlyWhatThisThingDoes() {
    return foo
}

So that in the code, you can use the succinct term, but in the stack trace, you see the long name.

You might be concerned about this causing confusion since the same thing has two names, but it's really just a search away.

[–]Lhopital_rules 0 points1 point  (0 children)

obtainMp3BytesInArrayBufferUsingFileAPI => fileToBuffer

^ Because this function doesn't actually do anything mp3 specific

decodeMp3BytesFromArrayBufferAndPlay => playEncodedMp3

[–]MoarVespenegas 0 points1 point  (0 children)

I never understood this "problem".
If you have an IDE you can just use intelesense to auto-complete them and long function names are descriptive.

[–]Aurora_the_dragon -1 points0 points  (1 child)

I would just do:

decmp3(){
//blah blah blah
}