Tina Comston
Comp-111 Week 11
Franklin University
Week 11
Preparation
  • Read Chapter 8 (sections 8.1 - 8.3) in the COMP 111 Reading Guide.
Guided Learning Activity
Assignment - no homework assignment this week

Class Types
Up to this point in the course, we have been dealing with domain classes.  These are the user-defined data type we have been writing for the homework assignments and labs.  In addition to domain classes, there are also actors, utility, and library classes.

Domain Class - typically thought of as a noun, for example employee or time card.  Each class represents a single concept.

Actor Class - models a verb or action, usually a process.  These types of classes do things to or for the domain class, but don't have any instance variables unique for each object.  For example FederalTaxCalculator.  Typically these classes have names that end in er or or.

Utility Class - provide reusable services for both domain and actor classes. For example the Math class.

Library Class - groups of reusable components that are used to assemble a program.  For example the ArrayList or Scanner classes.
 
Cohesion & Coupling
Cohesion - the degree to which a class models a single concept.

For example student class - it might contain a name, date of birth, address, gpa, and so on.    This would be an example of low cohesion - there are too many concepts in this class.

Instead, the date of birth could be broken out to be a date object, where the date object has all of the methods associated with the date itself, such as calculating the age.

The address could be broken out to be an address object and then could be used for primary address, campus address, emergency contact address, etc.  This could then contain methods to format the address with city, st zip format, verify the state is a correct abbreviation, etc.

The gpa could be broken out to be a gpa object which would contain methods related to this component.

With all of these items become their own classes and representing a single concept, we now have high-cohesion, which is the goal.

Coupling - how much a class depends on other classes to work properly.  The more a class depends upon another class, the more challenging it is to develop, test, and maintain the class.  Low coupling is the goal.

YouTube video on coupling and cohesion
https://www.youtube.com/watch?v=ZND1JAJIofA

Another video on coupling and cohesion with a couple of great examples
https://www.youtube.com/watch?v=Ujq_xsd-9MQ

Pre-Condition and Post-Condition
Pre-Condition - any requirement that must be met for a method to function correctly.  For example, a valid date or valid number.

Post-Condition - the value that is returned by the method or the final state of the object and it's instance variables.  We have been testing post-conditions with our junit test cases.

Exam 2
  • I recommend that you call your proctor a couple of days prior to when you plan on taking the test and verify that the test has been received and that the proctor/office is open.  You will need to allow a minimum of 2-3 hours for taking the test.  It must be taken all at one time.  You cannot take half  at one time, take a break, and then take the rest.
Reflection Paper
  • Keep journaling.
Lab 4
  • Although you have a couple of weeks to complete this lab, it's never a good idea to wait until the last minute.  Read through the instructions. Make sure you have a clear understanding of what is needed.