![]() |
Click here to advertise with us
|
|
|||||||
| VB.NET General Discussion VB.NET general discussion area |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
That sounds reasonable. Given the situation though, does it even make sense to be able to set that property? Presumably you're calculating speed based on the last two locations and the time between them, so it really doesn't make sense for you to be setting that value from the outside. It's value should always be calculated from the inside. In that case it should be a ReadOnly property and have only a Get method.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
|||
|
For Speed, it doesn't make sense to have MetersPerSecond as the property because you could be passing KM/H or MPH, etc. Just jumping back to Heading... I am adding another function that determines your direction (north, south, east, and west) based on a degree value from 0 to 360. Would it be wrong to change the property for the Heading class from "Direction" to "Degree"? I know degree is the type but I am going to be passing the "degree" value to the direction function to determine N, S, E, or W as well.
It is just not making sense to me... Stephen |
|
||||
|
You shouldn't be naming properties after units. The property returns a value measured in those units. It doesn't return the unit. Would not Angle be a suitable name for a value that's measured in degrees?
I'd also be inclined to use a ReadOnly property to expose the N, S, E & W values and calculate them on the fly. You should also define an enumeration for the values: Code:
Public Enum Direction
North
South
East
West
End Enum
Code:
Private _angle As Double
Public Property Angle() As Double
Get
Return Me._angle
End Get
Set(ByVal value As Double)
Me._angle = value Mod 360
End Set
End Property
Public ReadOnly Property Direction() As Direction
Get
Dim value As Direction
Select Case Me.Angle
Case Is < 45
value = Direction.North
Case Is < 135
value = Direction.East
Case Is < 225
value = Direction.South
Case Is < 315
value = Direction.West
Case Else
value = Direction.North
End Select
Return value
End Get
End Property
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
||||
|
Actually, given that you're moving at a particular angle I would think Heading or Bearing would be the most appropriate property name. I know you mentioned Heading before but I'm not going to read back to find out where.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
||||
|
In that case Bearing might be the best name. Also, such a type has the look of a structure to me, rather than a class, much like Point and Size.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|