Monday, October 24, 2011

5 Important Software Engineering Practices / Concepts

It's been a good semester of Software Engineering so far and I have learned a lot.  Of course there are too many important tidbits too share in one post, but here I will share 5 points that stuck out to me which will you will hopefully find interesting or useful (plus it will help me review for the upcoming midterm!).

  1. Why should you always override the hashCode method when you override that object's equals method?

    The contract of the hashCode method states that if two objects are equal according to that object's equals method, then calling the hashCode method on the two objects must return the same integer. Since modifying the equals method of the object can change the definition of what makes two object equal, the hashCode method must also be overridden to stay consistent with the new definition.

  2. What are the four properties that any implementation of the equals function should exhibit when comparing two non-null objects?

    1. Reflexivity: x.equals(x) must return true.
    2. Symmetry: x.equals(y) must return the same value as y.equals(x).
    3. Transitivity: If x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) must also return true.
    4. Consistency: x.equals(y) must return the same value over multiple calls to equals given that no information used in the comparison is changed.

  3. Which property of the property Ant tag should you use to make properties representing paths? Why?

    While the value can work, you should use the location property of the property tag because the location property will change the file separators (i.e. '/' or '\') to the one that the operating system uses while the value property will not. Hence, using the location tag allows for better portability as it will change the separators in the paths to match the operating system invoking Ant.

  4. What is the syntax do you use to access the value of a property defined in an Ant build file? For example, how would you access the value of:
    <property name="new.property" value="new />

    Surround the property name with ${ }. So ${new.property} may be used to access the value of the sample property above.

  5. What are the three general categories of test cases?

    1. Acceptance tests: The program achieves and passes some basic requirement. For example, a Robocode robot always wins against a certain sample robot.
    2. Behavioral tests: The implementation actually works as intended. For instance, the Robocode robot actually follows the strategy by moving to the specified locations through out the battle.
    3. Unit tests: Test small self-contained classes or methods in isolation. For example, testing the output of a Robocode robot's fire-control method to ensure that the output matches the expected values without actually running the battles to check the robot's behavior.

And there you have 5 of the software engineering highlights that I have seen so far. Hopefully you have picked up something new and useful and I hope to share more with you as I continue my journey through the wonderful realm of software engineering!

0 comments:

Post a Comment