Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

VB.NET - Refactor Class per SOLID principles

Working on a project and the .NET application contained IP's all over the code.  I created a class to put them in one spot based on SOLID.  Looking at the below class can this be refactored?  Should I create an Interface then a class that inherits that Interface and a class for each IP?
Namespace Properties
    Module IPAddress

        Private _ProdIP As String = "1.2.3.4"
        Public ReadOnly Property ProdIP() As String
            Get
                Return _ProdIP
            End Get
        End Property

        Private _TestIP As String = "2.3.4.5"
        Public ReadOnly Property TestIP() As String
            Get
                Return _TestIP
            End Get
        End Property

        Private _QAIP As String = "3.4.5.6"
        Public ReadOnly Property QAIP() As String
            Get
                Return _QAIP
            End Get
        End Property

    End Module
End Namespace

Open in new window

Avatar of Arana (G.P.)
Arana (G.P.)

I dont know how many IPs you are talking about but i think you are overcomplicating it.

for ease of maintenance I would have created something like:

Public Class addreses
    Public Const ProdIP As String = "1.2.3.4"
    Public Const TestIP  As String = "2.3.4.5"
    Public Const QAIP    As String = "3.4.5.6"
End Class

or an ENUM
ASKER CERTIFIED SOLUTION
Avatar of Subrat (C++ windows/Linux)
Subrat (C++ windows/Linux)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial