Name Conventions

BlitzMax Forums/BlitzMax Beginners Area/Name Conventions

H&K(Posted 2006) [#1]
Lets say I have a type "Bob"

And I want two Methods

ABob.Plus(BBob) Which adds BBob to ABob and returns the result (ABob = ABob + BBob)

ABob.Plus(BBob) Which adds BBob to ABob and set ABob with the Answer (ABob:+ BBob)

What nameing convention would people sudjest to distungush bettween the above

(I have posted a similar question before)


tonyg(Posted 2006) [#2]
Couldn't you have a function Bob.AddBobs(Bob1,Bob2) and method ABob.add(BBob)?


Tom Darby(Posted 2006) [#3]
I'd do something along the lines of what tonyg recommends. If you really want to stick to the design you lay out above, though, I'd recommend using "Sum" and "AddTo" as method names.


gman(Posted 2006) [#4]
for the Irrlicht mod i used:

.Plus() for adding and returning a new object
.PlusEq() for adding and setting the current object
.Minus()
.MinusEq()
.Div()
.DivEq()
.Mult()
.MultEq()

made sense to me :)


FlameDuck(Posted 2006) [#5]
.add() 'Adds the parameter.
.sum() 'Returns a new Bob with the sum of the two parameters
.multiply()
.product()


dmaz(Posted 2006) [#6]
I use

a:mytype
b:mytype

a.add(b) ' adds b to a

local c:mytype = new mytype.add(a,b) ' for this .add needs to return itself and needs a second param that default to null

or
local c:mytype = a.copy().add(c) ' copy returns the type.


Curtastic(Posted 2006) [#7]
I'm not sure if this is relevant but I use these two functions all the time and I'm open to suggestions. I'm just tacking Var onto the end if it edits the number.

Function KeepInInt:Int(num:Int,lo:Int,hi:Int)
	If num<lo Then 
		Return lo
	ElseIf num>hi
		Return hi
	EndIf
	Return num
EndFunction

Function KeepInIntVar:Int(num:Int Var,lo:Int,hi:Int)
	If num<lo Then 
		num=lo
	ElseIf num>hi
		num=hi
	EndIf
EndFunction