Is this a suitable design for MonoState?

I have a class Person

and based on some help I got in this post.

MonoState, Singleton or Derived Forms: Best Approach for CRUD Application?

I have a class CurrentPerson

around (??) and I am accessing data through this.

I think I understand how this should work, but it seems that I am not quite right.

Questions:

  • For starters, shouldn't Person

    all of its member variables be private ?

  • Why Person

    , if declared in CurrentPerson

    , static? It is right?

  • Person

    has child objects Address

    , Enrollment

    and CaseNote

    . How do I enable them? A CurrentEnrollment

    wrapper around Enrollment

    ?

I am new to OOP as an applied science, so some of these concepts are difficult for me to introduce.

The code is long, sorry.


class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string MiddleName { get; set; }
    public string SuffixID { get; set; }
    public string TitleID { get; set; }
    public string SocialSn { get; set; }
    public string Gender { get; set; }
    public string DlNumber { get; set; }
    public string DlStateID { get; set; }
    public string PrimaryRace { get; set; }
    public string SecondaryRace { get; set; }
    public string EmailAddress { get; set; }
    public string MaritalStatus { get; set; }
    public string InsertProgram { get; set; }
    public string InsertUserID { get; set; }
    public string UpdateProgram { get; set; }
    public string UpdateUserID { get; set; }
    public string LockID { get; set; }

    public int PersonID { get; set; }
    public int ClientID { get; set; }
    public int ResidencyCountyID { get; set; }
    public int ResponsibilityCountyID { get; set; }

    public bool HispanicOriginFlag { get; set; }
    public bool CitizenFlag { get; set; }
    public bool VeteranFlag { get; set; }

    public DateTime BirthDate { get; set; }
    public DateTime DeathDate { get; set; }
    public DateTime InsertDateTime { get; set; }
    public DateTime UpdateDateTime { get; set; }



}

class CurrentPerson
{
    public static Person Person { get; set; }

    public string FirstName
    {
        get { return CurrentPerson.Person.FirstName; }
        set { CurrentPerson.Person.FirstName = value; }
    }

    public string LastName
    {
        get { return CurrentPerson.Person.LastName; }
        set { CurrentPerson.Person.LastName = value; }
    }

    public string MiddleName
    {
        get { return CurrentPerson.Person.MiddleName; }
        set { CurrentPerson.Person.MiddleName = value; }
    }

    public string SuffixID
    {
        get { return CurrentPerson.Person.SuffixID; }
        set { CurrentPerson.Person.SuffixID = value; }
    }

    public string TitleID
    {
        get { return CurrentPerson.Person.TitleID; }
        set { CurrentPerson.Person.TitleID = value; }
    }

    public string SocialSn
    {
        get { return CurrentPerson.Person.SocialSn; }
        set { CurrentPerson.Person.SocialSn = value; }
    }

    public string Gender
    {
        get { return CurrentPerson.Person.Gender; }
        set { CurrentPerson.Person.Gender = value; }
    }

    public string DlNumber
    {
        get { return CurrentPerson.Person.DlNumber; }
        set { CurrentPerson.Person.DlNumber = value; }
    }

    public string DlStateID
    {
        get { return CurrentPerson.Person.DlStateID; }
        set { CurrentPerson.Person.DlStateID = value; }
    }

    public string PrimaryRace
    {
        get { return CurrentPerson.Person.PrimaryRace; }
        set { CurrentPerson.Person.PrimaryRace = value; }
    }

    public string SecondaryRace
    {
        get { return CurrentPerson.Person.SecondaryRace; }
        set { CurrentPerson.Person.SecondaryRace = value; }
    }

    public string EmailAddress
    {
        get { return CurrentPerson.Person.EmailAddress; }
        set { CurrentPerson.Person.EmailAddress = value; }
    }

    public string MaritalStatus
    {
        get { return CurrentPerson.Person.MaritalStatus; }
        set { CurrentPerson.Person.MaritalStatus = value; }
    }

    public string InsertProgram
    {
        get { return CurrentPerson.Person.InsertProgram; }
        set { CurrentPerson.Person.InsertProgram = value; }
    }

    public string InsertUserID
    {
        get { return CurrentPerson.Person.InsertUserID; }
        set { CurrentPerson.Person.InsertUserID = value; }
    }

    public string UpdateProgram
    {
        get { return CurrentPerson.Person.UpdateProgram; }
        set { CurrentPerson.Person.UpdateProgram = value; }
    }

    public string UpdateUserID
    {
        get { return CurrentPerson.Person.UpdateUserID; }
        set { CurrentPerson.Person.UpdateUserID = value; }
    }

    public string LockID
    {
        get { return CurrentPerson.Person.LockID; }
        set { CurrentPerson.Person.LockID = value; }
    }

    public int PersonID
    {
        get { return CurrentPerson.Person.PersonID; }
        set { CurrentPerson.Person.PersonID = value; }
    }

    public int ClientID
    {
        get { return CurrentPerson.Person.ClientID; }
        set { CurrentPerson.Person.ClientID = value; }
    }

    public int ResidencyCountyID
    {
        get { return CurrentPerson.Person.ClientID; }
        set { CurrentPerson.Person.ClientID = value; }
    }

    public int ResponsibilityCountyID
    {
        get { return CurrentPerson.Person.ResponsibilityCountyID; }
        set { CurrentPerson.Person.ResponsibilityCountyID = value; }
    }

    public bool HispanicOriginFlag
    {
        get { return CurrentPerson.Person.HispanicOriginFlag; }
        set { CurrentPerson.Person.HispanicOriginFlag = value; }
    }

    public bool CitizenFlag
    {
        get { return CurrentPerson.Person.CitizenFlag; }
        set { CurrentPerson.Person.CitizenFlag = value; }
    }

    public bool VeteranFlag
    {
        get { return CurrentPerson.Person.VeteranFlag; }
        set { CurrentPerson.Person.VeteranFlag = value; }
    }

    public DateTime BirthDate
    {
        get { return CurrentPerson.Person.BirthDate; }
        set { CurrentPerson.Person.BirthDate = value; }
    }

    public DateTime DeathDate
    {
        get { return CurrentPerson.Person.DeathDate; }
        set { CurrentPerson.Person.DeathDate = value; }
    }

    public DateTime InsertDateTime
    {
        get { return CurrentPerson.Person.InsertDateTime; }
        set { CurrentPerson.Person.InsertDateTime = value; }
    }

    public DateTime UpdateDateTime
    {
        get { return CurrentPerson.Person.UpdateDateTime; }
        set { CurrentPerson.Person.UpdateDateTime = value; }
    }


}

      


PS If Daniel Brueckner possibly reads this, please don't be offended, because I am not second guessing about your answer; I just need a deeper clarification of some of the subjects in order to properly understand the use of monostat in my application.

+1


a source to share


1 answer


As for whether fields need to be private, that's the only new (C # 3.0?) Way of declaring properties that don't have underlay variables. A common option is

public string SomeProperty { get; protected set }

      

'Of course, once you want to do something like validation in the setter, it doesn't work and you need to go back to writing setters and getters and declare a fallback variable.



I'm not sure what a static method is CurrentPerson.Person()

, or how it gets set.

In the third question, if I understand correctly, you give the class Person

a type property Address

and get something like this to it:

Console.WriteLine(somePerson.HomeAddress.City);

      

+1


a source







All Articles