Index: [thread] [date] [subject] [author]
  From: Garrett Mitchener <wgm2@acpub.duke.edu>
  To  : 
  Date: 02 Mar 1999 23:40:07 -0500

A scary story to tell in the dark

Last semester I posted some very long things to the news group about
scandir, including lots of questions, things to think about, etc.
I've been told it scared people, so I turned it into web pages (part
of the updated as of five minutes ago Design Hints link on the 108
help page) and will post it again in small bits.

You should have submitted a scandir library already.  However, you may
find it difficult to use as you work on the rest of the scoobi
assignment, and may decide to revise it.

Here are some of the hints available on the web page.  If you have
questions, post news and we'll talk about it.

     We already have the scandir function. Part of the point of
     this assignment is to replace it with an object-oriented
     solution to the same problem. This means that you should 1:
     Figure out exactly what problem scandir() solves, and 2:
     solve the same problem with classes and objects. If your
     solution is to have a Scandir class with one member
     function that takes two function pointers and returns a
     vector of file names, then you need to rethink your design.
     That and many things similar are most definitely NOT
     object-oriented. Why? What does it mean to be
     object-oriented? (Clearly, the answer is not just "use
     classes.")

     In particular, you should be making sensible use of 1:
     inheritance, 2: encapsulation, and 3: virtual functions. If you
     are not using all three of these, rethink your design. How can
     you tell if you are using all three of these?

     You should not need global variables of any kind. The
     scandir() function certainly doesn't.

     Continuing on that note, we can use any comparison function
     we can code with the scandir() function without having to
     touch the source code for scandir. If it is impossible or
     painfully difficult to add a new sort order to your solution to
     the scandir problem without editing your files, then you need
     to rethink your design.

     The same goes with filtering. The scandir part will be in a
     library, and will be a black box as far as other people using
     your code are concerned. Your scandir library should be at
     least as useful and flexible as the scandir() function.

     Part of the point of object-oriented programming is to avoid
     long, complicated if-else chains. How does it do this, and
     why?

     If you filter in one place, don't filter somewhere else too. If
     you sort in one place, don't sort somewhere else too.

     Don't needlessly invent special cases. You should do all your
     filtering "the same way." You should do all your sorting "the
     same way."

	-- "Stephen King" :-)


Index: [thread] [date] [subject] [author]