Agile Principles, Patterns, and Practices in C#
| © Jennifer M. Kohnke The time has come for our first major case study. We have studied practices and principles. We have discussed the essence of design. We have talked about testing and planning. Now we need to do some real work. In the next several chapters, we explore the design and implementation of a batch payroll system, a rudimentary specification of which follows. As part of that design and implementation, we will make use of several design patterns: COMMAND, TEMPLATE METHOD, STRATEGY, SINGLETON, NULL OBJECT, FACTORY, and FACADE. These patterns are the topic of the next several chapters. In Chapter 26, we work through the design and implementation of the payroll problem. There are several ways to read through this case study.
Indeed, there are no rules. Pick, or invent, the strategy that works best for you. Rudimentary Specification of the Payroll System
Following are some of the notes we took while conversing with our customer. (These notes are also given in Chapter 26.) This system consists of a database of the company's employees, and their associated data, such as time cards. The system must pay all employees the correct amount, on time, by the method that they specify. Also, various deductions must be taken from their pay.
Exercise
Before continuing, you might find it instructive to design the payroll system on your own, now. You might want to sketch some initial UML diagrams. Better yet, you might want to write the first few test-first use cases. Apply the principles and practices we've learned so far, and try to create a balanced and healthy design. Remember the coffee maker! If you are going to do this, take a look at the use cases that follow. Otherwise, skip them; they'll be presented again in Chapter 26. Use Case 1: Add New Employee
A new employee is added by the receipt of an AddEmp transaction. This transaction contains the employee's name, address, and assigned employee number. The transaction has three forms:
The employee record is created with its fields assigned appropriately. Alternatives: An error in the transaction structure
If the transaction structure is inappropriate, it is printed out in an error message, and no action is taken. Use Case 2: Deleting an Employee
Employees are deleted when a DelEmp TRansaction is received. The form of this transaction is as follows: DelEmp <EmpID>
When this transaction is received, the appropriate employee record is deleted. Alternative: Invalid or unknown
EmpID If the <EmpID> field is not structured correctly or does not refer to a valid employee record, the transaction is printed with an error message, and no other action is taken. Use Case 3: Post a Time Card
On receipt of a TimeCard transaction, the system will create a time card record and associate it with the appropriate employee record: TimeCard <empid> <date> <hours> Alternative 1: The selected employee is not hourly
The system will print an appropriate error message and take no further action. Alternative 2: An error in the transaction structure
The system will print an appropriate error message and take no further action. Use Case 4: Posting a Sales Receipt
On receipt of the SalesReceipt transaction, the system will create a new sales-receipt record and associate it with the appropriate commissioned employee. SalesReceipt <EmpID> <date> <amount>
Alternative 1: The selected employee is not commissioned
The system will print an appropriate error message and take no further action. Alternative 2: An error in the transaction structure
The system will print an appropriate error message and take no further action. Use Case 5: Posting a Union Service Charge
On receipt of this transaction, the system will create a service-charge record and associate it with the appropriate union member: ServiceCharge <memberID> <amount>
Alternative: Poorly formed transaction
If the transaction is not well formed or if the <memberID> does not refer to an existing union member, the transaction is printed with an appropriate error message. Use Case 6: Changing Employee Details
On receipt of this transaction, the system will alter one of the details of the appropriate employee record. This transaction has several possible variations:
Alternative: Transaction Errors
If the structure of the transaction is improper, <EmpID> does not refer to a real employee, <memberID> already refers to a member, print a suitable error, and take no further action. Use Case 7: Run the Payroll for Today
On receipt of the payday transaction, the system finds all those employees who should be paid on the specified date. The system then determines how much they are owed and pays them according to their selected payment method. An audit-trail report is printed showing the action taken for each employee: Payday <date>
|
Категории