Author Topic: Property or argument  (Read 2415 times)

0 Members and 1 Guest are viewing this topic.

Draftek

  • Guest
Property or argument
« on: January 11, 2006, 08:53:08 AM »
Due to the wild success of my last post here is another question:

I have a com class for which I only want to expose a single function to return a bitmap from a dwg file. (same one)
I can manipulate the background color to either white or black in the process.

In your opinion, which is the best practice:

1. Use a background color property with a default setting.
2. add the background color argument to the function and force the client app to pass it with each calling.

Here is the function as it currently exists:
Code: [Select]
' The primary function of this class
' Accepts drawing file with path or http address of a drawing
' and returns the pointer to the bitmap if successful
Public Function GetDwgPreview(ByVal sFile As String, _
                              ByRef hBitmap As Long) As Boolean

Once I compile and distribute, I can't change the function ars without breaking compatibility.

Chuck Gabriel

  • Guest
Re: Property or argument
« Reply #1 on: January 11, 2006, 10:06:55 AM »
Maybe you could make it an optional argument, and default the background color if the argument isn't provided.

Troy Williams

  • Guest
Re: Property or argument
« Reply #2 on: January 11, 2006, 10:16:02 AM »
How about provide both? Provide a property and an optional value in the function. That should cover your compatibility needs.


I ran into some classes that I wrote a couple of years ago and realized that if I had provided a method as well as the option in the routine I would be able to do what I needed with out breaking compatibility or bolting things on.

Draftek

  • Guest
Re: Property or argument
« Reply #3 on: January 11, 2006, 10:21:08 AM »
oOOoo. Nice ideas.

That is exactly what I'll do. Both property and optional argument.

Thanks Chuck and Troy.