Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
CoWeb Assignment 2.
- Refactoring is the process whereby the developer is changing the internal structure of code in order to make it easier to maintain, reduces duplicate/redundant code, and increases readability by other humans (prevents software entropy). It does not effect the observable outcome of software.
- Examples of code needing refactoring
- Variable names are unrelated to their functions. (ex. i, aNumber, aStr).
- methods that have a high complexity value or are of very long length.
- duplicate code.
- Unit testing provides a means of making sure that during the refactoring process, the developer doesnt break methods by changing the code. The developer can run the unit tests after changes are made to make sure that the methods still have the same functionality as they did before the changes.
- All instance variables in squeak are private variables to that object. If the programmer wanted another function to have access to those instance variables, they could create a method that would retrieve the value of the variable and then return it as a message to the calling object. They could also create a method that allows another object to change or set the value of an instance variable.
- All instance methods in squeak are public. If a method is created for a class, then there is no way to restrict access to that method, meaning any object can call any of the methods in another objet
- Some advantages to the squeak model over the java model:
- In java, instances respond to class methods whereas in smalltalk, the class responds to messages with class methods and instances respond to a messages with instance methods. This advantage of squeak over java provides a better object-oriented programming style. A class and its instances are not the same object and thus should be seperated and use different methods.
- Having all methods of a class public can lead to errors. In the case that a method is really meant to be private, and another object trys to access that method. Eventhough this characteristic of squeak can cause errors, squeak handles errors very well.