Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 07-08-2009, 12:13 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

Good point... This is confusing.

So since I am dealing with GPS data, should I name the class GPS and the property Speed?

Stephen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 07-08-2009, 12:27 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,102
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 07-08-2009, 12:30 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

This value actually gets passed in by the GPS device so I do want to do some basic validation on it.

Thanks for all of your help!

Stephen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 07-08-2009, 1:08 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 07-08-2009, 1:18 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,102
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 07-08-2009, 1:30 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

Okay, I think I got it now.

Stephen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 07-08-2009, 1:32 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,102
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 07-08-2009, 1:33 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 27
Reputation: 11
subaru_sti is on a distinguished programming path ahead
Default

I am using Heading as the class name.

Stephen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 07-08-2009, 2:22 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,102
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 3:37 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.