# How do you do this the right way?

So I’m working with Java at work now. A little applet that has several tabbed panes of similar “View” objects.

The code I’m modeling it off of has several If/Then/Else blocks wrapping cut-n-pasted code which is slightly altered for each class. I want to replace this with something much more intelligent and generic. Something like this:

private void loadGenericView (String objClass, String label) {
String msg;
try {
Class c = Class.forName(objClass);
DataView view = (DataView) c.newInstance();