Should this code/logic be included in Business Objects class or a separate class?

Posted by aspdotnetuser on Programmers See other posts from Programmers or by aspdotnetuser
Published on 2012-07-03T11:43:40Z Indexed on 2012/07/03 15:24 UTC
Read the original article Hit count: 212

I have created a small application which has a three tier architecture and I have business object classes to represent entities such as User, Orders, UserType etc. In these classes I have methods that are executed when the Constuctor method of, for example, User is called. These methods perform calculations and generate details that setup data for attributes that are part of each User object.

Here is the structure for the project in Visual Studio:

enter image description here

Here is some code from the business object class User.cs:

Public Class User
{
    public string Name { get; set; }
    public int RandomNumber { get; set; }
    etc

        public User
        {
            Name = GetName();
            RandomNumber = GetRandomNumber();
        }

        public string GetName()
        { 
          ....
          return name;
        }

        public int GetRandomNumber()
        {
           ...
           return randomNumber;
        }

    }

Should this logic be included in the Business Object classes or should it be included in a Utilities class of some kind? Or in the business rules?

© Programmers or respective owner

Related posts about c#

Related posts about design-patterns