in Core Java

Identifying Objects in a requirement

Identifying Objects is the most important task in modeling and creating types in Object oriented programming. In this post let us take a simple requirement which needs to be implemented using the Object oriented programming language.

Requirement Description:

An Employee management system has to be created for a factory. The requirements are as given below:

  • All the Employee should report at the security to log the time when the come to duty and also log the out time when the leave factory.
  • The security persons should check the register by end of day and check if any employee has not logged his time and should mark absent.
  • The accountant should calculate the number of days an employee has worked and should credit the salary to the employees bank account.
  • The employee will have an employee id, name, department, bank account number etc.,

The software should ask for an employee id, his in time and out time of a day and should give the details of number days an employee has worked.

Let us identify the Objects in this requirement. 

To identify the objects, we need to analyze which or who is acting or does some work. That is first we need to identify the actors from the requirement.

  • Employee is the first actor who should report at security.
  • Security is second actor who logs the time to the system.
  • The accountant is the third actor who calculates the salary to be paid. 

You can observe that all the actors here are actually nouns from the sentences of the requirements . 

Most of the time, the nouns form the actors from a requirement description. But do remember that not all nouns turn to be actors. The actors which have some action in the system are actors.

Now let us model the object.  We know that every object has attributes and methods as members which represent the data and behavior of the actor respectively.

identifying actors in a requirements

First let us consider the actor Employee.

  • In the requirement, it is mentioned that the employee has employee id, name, account number etc., There are the data which belongs to employee which can be stored using java data types.
  • The second thing is to identify the Employees behavior.  The Employee has to report the in time at security. Employee has to report the out time at security.
  • So, the behavior of the employee is report in time and report out time. We can use the same phrases to name the methods in the Employee as reportInTime() and reportOutTime().

The second actor is Security.

  • The security has no data given in the requirement. He just has the behavior to log the time details to the systems.
  • So, we can go ahead to add a behavior – logReportTimings().

The third actor is the accountant.

  • His behavior is to calculate the number of days worked and pay salary to employees. so, we can go ahead to create the methods calculateTotalDaysWorked() and paySalaray() as the methods in accountant.

Given below are the java classes which represent these types as object in the system.

Please note that the name of the class should represent an actor and not the work done by the actor in the system.

Srinivas Reddy

Srinivas Reddy

An IT - Specialist with loads of experience in Java, J2ee platforms and loves to share his experience on technology with You...

More Posts - Website

Follow Me:

Related Posts

Srinivas Reddy
Written By:

An IT - Specialist with loads of experience in Java, J2ee platforms and loves to share his experience on technology with You...