aspose file tools
The moose likes Cattle Drive and the fly likes DataPool Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Reply Bookmark "DataPool" Watch "DataPool" New topic
Author

DataPool

Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
not sure how much information y'all can give me here, but i have a question about a nitpick.
i created a new DataPool() object in my "mystery" file for Servlets 4b... but the nitpick said:
"what instance methods are you using in your DataPool object?"
it seems obvious to me that i am using "put()" and "get()"... do i need a pool object?


what?
Michael Pearson
Ranch Hand

Joined: Mar 11, 2001
Posts: 351
It is easy to make the DataPool portion of this assignment too hard. From your post I think you may be headed in that direction.
The javadoc for DataPool shows two static methods that are very useful. You might have an epiphany.
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
i love the cryptic replies on this forum! are you talking about the 2 methods i mentioned above?
i have a weekend to spend programming, so i think i will get this one finished (for another round of nitpicking).
[ April 11, 2002: Message edited by: Greg Harris ]
Michael Pearson
Ranch Hand

Joined: Mar 11, 2001
Posts: 351
The cryptic replies are propagated by:
  • the Java Ranch community that is built on teaching not showing
  • the fear of a being reprimanded by a Sheriff or a Bartender



  • You referred to methods that provide the functionality "put" and "get". I must say I see two static methods that do that.
    I was hoping to encourage some analysis of why you are creating a new DataPool().
    [ April 11, 2002: Message edited by: Michael Pearson ]
    Michael Pearson
    Ranch Hand

    Joined: Mar 11, 2001
    Posts: 351
    I am breathing easier, refer to this thread to read Marilyn's suggestions...
    DataPool
    [ April 11, 2002: Message edited by: Michael Pearson ]
    jason adam
    Chicken Farmer ()
    Ranch Hand

    Joined: May 08, 2001
    Posts: 1932
    Do you understand what the static keyword does? Not trying to belittle, just want to make sure that first you have a good understanding of that.
    If you do have a grasp of static methods, then it should be pretty obvious from reading the class definition why you don't need an instance of DataPool. Theoretically you could make an instance, but why mess with the overhead of creating an object when one isn't necessary?
    Michael Pearson
    Ranch Hand

    Joined: Mar 11, 2001
    Posts: 351
    it must be nice to have spurs, , and not worry about saying to much
    Michael Matola
    whippersnapper
    Ranch Hand

    Joined: Mar 25, 2001
    Posts: 1721
    Not to confuse the matter, but an instance of DataPool *does* get created (in the static initialization block) whenever you first access DataPool -- but as far as I can tell its purpose is just to get a new thread running.
    Always wondered if there's any reason Paul didn't give DataPool a private (or protected) constructor.
    (Unless he did it that way to trip up Cattle Drivers who go and create their own instances of DataPool!)
    Incidentally, I think being able to access a static method through an object reference is the second ugliest thing about Java.
    Michael Pearson
    Ranch Hand

    Joined: Mar 11, 2001
    Posts: 351
    I did not want to go into DataPool's static initializer to avoid discussing Threads. Your point is correct and I appreciate the attention to detail.
    [ April 11, 2002: Message edited by: Michael Pearson ]
    jason adam
    Chicken Farmer ()
    Ranch Hand

    Joined: May 08, 2001
    Posts: 1932
    Originally posted by Michael Matola:

    Incidentally, I think being able to access a static method through an object reference is the second ugliest thing about Java.

    Agreed, and it is something I see many people who are new to the language doing. Been tutoring some people in my Java classes, and they never fail to mark all their methods static for some reason, but then go and create an object to start accessing the methods.
    And yes, it does create an object and starts a thread, which goes through and cleans up any tokens that have expired. Agreed, given the implementation of it, a private no-argument constructor would have made a lot of sense.
    Greg Harris
    Ranch Hand

    Joined: Apr 12, 2001
    Posts: 1012
    wow, thanks for all the replies! this has been very informative (it seems all the discussions between you three (and a few others) are informative).
    ( as greg slaps himslef in the forehead and thinks... now why didn't i think of that?"... )
    i have been in class the last 5 hours so i could not keep up with the discussion... so thanks for keeping it going.
    michael p.
    thanks for the link... i looked at the date and that was posted after i had looked at the DataPool code and written my first attempt. i guess i should have tried again.
    jason
    belittle me all you want... obviously i need to read up on "static" i just implemented DataPool like anything else and it worked... so i did not pay attention to what was really going on.
    michael m.
    thanks for pitching in and helping with my education... i am feeling really stupid for not thinking about what i was doing.
    [ April 11, 2002: Message edited by: Greg Harris ]
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9033
        
      10
    Originally posted by Greg Harris:
    belittle me all you want... obviously i need to read up on "static" i just implemented DataPool like anything else and it worked... so i did not pay attention to what was really going on.

    You implemented DataPool?


    JavaBeginnersFaq
    "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
    Greg Harris
    Ranch Hand

    Joined: Apr 12, 2001
    Posts: 1012
    sorry, Marilyn... bad choice of words. read "implemented" as "used." i have been out of the Navy for 4 years, but i still use the terms.
    paul wheaton
    Trailboss

    Joined: Dec 14, 1998
    Posts: 19672
        ∞

    Originally posted by Michael Matola:
    Always wondered if there's any reason Paul didn't give DataPool a private (or protected) constructor.

    That's a good idea!
    I put it into my copy just now. When Marilyn gets her computer running again, she and I need to merge some stuff ... Then the change should be available.


    permaculture forums
    Michael Pearson
    Ranch Hand

    Joined: Mar 11, 2001
    Posts: 351
    Looks like Michael M. deserves a gold star.
     
    I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: DataPool
     
    Similar Threads
    Drowning in DataPool.........
    DataPool and servlets 5
    helping Carol with DataPool
    Role of DataPool