Reuse the ActiveX DLL

I l @ ve RuBoard

WE WILL NOW use this DLL in another application by walking through the analysis and design steps recommended in this book. To set the stage: You are tasked with building an application that will display the pay for an employee. The user of the application is the Manager. You must use the DLL provided by the payroll department (DLL created earlier). Start with a new, empty model.

CREATE THE USE CASE DIAGRAM

graphics/quatranirose_icon.gif
  1. Create a new model. Do not use a framework.

  2. Open the Main use case diagram by clicking the + next to the Use Case View package in the Browser to expand the package and double-clicking on the diagram called Main.

  3. Click to select the Actor icon on the toolbar and click on the diagram to place the actor.

  4. While the new actor is still selected, enter its name . . . Manager.

  5. Right-click on the actor on the use case diagram to make the shortcut menu visible.

  6. Select the Options:Stereotype Display:Icon menu choice.

  7. Click to select the Use Case icon on the toolbar and click on the diagram to place the use case.

  8. While the new use case is still selected, enter its name . . . Display Pay.

  9. Click to select the Unidirectional Association icon on the toolbar, click on the Manager actor, and drag the line to the Display Pay use case.

CREATE A REALIZATIONS USE CASE DIAGRAM

graphics/quatranirose_icon.gif
  1. Right-click on the Logical View package in the Browser to make the pop-up menu visible.

  2. Select the New:UseCaseDiagram menu choice. This will add a use case diagram called NewDiagram to the Browser.

  3. While the new diagram is still selected, enter its name . . . Realizations.

  4. Double-click on the Realizations use case diagram to open the diagram.

CREATE THE REALIZATION USE CASE

graphics/quatranirose_icon.gif
  1. Click to select the Use Case icon on the toolbar and click on the use case diagram to place the object. This will add a use case called NewUseCase to the diagram.

  2. Double-click on the use case to open the Specification.

  3. Enter the name Display Pay in the Name field. (Note: It is important that you name the use case in this manner so the namespace support in Rose is invoked. Do not name the use case using the diagram. If you do so, Rose assumes that you want the Display Pay use case from the Use Case View).

  4. Click the arrow in the Stereotype field to make the drop-down menu visible.

  5. Select use-case-realization.

  6. Click the OK button to close the Specification.

  7. You will be informed that the use case Display Pay now exists in multiple namespaces. This is okay. Click the OK button to close the Warning window.

  8. Right-click on the use case to make the shortcut menu visible.

  9. Select the Stereotype Display:Icon menu choice.

CREATE A SEQUENCE DIAGRAM

graphics/quatranirose_icon.gif
  1. Right-click on the Display Pay realization use case in the Browser to make the pop-up menu visible.

  2. Select the New:Sequence Diagram menu choice.

  3. While the new sequence diagram is still selected, enter its name . . . Display Pay for an Employee.

  4. Double-click on the new sequence diagram in the Browser to open the diagram.

ADD OBJECTS AND MESSAGES TO THE SEQUENCE DIAGRAM

  1. Click to select the Manager actor in the Browser and drag the actor onto the sequence diagram.

  2. Click to select the Object icon on the toolbar and click on the sequence diagram to place the object.

  3. While the object is still selected, enter its name . . . aPayForm.

  4. Click to select the Object Message icon on the toolbar, click on the dashed line for the actor, and drag the message to the dashed line for the aPayForm object.

  5. While the new message is still selected, enter its name . . . display pay for joe.

  6. Click to select the Object icon on the toolbar and click on the sequence diagram to place the object.

  7. While the object is still selected, enter its name . . . Joe.

  8. Click to select the Object Message icon on the toolbar, click on the dashed line for the aPayForm, and drag the message to the dashed line for the Joe object.

  9. While the new message is still selected, enter its name . . . get pay rate.

  10. Click to select the Object icon on the toolbar and click on the sequence diagram to place the object.

  11. While the object is still selected, enter its name . . . aPayClerk.

  12. Click to select the Object Message icon on the toolbar, click on the dashed line for the aPayForm, and drag the message to the dashed line for the aPayClerk object.

  13. While the new message is still selected, enter its name . . . calculate pay for this rate.

  14. Click to select the Message to Self icon on the toolbar and click on the dashed line for the aPayForm object to place the message.

  15. While the message is still selected, enter its name . . . display pay.

