Faking nested methods

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edward Povazan

    #1

    Faking nested methods

    Hello,

    I have a method like the following.

    public void resetSessions() {
    // All the following are private, used to implement resetSessions()
    insertNullSessi ons();
    applyUserSessio n();
    mergeSessions() ;
    setCurrentIndex ();
    resetSingleSess ion();
    }

    I like the break things down at a high level that reads well, and then
    implement the sub methods.
    These submethods, used only by resetSessions() then pollute the rest of
    my class with unnecessary methods. So I need to parse way more
    information than necessary to see the structure of my class.

    Does anyone have any hacks to fake nested methods? Off the top of my
    head I can think of this one:

    resetSession resetSessions = new resetSessions() ;
    class resetSessions() {
    public void call() {
    resetSessions() ;
    insertNullSessi ons();
    applyUserSessio n();
    mergeSessions() ;
    setCurrentIndex ();
    resetSingleSess ion();
    }

    void insertNullSessi ons() {
    }

    void ... rest of the above methods.
    }

    And the using it somewhere in code:
    resetSessions.c all();

    Of course this approach creates many inner classes. Any other ideas?

    -Ed
Working...