To class or to method  
Author Message
-





PostPosted: 2005-6-28 21:42:00 Top

java-programmer, 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.
 
-





PostPosted: 2005-6-30 20:03:00 Top

java-programmer >> To class or to method - wrote:
> 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?
 
Ingo R. Homann





PostPosted: 2005-6-30 20:27:00 Top

java-programmer >> To class or to method Hi,

>> 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.

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

 
 
-





PostPosted: 2005-7-1 7:51:00 Top

java-programmer >> To class or to method Ingo R. Homann wrote:

> 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. :-)
 
 
Ingo R. Homann





PostPosted: 2005-7-1 15:26:00 Top

java-programmer >> To class or to method 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