CREATE THE PAYROLLFORM CLASS AND THE EMPLOYEE CLASS

graphics/quatranirose_icon.gif
  1. Right-click on the Logical View package in the Browser to make the pop-up menu visible.

  2. Select the New:Class menu choice.

  3. While the new class is still selected, enter its name . . . PayrollForm.

  4. Right-click on the PayrollForm class in the Browser to make the pop-up menu visible.

  5. Select the Open Specification menu command.

  6. Click the arrow in the Stereotype field to make the drop-down menu visible.

  7. Select the Form stereotype. (Note: If you did not set the default language to Visual Basic, this stereotype will not be available. You can either delete the class, set the default language to Visual Basic and re-create the class, or wait until you assign the class to a component with the language set to Visual Basic to add the stereotype).

  8. Click the OK button to close the Specification.

  9. Click to select the PayrollForm class in the Browser and enter its documentation in the Documentation Window . . . this form displays the weekly pay for an employee.

  10. Right-click on the Logical View package in the Browser to make the pop-up menu visible.

  11. Select the New:Class menu choice.

  12. While the new class is still selected, enter its name . . . Employee.

  13. While the new class is still selected, enter its documentation in the Documentation window . . . an Employee is someone who is paid by the Company.

ADD THE DLL TO THE MODEL

graphics/quatranirose_icon.gif
  1. Click the + next to the Component View package in the Browser to expand the package.

  2. Double-click on the component diagram called Main to open the diagram.

  3. Open the Windows Explorer and find the PayrollCalculator.dll created earlier.

  4. Select the PayrollCalculator.dll and drag it onto the open component diagram.

  5. Select the Full Import menu choice.

ASSIGN THE OBJECTS IN THE SEQUENCE DIAGRAM TO CLASSES

  1. If the Display Pay for an Employee sequence diagram is not open, right-click on the sequence diagram in the Browser to make the pop-up menu visible and select the Open menu choice.

  2. Click the + next to the Logical View package in the Browser to expand the package.

  3. Click to select the PayrollForm class and drag it onto the aPayForm object. Ignore the warning.

  4. Click to select the Employee class and drag it onto the Joe object. Ignore the warning.

  5. Click the + next to the COM package in the Logical View package of the Browser to expand the package.

  6. Click the + next to the PayrollCalculator package in the Logical View package of the Browser to expand the package.

  7. Click to select the Payroll class and drag it onto the aPayClerk object. Ignore the warning.

ASSIGN MESSAGES TO OPERATIONS

graphics/quatranirose_icon.gif

Note

The messages to the form class are not operations. They will become fields on the form and we will set them in Visual Basic.


  1. Right-click on the get pay rate message and select the <new operation> menu choice. This will open the Operation Specification.

  2. Enter the name of the operation in the Name field . . . getRate.

  3. Click the arrow in the Return Class field to make the drop-down menu visible.

  4. Select Currency. (As before, if you did not set the default language to Visual Basic, Currency will not be a choice.)

  5. Click the OK button to close the Specification.

  6. Right-click on the calculate pay for this rate message to make the pop-up menu visible.

  7. Select IPayroll_calcPay.

CREATE A CLASS DIAGRAM

