Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

WaveVector?

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 :)

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

I'd probably go with WaveProperties, really.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top