To class or to method

?

-

I have a class

public class CascadeAction {

...

public CascadeAction(JDesktopPane ... ) {
}

...

public void setIgnoreIconified(...) {
...
}

public void actionPerformed(ActionEvent evt) {
...
}

...
}


Instead of having a class, is the proper way to create a method :

public void cascadeFrames(JDesktopPane desktopPane, int layer, boolean
ignoreIconified) {

...
}

I don't think I should place this method in a subclass of JDesktopPane
since doing so will make it impossible for other users to use the
cascade feature if they already have their own custom JDesktopPane.

Please advice me on the proper way.
 
?

-

- said:
I have a class

public class CascadeAction {

...

public CascadeAction(JDesktopPane ... ) {
}

...

public void setIgnoreIconified(...) {
...
}

public void actionPerformed(ActionEvent evt) {
...
}

...
}


Instead of having a class, is the proper way to create a method :

public void cascadeFrames(JDesktopPane desktopPane, int layer, boolean
ignoreIconified) {

...
}

I don't think I should place this method in a subclass of JDesktopPane
since doing so will make it impossible for other users to use the
cascade feature if they already have their own custom JDesktopPane.

Please advice me on the proper way.


Anybody? Please?
 
I

Ingo R. Homann

Hi,

Why not put this method in a utility-class:

public class JDesktopPaneUtil {
public static void cascadeFrames(JDesktopPane desktopPane,
int layer, boolean ignoreIconified) { ...

Where's the problem?

Ciao,
Ingo
 
?

-

Ingo said:
Why not put this method in a utility-class:

public class JDesktopPaneUtil {
public static void cascadeFrames(JDesktopPane desktopPane,
int layer, boolean ignoreIconified) { ...

Where's the problem?

Thank you for replying.

The problem I have is deciding whether to put it in a:

1) class of itself
2) a method in
a) a general utility class
b) a specific utility class like the JDesktopPaneUtil you suggested.
c) a CascadeAction class (making the method static) as above.
d) somewhere else.

There are many ways to skin a cat but I need to know which one is better
so that the cat won't suffer. :)
 
I

Ingo R. Homann

Hi,
The problem I have is deciding whether to put it in a:

1) class of itself
2) a method in
a) a general utility class
b) a specific utility class like the JDesktopPaneUtil you suggested.
c) a CascadeAction class (making the method static) as above.
d) somewhere else.

If I understand you right, (1) and (2c) are the same (despite of
non-/static). Anyhow...
There are many ways to skin a cat but I need to know which one is better
so that the cat won't suffer. :)

....I think, the differenecs are not so great and it does depend on the
context, what's best:

2a) possible, if there are not too many utility-methods
2b) my favourite
1/2c) IMHO oversized. Why a seperate class for every method?
2d) where? perhaps something between 2a) and 2b): A class GUIUtils.

Ciao,
Ingo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top