We help IT Professionals succeed at work.

Multiple Services and Class library

JRockFL
JRockFL asked
on
I am creating two independent services, but both need to use some of the same classes I created.
For example, the File Class below.
Should I have a copy of the class in each project, or should I be moving this to a seperate class library?
Option Strict On
Option Explicit On
 
Public Class File
 
    Private _name As String
    Private _lastAction As FileActions = FileActions.Unknown
    Private _guid As Guid
    Private _created As Date
 
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property
 
    Public Property LastAction() As FileActions
        Get
            Return _lastAction
        End Get
        Set(ByVal value As FileActions)
            _lastAction = value
        End Set
    End Property
 
    Public ReadOnly Property Extension() As String
        Get
            Return _name.Substring(_name.LastIndexOf("."), 4)
        End Get
    End Property
 
    Public ReadOnly Property Guid() As Guid
        Get
            Return _guid
        End Get
    End Property
 
    Public ReadOnly Property Created() As Date
        Get
            Return _created
        End Get
    End Property
 
    Public Sub New()
        _guid = Guid.NewGuid()
        _created = Date.Now
    End Sub
 
End Class

Open in new window

Comment
Watch Question

Software Architect
CERTIFIED EXPERT
Top Expert 2008
Commented:
will be better to put into a class library, because if you detect a bug in your shared class or want to enhance it, you will have to go to every project and update it.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.