Class Stubs

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

BankAccount.java
public class BankAccount {
   public BankAccount() {}
   public void deposit(int amount) {}
   public void withdraw(int amount) {}
   public int getBalance() { return 0; }
   public String toString() { return ""; }
}

*Designing classes belongs to the most challenging arts in software development.
 
*To get a feeling for a design candidate it might be helpful to write a class stub first. This is a class which is stripped from its implementation but can be still compiled.
 
*This is achieved by shorten all method bodies to {} or to { return ...; }.
 
*Instance variables and private methods can be postponed. At this stage, only the public accessible part of a class is of interest.
 
*While its compilation result is not useful, it might be helpful to see possible error messages by the compiler early.
 
*It is also possible now to attempt to compile other classes that use this class.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002