Java programming course: 8.1 Refactoring and utility classes

In the previous lesson we created our own Exception class.


Refactoring and utility classes

Refactoring refers to the process of improving how you application is internally structured. Utility classes can be defined to provide commonly used services for multiple applications.

In this section you will learn:

  • Some basic refactoring techniques
  • How to define a utility class

Refactoring

To refactor a software system means modifying the structure or the code of your classes but without changing any of the functionality, in order to make the system better designed and easier to maintain. This is a natural part of the iterative process of development that is a recurrent theme in this course as you gradually build and improve the zoo application.

If you consider the classes ZooKeeper and Visitor you will notice that in the real world they are both types of people, and thus share certain characteristics. This is borne out just by looking at the attributes in these two classes; they each have an attribute called name together with methods setName() and getName(). Just as you placed the attributes common to different types of animals into an Animal class, so it makes sense to define a Person class along similar lines. As you will see, however, there will be some subtle differences that come to light. 


In the next lesson we will look at utility classes.

Next lesson: 8.2 Utility classes


Print
×
Stay Informed

When you subscribe, we will send you an e-mail whenever there are new updates on the site.

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Monday, 27 October 2025

Captcha Image