Public Group

# Need a short name to replace a really really long function's name

This topic is 1425 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First of all, thanks for reading this post.

Now I just get to the point.

I've got a function named: SetPosByOrigCenter().

That means: Set Position By Original Center Point

Then I've got this: SetPosByOrigCenterOnEvent(e:Event)

public function SetPosByOrigCenterOnEvent(e:Event) {
SetPosByOrigCenter();
}

That means: Set Position By Original Center Point On Event

Yeah, their name are really long, right?

Like 18-25 characters.

So I'm just asking if you guys would mind finding a new name for these functions

##### Share on other sites

Looks ok to me, are you too lazy to type it out?

##### Share on other sites

I think long function names are generally a good thing as they are more descriptive. As long as you have some sort of autocomplete, you shouldn't have to type it all out, and most nowadays support just typing the initials (SPBOCP). If you are looking to reduce the length of the names, think about what information is implied by the function parameters and return type.

If I have a function

public List<Friend> GetListOfFriendsByID (int id)
{
//Return new list with my friends
}


I can see that it clearly returns a List and I can clearly see that I am passing in an id. I can now shorten the name to

public List<Friend> GetFriends (int id)


Clearly you are getting data.  It should really just be public List<Friend> Friends(int id);

##### Share on other sites

Keep it. It's useful for looking over code.

##### Share on other sites
Here's the explanations:

What the function SetPosByOrigCenter() does is: set the position by setting it to the x (and y) of the original center point minus half of the width (and height) of the object (the object here is a button)

public function SetPosByOrigCenter():void {
//this: the button
this.x = origCenterPoint().x - this.width / 2;
this.y = OrigCenterPoint().y - this.height / 2;
}


What the function SetPosByOrigCenterOnEvent() does:

public function SetPosByOrigCenterOnEvent(e:Event):void {
//e:Event is a must for event function in AS3
SetPosByOrigCenter();
}


The function SetPosByOrigCenterOnEvent() is called every time the button is transformed in size like these buttons in Frantic Frigates:

public function Button(...) {

...

...
}

Maybe, I just rename it ResetPosition() or let it remain unchanged

##### Share on other sites

SetPosByOrigCenterOnEvent

glDrawElementsInstancedBaseVertexBaseInstance

You function name isn't even that long compared with the gl function above. However, the point of function names is to be descriptive, irrespective of how long they are. If you come back to this code in 5 years will you be able to tell exactly what the function does without any comments? If not, rename it to something more meaningful.

1. 1
2. 2
3. 3
4. 4
5. 5

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632911
• Total Posts
3009187
• ### Who's Online (See full list)

There are no registered users currently online

×