graphics/quatranirose_icon.gif
  1. Click the + next to the Logical View package in the Browser to expand the package.

  2. Double-click on the diagram called Main to open the diagram.

  3. Select the Query:Add Classes menu choice.

  4. By default, the package is the Logical View package.

  5. Click the All>> button to add the PayrollForm and the Employee classes to the diagram.

  6. Click the arrow in the Package field to make the drop-down menu visible.

  7. Select the PayrollCalculator package.

  8. Select the All>> button to add the classes to the diagram.

  9. Click the OK button to close the Add Classes window.

  10. Click the Unidirectional Association icon on the toolbar, click on the PayrollForm class, and drag the association line to the Employee class.

  11. Right-click on the association line near the Employee class to make the pop-up menu visible.

  12. Select the Role name menu choice and enter the role name . . . anEmployee.

  13. Right-click on the association line near the Employee class to make the pop-up menu visible.

  14. Select the Multiplicity:1 menu choice.

  15. Click the Unidirectional Association icon on the toolbar, click on the PayrollForm class, and drag the association line to the Payroll class. (stereotype = coclass).

  16. Right-click on the association line near the Payroll class to make the pop-up menu visible.

  17. Select the Role Name menu choice and enter the role name . . . myPayClerk.

  18. Right-click on the association line near the Payroll class to make the pop-up menu visible.

  19. Select the Multiplicity:1 menu choice.

USE THE MODEL ASSISTANT TO SET CODE GENERATION OPTIONS

graphics/quatranirose_icon.gif
  1. Right-click on the PayrollForm class to make the pop-up menu visible.

  2. Select the Model Assistant menu choice.

  3. Click the + next to anEmployee property to expand the tree.

  4. Select the anEmployee data member.

  5. Click to select the New checkbox.

  6. Click the + next to myPayClerk property to expand the tree.

  7. Select the myPayClerk data member.

  8. Click to select the New checkbox.

  9. Click the OK button to close the Model Assistant.

CREATE THE COMPONENT DIAGRAM

graphics/quatranirose_icon.gif
  1. Click the + next to the Component View package in the Browser to expand the package.

  2. Double-click on the diagram called Main to open the diagram.

  3. Click to select the Package icon on the toolbar and click on the diagram to place the package.

  4. While the package is still selected, enter its name . . . Manager Options.

  5. Click the + next to the COM package in the Component View of the Browser to expand the package.

  6. Click to select the PayrollCalculator package in the component view of the Browser and drag the package onto the Main component diagram.

  7. Click to select the Dependency icon on the toolbar, click on the Manager Options package, and drag the dependency line to the PayrollCalculator package.

  8. Double-click on the Manager Options package on the component diagram to open the Main component diagram for the package.

  9. Click to select the Component icon on the toolbar and click on the diagram to place the component.

  10. Double-click on the component on the diagram to open the Specification.

  11. Enter the name of the component in the Name field . . . DisplayPay.

  12. If you did not set the default language to Visual Basic, then click the arrow in the Language field to make the drop-down menu visible and select Visual Basic.

  13. Click the arrow in the stereotype field to make the drop-down menu visible.

  14. Select the Standard EXE stereotype.

  15. Click the OK button to close the Specification.

  16. Select the PayrollForm class in the Logical View package in the Browser and drag the class onto the DisplayPay component.

  17. Select the Employee class in the Logical View package in the Browser and drag the class onto the DisplayPay component.

  18. Click the + next to the PayrollCalculator package in the Component View of the Browser to expand the package.

  19. Click to select the PayrollCalculator component in the Browser and drag it onto the component diagram.

  20. Click to select the Dependency icon on the toolbar, click on the DisplayPay component, and drag the dependency line to the PayrollCalculator component.

GENERATE THE CODE

graphics/quatranirose_icon.gif
  1. Click to select the DisplayPay component.

  2. Select the Tools:VisualBasic:UpdateCode menu choice to make the Code Update tool visible.

  3. Click the Finish button.

  4. Click the Close button to close the Code Update tool.

IMPLEMENT THE CODE IN VISUAL BASIC

  1. Select the Employee class.

  2. Enter the following implementation code for the getRate method:

    getRate = 10

  3. Select the PayrollForm class.

  4. Place a Text Box on the form.

  5. Enter the following implementation code for the Form_Load method:

    Dim theRate As Integer

    theRate = anEmployee.getRate

    Text1.Text = myPayClerk.IPayroll_calcPay(theRate)

  6. Select the Project: Display Pay Properties . . . menu choice.

  7. Click the arrow in the StartUp Object field to make the drop-down menu visible.

  8. Select PayrollForm.

  9. Click the OK button to close the Properties window.

  10. Run the executable and you will see 400 displayed in the textbox.

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net