Avatar of CipherIS
CipherIS
Flag 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

C#Visual Basic.NET* SOLID

Avatar of undefined
Last Comment
Subrat (C++ windows/Linux)

8/22/2022 - Mon
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
Subrat (C++ windows/Linux)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck