Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

All client classes should be package private

 
Mogens Nidding
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or should they? Any comments will be greatly appreciated.

Looking at my own client classes I would say most of them should not be public, since I seriously doubt that Bodgitt and Scarper, their affiliates or anyone else would ever want to use anything but the most central couple of classes.

These are the candidates for public access I can identify:

  • Starter (because it holds the main method). What's a good name for such a class anyway?
  • RecordTableModel (a Swing TableModel backed by a collection of database records, since it is, at least in theory, reusable)
  • Contractor, ContractorTableModel and ContractorTablePanel. These all deal with database records representing contractors and are also, in theory, reusable.


  • Any comments on what to make public are very welcome. I am thinking of choosing "Starter" alone.
     
    mike acre
    Ranch Hand
    Posts: 197
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I wanted to make a few of my classes package private, but decided against it. All my top level classes/interfaces were public because of the must requirement: 'You must provide Javadocs for all classes'. Since it is usual to provide only public/protected Javadocs this swung it for me.

    Starter : Runner is customary
     
    Mogens Nidding
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the advice, Mike! I guess the requirement you mention either forces us to make all classes public, or to generate package-level javadoc.
    If there is no other reason to make the classes in the client package public than javadoc inclusion, then I'm going with the package-level javadoc, though, since I think it's the lesser of the two evils.

    By the way, the requirement also seems to force us generate javadoc inner classes, which are often private. This surely can't be the intention?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic