Creating DLL library

IfYouSaySo

Well-known member
Joined
Jan 4, 2006
Messages
102
Location
Hermosa Beach, CA
Programming Experience
3-5
Ok, my question is not so much how to create the library, but how do you hide the implmentation details from clients? For example, lets say you have:

VB.NET:
Namespace MyCodeLibrary
    Class A
        Public Sub DoSomething()
            Dim x As New B
 
            x.DoSomethingImplementation()
        End Sub
    End Class
 
    Class B
        Public Sub DoSomethingImplementation()
            ' Do whatever here
        End Sub
    End Class
End Namespace

And now lets say that you expect clients to create instances of A, but B is only really used as an implementation detail of A. Also, I want to avoid making B a private class within A, because I have a small number of public classes (from the perspective of clients) and a relatively large number of classes that are simply implementation details. So if I were to take that approach, I would end up with a small number of absolutely huge files...

An idea I had was to make two DLL's, one that is the public interface, and the other that is the private details, and then only document the public one...

Any ideas on what is normally done?
 
You should be setting access modifiers on ALL your classes. If you want a class visible outside the current assembly then declare it Public. If it is to be used only within the current assembly then declare it Friend. When writing an application ALL classes should be declared Friend. There's no reason that a class should be visible from outside an application assembly. If you don't do that then anyone can change the extension to DLL and then reference your assembly and use your classes.
 
Ok...I come from a C++ world, so declaring a class friend (to make it private) was somewhat foreign...I think I tried declaring private and that didn't work. Thanks for the tip...
 
Back
Top