naming functions

BlitzMax Forums/BlitzMax Programming/naming functions

Chris C(Posted 2006) [#1]
because of commands like setScale in max its better to avoid using even methods called setScale, I've ended up comming up with a long winded method, can anyone suggest a better way (bare in mind some people winge about abreviations!)

a method changing a value is named Set<object type><value name>
a method retrieving a value is named Get<object type><value name>

functional methods that change one or more values indirectly like RollEntity are named <functional name><object type>
(rollEntity on TS_PARENT space could change local roll pitch and yaw for instance)

Type Tentity
Function CreateEntity:Tentity(Name:String,Mesh:String)

Method SetEntityParent(p:Tentity)
Method SetEntityPosition(x:Float,y:Float,z:Float) 'absolute world position
Method SetEntityScale(x:Float,y:Float,z:Float)
Method SetEntityMaterial(m:String)

Method RollEntity(angle:Float,space:Int=TS_LOCAL) 'Add angle relative to an axis type
Method PitchEntity(angle:Float,space:Int=TS_LOCAL) 'TS_LOCAL, TS_PARENT or TS_WORLD
Method YawEntity(angle:Float,space:Int=TS_LOCAL)

Method GetEntityName:String()

Method SetEntityFragParam(param:String,v1:Float,v2:Float=0,v3:Float=0,v4:Float=0)
Method SetEntityVertParam(param:String,v1:Float,v2:Float=0,v3:Float=0,v4:Float=0)


Dreamora(Posted 2006) [#2]
I have no problem using the functions on my types.

As BM is scope, you can within those methods just call BRL.MAX2D.SetScale ...
I don't see why I should make the naming more complex if it is not needed ...
Most likely its SetScaleVector / SetScaleComponent anyway (to make it possible input a float array or each value on its own)


Yan(Posted 2006) [#3]
I think that may lead to confusion. Why not stick to SetBlah and GetBlah?

If not, I'd be tempted to simplify things even further and just have BlahEntity() to set and EntityBlah() to recover:

myEntity.PositionEntity(x:Float, y:Float, z:Float)
myEntity.EntityPosition(x:Float Var, y:Float Var, z:Float Var)

??


Chris C(Posted 2006) [#4]
SetScaleVector(v:Tvector)
SetScaleX(v:float)
SetScaleY(v:float)
SetScaleZ(v:float)

instead of
SetEntityScale(x:Float,y:Float,z:Float)

is that what you mean?

BRL.MAX2D.SetScale - pretty it aint!
and it messes the highlighting up in the method declaration too...


Dreamora(Posted 2006) [#5]
I mean:
Type entity
  field _scale:float[2]

  method SetScale(x:float, y:float)
    _scale[0] = x
    _scale[1] = y
  end method

  method draw()
    brl.max2d.setscale _scale[0],_scale[1]
    ' do the rest
  end method
end type


Things like that is what I meant.


Beaker(Posted 2006) [#6]
I don't understand why you are using the word "Entity" in your Tentity method names. Seems like overkill to me. Just a thought.


Chris C(Posted 2006) [#7]
it was really because I'm not keen of using SetScale...


N(Posted 2006) [#8]
Use SetScale.


Chris C(Posted 2006) [#9]
yeah, I guess so...


H&K(Posted 2006) [#10]
Bump.

Chris, I see what you mean, but if you have strong nameing of the instances then the methods dont need the "Entity" bit
ie
AName.SetEntityScale(x:Float,y:Float,z:Float)
AnEntity.SetScale(x:Float,y:Float,z:Float)