views:

111

answers:

5

I have a structure named WaveSize to represent both an amount of samples or an amount of time, but I'm also using this structure to represent a position or an offset within a wave.

While it's pretty common to represent both sizes and positions within a coordinate system with a Vector2d type, I'm unable to find a good name abstract enough to represent wave lengths and wave positions/offsets.

I find odd to see something like:

public WaveSize Size { get; }
public WaveSize Offset { get; }

I'd rather come up with a good name than creating empty classes or using 'using'.

Any suggestions will be much appreciated. Thanks in advance.

EDIT: As Reed Copsey & Marc Gravel suggested it makes a lot of sense to have two different classes since they are two different concepts, so, any similarities in code should be seen as mere coincidences.

A: 

Could you have a struct called simply Wave and then size and offset would fit snugly into the more general name? I hope you dont have a Wave struct already :)

willcodejavaforfood
+1  A: 

WaveVector?

Chris Doggett
In terms of physics, a force vector indicates the magnitute (size) and direction (position) of the force.
Joel Coehoorn
A: 

Isn't the usual name for the 'offset' the phase shift?

I'd probably go with WaveProperties, really.

chaos
+3  A: 

You could compare to the winforms Point and Size structures... they decided that even if they are similar, to keep them separate. It makes sense at the algebraic sense:

Point - Point = Size
Point + Size = Point
Size + Size = Size
Point + Piont = ???? error (no defined operator)

etc

Marc Gravell
I'm really tempted to do this, but having to duplicate every method hurts a little...
Trap
+3  A: 

I would have two separate structs, and make conversions easy between them.

You're trying to represent two concepts here, one for position, and one for size. Since these are two conceptually distinct ideas, I'd make them two structs.

I also agree with Marc Gravell's answer regarding the BCL's Point/Size structs. I think they're a good model to follow.

Reed Copsey
I agree with you in that these are two different concepts and should be treated accordingly.
Trap