I am attempting to encapsulate several features about a user in a single class. Although the main use for this class would be to initialize it once and never have to call set any variables again, I would like this class to be scalable to be called many times. Although by putting this into a class I feel like I am either over-complicating it or breaking OOP standards.
At the moment I am currently using these current sorts of calls throughout VBA code:
username = GetUsername()
IF userHasSecurity(GetUsername(), "WhatUserHasAccessTo") = true THEN
What I am hoping to do it replace it (respectively) with:
Set UserID = New Username UserID.GetUserName
IF UserID.HasModuleAccess("WhatUserHasAccessTo") = true THEN
In addition to this change, I have a function that returns
Active Directory information and also verify if usernames input exist in
The Class Diagram is as such
Private UserName As String Private FirstName As String Private MiddleInitial As String Private LastName As String Private Sub class_Initialize() Private Function findCurrentUsername() As String Private Function doesUsernameExist(usernameToCheck As String) As Boolean Public Property Get GetUserName() As String Public Property Let setUsername(newUsername As String) Public Property Get getFirstName() As String Private Property Let setFirstName(newFirstName As String) Public Property Get getLastName() As String Private Property Let setLastName(newLastName As String) Public Property Get getMiddleInitial() As String Private Property Let setMiddleInitial(newMiddleInitial As String) Private Function findNameDetails() Public Property Get getFullName() As String Public Function HasModuleAccess(moduleName As String, Optional appName As String) As Boolean Public Function getUserActiveDirectoryGroups() As DAO.Recordset
Is this more an opinion based execution(standalone functions vs. class) thing or is there something to gain? Does this break OOP standards and am I using classes incorrectly?