To class or to method

Discussion in 'Java' started by -, Jun 28, 2005.

  1. -

    - Guest

    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.
    -, Jun 28, 2005
    #1
    1. Advertising

  2. -

    - Guest

    - 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?
    -, Jun 30, 2005
    #2
    1. Advertising

  3. 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
    Ingo R. Homann, Jun 30, 2005
    #3
  4. -

    - Guest

    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. :)
    -, Jul 1, 2005
    #4
  5. 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
    Ingo R. Homann, Jul 1, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,711
    Thomas Weidenfeller
    Oct 12, 2005
  2. Pawel_Iks
    Replies:
    3
    Views:
    523
    terminator
    Jul 31, 2007
  3. Replies:
    3
    Views:
    917
    Roedy Green
    Jan 28, 2008
  4. Chuck Remes
    Replies:
    3
    Views:
    172
    hemant
    Aug 12, 2010
  5. Dan Stromberg
    Replies:
    1
    Views:
    76
    Steven D'Aprano
    Jun 7, 2014
Loading...

Share This Page