Suppose I have system with a User class, meant to represent one row in a database table of users of the system. There will be queries for the administrator's screen reading a list of all users, in order to change a user's permissions, activate/deactivate users, etc.
Then, suppose I want a class, used by the UI, to represent the current Windows user logged in to the system (this is a WinForms system). The only difference between this "current user" class and the "User" class above is that the User class will have a standard get/set property for LoginID (because LoginID is being read from the database when fetching the whole table of users), but the "current user" class will have a ReadOnly property for (the Windows) LoginID, being set in the constructor like this:
Public Sub New() LoginID = My.User.CurrentPrincipal.Identity.Name End Sub
All other properties such as FirstName, LastName, Email, IsActive, IsAdmin, etc. will be the same between these two classes.
I'm running into issues where I can override the LoginID property of User, but can't change the scope to ReadOnly. I ultimately want the current user class to protect the LoginID property and have it only set via
Should these be two different classes from an OO perspective? Could I somehow have a CurrentUser class inheriting from the User class and handle the ReadOnly scope in the derived class? Could the design be one class?