Admittedly, having ACTOR and
ACTRESS as two different occupations isn't a very good design, but it will work
for now. So go on and add such an enumeration to the appropriate package of
Celebrity Collector.
Next, we need to provide a data source. It would be a good idea to create an interface
for this purpose with different methods in it that our application might require. We
could then have different implementations of this interface??”a mock one, to simplify
the initial development, and a real one, for the time when the application will go
live. With proper coding, we shall be able to easily substitute one data source for
another. Create a new package, com.packtpub.celebrities.data, and add to it the
following interface:
Simple Components
[ 84 ]
package com.packtpub.celebrities.data;
import com.packtpub.celebrities.model.Celebrity;
import java.util.List;
public interface IDataSource
{
public List
getAllCelebrities();
public Celebrity getCelebrityById(long id);
public void addCelebrity(Celebrity c);
}
Following is what a mock implementation, with an odd collection of celebrities,
could look like:
package com.packtpub.celebrities.data;
import com.packtpub.
Pages:
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120