Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

suitable name for function/method [closed]

Tags:

java

c#

oop

I have class with method that inside of it i take complex object and from it I create new object with simple structure user can work with it in more convenient way .I store this object instance in the memory and and provide simple api to it. I give it name Serializable but I'm not sure that this is the right name.

like image 917
Olaf Bergin Avatar asked Sep 03 '26 18:09

Olaf Bergin


2 Answers

  • Transform
  • TransformToX (where X is the name of the resulting object)
  • ToX (you see that a lot, for instance, ToString, ToInt32)
like image 151
T.J. Crowder Avatar answered Sep 05 '26 07:09

T.J. Crowder


I name methods like that using names like asThing(). I suppose in C# it should be AsThing(). Another choice might be to follow the example of Java's Number class: Number.intValue(), etc.

like image 22
Ted Hopp Avatar answered Sep 05 '26 07:09

Ted Hopp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!