Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Guidance Needed in VB: When NOT to use public functions

  1. #11
    Variable Bitrate
    Join Date
    Nov 2007
    Posts
    262
    Even for solo projects, there are two people to consider:
    1) You, today, churning away on the code in question,
    2) You, next year, going back to the same code for the first time in many months (for a bug fix, new feature, performance improvement, whatever).

    Generally speaking, a class should have a single clear purpose, which is captured by the class name. The operations that the user of the class (you, today & you, next year) needs to understand to meet that purpose, should be public. Anything else the class does, should be private.

    One of the key things about private functions and private member variables is that you can revise them all you want without breaking the code that uses the class (unless you introduce bugs, of course). It's only when you change the public members (or the behavior, of coures) that you have to revise the rest of the project.

    As other said, stuff should be public if something else needs it. Otherwise, leave it private. That's a note to you-next-year that you're free to revise this without worrying too much about side-effects in other areas. It's also a note to you-next-month that the member in question isn't important if all you want to do is USE the class. It's stuff you can forget about when you're focused on other parts of the project and just want to use the class for whatever purpose it was designed for.

  2. #12
    Newbie
    Join Date
    Jun 2008
    Posts
    44
    Quote Originally Posted by colin View Post
    Or the not-so-insane instance that there are two forms with a Button1 on them and the event Button1Click is public somewhere...
    Or that Button1Click calls Play() on the video page which actually calls the public function on the music page instead...

    Just quick examples I could see off the bat. For the record, I use all public functions and name them accordingly. IE: musicPlay, videoPlay, albumPlay, etc... Mostly because each one has different parameters but... you get the idea.
    I was talking about if you had a private method and then made it public. I think you misread as vice versa, which you are 100% right on.

  3. #13
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    53
    wow.. its amazing that just a year ago when i started this thread i knew NOTHING about VB lol. Now i've got 5 or 6 active plugins with more to come!
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Help needed from VB expert !
    By CdRsKuLL in forum Software & Software Development
    Replies: 4
    Last Post: 12-27-2004, 03:28 PM
  2. VB & Winamp Help Needed
    By ST34LTH in forum Software & Software Development
    Replies: 7
    Last Post: 07-21-2004, 10:13 PM
  3. VB help needed - DVDplayer- Brushed metal
    By Custommx3 in forum MediaCar
    Replies: 2
    Last Post: 06-11-2004, 01:03 AM
  4. BASIC Stamp question
    By Banderon in forum General Hardware Discussion
    Replies: 18
    Last Post: 05-07-2004, 08:33 AM
  5. Programming help needed (DirectShow & VB)
    By All4Norway in forum Software & Software Development
    Replies: 0
    Last Post: 01-06-2003, 05:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •