Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > To class or to method

Reply
Thread Tools

To class or to method

 
 
-
Guest
Posts: n/a
 
      06-28-2005
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.
 
Reply With Quote
 
 
 
 
-
Guest
Posts: n/a
 
      06-30-2005
- 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?
 
Reply With Quote
 
 
 
 
Ingo R. Homann
Guest
Posts: n/a
 
      06-30-2005
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

 
Reply With Quote
 
-
Guest
Posts: n/a
 
      06-30-2005
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.
 
Reply With Quote
 
Ingo R. Homann
Guest
Posts: n/a
 
      07-01-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
injecting an instance method into another class' class method Chuck Remes Ruby 3 08-12-2010 07:15 PM
why a class can't access protected method from another class in thesame package,the method is interited from the ohtner class from differntpackage? junzhang1983@gmail.com Java 3 01-28-2008 02:09 AM
how to call method of the class which contains a pointer to other class method? Pawel_Iks C++ 3 07-31-2007 06:30 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Unit testing - one test class/method, or test class/class Edvard Majakari Python 4 02-25-2005 07:31 PM



Advertisments