1

there are many text about Boundary , Entity , Control class and ICONIX process and Robustness Diagrams.but there is no code samples in real , how can we implement control classes in code ? here is my code sample , i want to detect that where is the control class in this code ?

classes :

Program_Boundary : Boundary Class

Person : Entity

People : Entity ( because it has CRUD operations )

Where is Control class ? Is there a control class for this example :

class Program_Boundary // BoundaryClass
{
    static void Main(string[] args)
    {
        People people = new People();
        Person person;
        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine("Enter name:");
            string name = Console.ReadLine();
            Console.WriteLine("Enter family:");
            string family = Console.ReadLine();
            person = new Person(name, family);
            people.Add(person);
        }
    }
}
class People //Entity Class
{
    List<Person> person_list = new List<Person>();
    public People()
    {

    }
    public void Add(Person person)
    {
        person_list.Add(person);
    }
    public void Delete(string name, string family)
    {
        for (int i = 0; i < person_list.Count; i++)
            if (person_list[i].name == name && person_list[i].family == family)
                person_list.Remove(person_list[i]);
    }
    public void Update(string name, string family, string new_name, string new_family)
    {
        for (int i = 0; i < person_list.Count; i++)
            if (person_list[i].name == name && person_list[i].family == family)
            {
                person_list[i].name = new_name;
                person_list[i].family = new_family;
            }
    }
}
class Person //Entity Class
{
    private string _name;
    private string _family;

    public Person(string n,string f)
    {
        _name = n;
        _family = f;
    }
    public string name { get { return _name; } set { _name = value; } }
    public string family { get { return _family; } set { _family = value; } }
}
Community
  • 1
  • 1
sap
  • 87
  • 1
  • 11

1 Answers1

0

There is no control class in your snippet. Control class would be a class responsible for performing a set of operations corresponding to a given usecase. For example, you could have a usecase of updating person details. It can, for example, involve these operations:

  1. find the person.
  2. get the new data.
  3. update the person record.

You can create a control object, let's call it UpdateController, which will execute these 3 operations by addressing the relevant entities and boundary classes to get the job done. The controller itself doesn't perform the actual operations, but rather delegates them to the relevant modules. Controller is the one that invokes and synchronizes the required operations.

Also, see here: In UML class diagrams, what are Boundary Classes, Control Classes, and Entity Classes?

Community
  • 1
  • 1
SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85