Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3353572
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:10:03+00:00 2026-05-18T02:10:03+00:00

I am learning some good code practice that’s why i was going through some

  • 0

I am learning some good code practice that’s why i was going through some code, some thing i could not understand in it. It has made property in a separate class for each entity like in userClass it has property

  #region public properties

    private int uid;
    public int userId
    {
        get { return uid; }
        set { uid = value; }
    }

    private string uName;
    public string userName
    {
        get { return uName; }
        set { uName = value; }
    }

    private string pwd;
    public string password
    {
        get { return pwd; }
    //    set { pwd = value; }
    }


    private string uAddress;
    public string userAddress
    { 
        get { return uAddress; }
        set { uAddress = value; }
    }


    private string fName;
    public string firstName
    {
        get { return fName; }
        set { fName = value; }
    }

    private string lName;
    public string lastName
    {
        get { return lName; }
        set { lName = value; }
    }

    private string uPhone;
    public string userPhone
    {
        get { return uPhone; }
        set { uPhone = value; }
    }

    private string uMobile;
    public string userMobile
    {
        get { return uMobile; }
        set { uMobile = value; }
    }

    private int secretQuestion;
    public int securityQuestion
    {
        get { return secretQuestion; }
        set { secretQuestion = value; }
    }

    private string userAnswer;
    public string answer
    {
        get { return userAnswer; }
        set { userAnswer = value; }
    }

    #endregion

and from the business logic class it uses the property instead of using directly any entity’s attribute name, but i am confuse whats there need to make a property like this?

other then this it has got enums for database column name which has a clear reason behind this that if in near future we have to change the database table’s fields name then we don’t have to change through out the whole business logic class and we can make changes to enum directly, But what is there use of creating property like this please elaborate me on this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:10:03+00:00Added an answer on May 18, 2026 at 2:10 am

    Are you really asking why it uses properties instead of having public fields?

    Fields are an implementation detail – they’re how data is stored, which shouldn’t be something the outside world cares about, at least for 99% of types. Properties are part of the contract that a type has in terms of its API – the implementation is up to the type. In other words, it’s a matter of encapsulation. Properties can be expressed in interfaces, as abstract methods etc, precisely because they keep the contract and the implementation separate.

    Additionally, properties make databinding, debugging and various other things simpler. I have an article about why properties matter, which you may find useful.

    Having said all of this, those properties are implemented in a tedious way – and they don’t obey .NET naming conventions. I would have written them as:

    public int UserId { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
    // etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening everyone! I am working on learning some java and I have made
I am just learning the Entity Framework and have made some good progress on
I'm learning C++, trying to write good, polymorphic code, and running in to some
I'm looking for some good references for learning how to model 2d physics in
I'm after some good tips for fluent interfaces in C#. I'm just learning about
Looking at learning some C since i saw in another SO question that is
I have been learning C++ with some books from school that are from the
I'm in the process of learning Interfaces. I've been reading through some books/articles and
I am looking to develop some code that will be able to by looking
There is a section of code from a learning resource that I am studying.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.