none
Where is the actual data processing of functions in this structure? RRS feed

  • Question

  • I understand that in the flavors of C you can declare function(s) in class definitions and define the function(s) themselves at some other place in code. There are descriptions, examples and walkthroughs abundantly available... prototyping, iirc.

    I'm finally in a place where I feel I would benefit from actually defining a class rather than re-writing code. But! I've switched to VB, and there doesn't seem to be documentation related to prototyping. I may be missing it, and if this is the case please point me in the right direction, as every time I search "prototype" the sheer volume of hits for C (flavor of choice) and scripted language of choice obscures any relevant hit for VB (even with a VB or Visual Basic qualifier on the search: these mostly point to books I will not buy or irrelevant MS documentation).

    Nevertheless, using existing code base to demonstrate a working "format" I turned to the PointF class (edit: not class, is structure) definition.

            Public Shared Function Subtract(pt As PointF, sz As Size) As PointF
            Public Shared Function Add(pt As PointF, sz As SizeF) As PointF
            '
            ' Summary:
            '     Translates a System.Drawing.PointF by the negative of a specified size.
            '
            ' Parameters:
            '   pt:
            '     The System.Drawing.PointF to translate.
            '
            '   sz:
            '     The System.Drawing.SizeF that specifies the numbers to subtract from the coordinates
            '     of pt.
            '
            ' Returns:
            '     The translated System.Drawing.PointF.
            Public Shared Function Subtract(pt As PointF, sz As SizeF) As PointF
            Public Shared Function Add(pt As PointF, sz As Size) As PointF

    Expanding the definitions (only one expanded here) you can see that none of these functions are actually defined, but rather are only declared. They are, in fact, defined no where within the class (at least as shown).

    So, my questions:

    1) Is this really prototyping, and the functions are defined elsewhere? Or, is this merely Microsoft obscuring the code because "reasons"?

    2) If it is prototyping, how might one define the function outside the class?

    3) Of even lesser importance. What is the reasoning behind the choice to prototype or define in class? (again assuming this is a case of function prototyping.)

    I believe none of the answers for these questions will stop me from progressing at this time, it merely burns in my mind to "understand" and incorporate that understanding for future consideration.

    If there is other information that might be helpful to me in this regard (without burying me in minutiae) I would appreciate that as well.

    Thank you!

    EDIT: I wanted to understand how they did not define what to do with the data in the structure's function definitions (which was my initial wrong thought) and where to find the real definitions as I'm certain they must have some actual processing - not just passing the data around until it magically becomes something else. Ultimate goal to understand the ephemeral "everything" just a bit better. I had many other thoughts, which were also incorrect and only confused those attempting to help. It has become obvious I'm not yet ready to understand the answer (or even ask the question properly) as I don't have enough prerequisite knowledge. Because I thought it might be LIKE prototyping in C, I wanted to head off answers in that language, obviously another mistake. I didn't want to be the 5 year old asking for the answer to the universe, but apparently I am.  I would delete the entire thing if it were possible. Just let it die.



    • Edited by Writeagame Tuesday, August 15, 2017 5:48 PM For less ambigous SUBJECT line +
    Tuesday, August 15, 2017 7:07 AM

Answers

All replies




    • Marked as answer by Writeagame Tuesday, August 15, 2017 12:54 PM
    • Edited by Cor Ligthert Tuesday, August 15, 2017 6:01 PM
    • Unmarked as answer by Writeagame Tuesday, August 15, 2017 6:44 PM
    Tuesday, August 15, 2017 7:26 AM
  • Write,

    I'm late to this, but it sounds like you're talking about inheritance.

    Cor showed the use of an interface which is also inheritance but the "standard" way may be more of what you're looking for?

    An Interface is a "HasA" relationship and standard inheritance is a "IsA" relationship:

    Public MustInherit Class AbstractClass
        Public MustOverride Function AddTwoIntegers() As Integer
    
    End Class

    The base class must be an abstract class to use MustOverride.

    When I then create a derived class from it, the fact that I set the "AddTwoIntegers" function as "MustOverride" will cause it to put the template out for me:

    Public Class SubClass
        Inherits AbstractClass
    
        Public Overrides Function AddTwoIntegers() As Integer
    
        End Function
    End Class

    With this, unlike with an Interface, the author of the base class establishes the access level (Public in my example above).

    Is that helpful?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    • Edited by Frank L. Smith Tuesday, August 15, 2017 5:17 PM ...mistated
    Tuesday, August 15, 2017 4:33 PM
  • Because of the fact that the OP has changed the header line, my replies are worthless. 

    I've blanked it to avoid that some become confused. 

    The OP is not asking in my idea something about Prototyping or whatever he is writing about. 

    Currently I think he is simply talking about a module but I stop replying on this. 


    Success
    Cor


    Tuesday, August 15, 2017 6:07 PM
  • I didn't want to be the 5 year old asking for the answer to the universe, but apparently I am.  I would delete the entire thing if it were possible. Just let it die.

    I hope you mean let this thread die rather than the universe? ;-)

    Edits do not trigger an e-mail being sent so I missed this. Don't leave yet - let's work through it and start here: What's are you trying to do? Do you have an example of "Input" and resultant "Output"?


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Tuesday, August 15, 2017 6:53 PM
  • Looking strictly at the revised question:

    "Where is the actual data processing of functions in this structure?"

    The answer is that it's done in the BCL -- the dotNET framework itself does all of that and we're very grateful that it does! ;-)

    VB (and others, including C#) are high level languages. The framework manages things for us like, for example, memory management, garbage collection, and their library of namespaces/classes galore makes it very rare that you ever need to branch out beyond the framework to get things done.

    I don't know if that's what you're after or not but that's the elevator speech anyway.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, August 15, 2017 7:04 PM

  • "A problem well stated is a problem half solved.” - Charles F. Kettering


    I so wish I had skill at that!

    I failed to well define my question because I can't even quantify the extents of it (I've tried several times and it just keeps getting bigger and broader). I assumed there was a general simple answer and leapt with that, believing it would make everything just slide into place. Wrong.

    I appreciate the attempts to help, even from Cor. His explanation was way more than I'm able to understand and so I don't even know if it addressed my problem... Your answer, I believe I understand but it doesn't seem to help explain my boggle with the PointF structure (or similar).

    So, thanks, but I'm convinced at this point I just don't know enough in general to be asking this question in the first place. At least not with an expectation that someone could give me an answer that wouldn't lead to more questions by me than is reasonable.

    Tuesday, August 15, 2017 7:57 PM
  • Then simply tell what you want to do. 

    If you want to eat an apple than don't tell that you have a knife, and a fork, and also a spoon but no plate and you have read in the bible that Adam got one from Eve and that gave problems. 

    Just tell: "I want to eat the clean apple I've in my hand". 

    Than somebody can say: "Just bite in it". 

    Be aware that the main difference between a structure and a class is that a structure is by default initialized in the main stack (probably difficult for you). 

    Structures are used for value types because a class is more expensive if it uses less than 16 bytes (other wise the structure is more expensive). 

    For instance PointF is just a structure which contains X and Y. 

    And then I've to write something you probably won't understand about overloading so I avoid that. 


    Success
    Cor



    Tuesday, August 15, 2017 8:18 PM
  • The details about PointF are available:

    These parts were made in C#.

    For convenience, Visual Studio shows only the prototypes and description.

    According to documentation and articles, it is possible to see and execute these sources when you debug your program. Look for “Enable .NET Framework source stepping” in Debugging tab of Options dialog.


    • Edited by Viorel_MVP Tuesday, August 15, 2017 8:31 PM
    • Marked as answer by Writeagame Wednesday, August 16, 2017 9:48 AM
    Tuesday, August 15, 2017 8:26 PM
  • I hope you mean let this thread die rather than the universe? ;-)

    Edits do not trigger an e-mail being sent so I missed this. Don't leave yet - let's work through it and start here: What's are you trying to do? Do you have an example of "Input" and resultant "Output"?


    "A problem well stated is a problem half solved.” - Charles F. Kettering



    Your hopes are fulfilled. :) Universe going away would be far too inconvenient for everyone.
    • Edited by Writeagame Tuesday, August 15, 2017 9:56 PM
    Tuesday, August 15, 2017 9:55 PM
  • Your hopes are fulfilled. :) Universe going away would be far too inconvenient for everyone.
    ...and difficult to pull off. ;-)

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, August 15, 2017 9:58 PM
  • The answer is that it's done in the BCL -- the dotNET framework itself does all of that and we're very grateful that it does! ;-)

    VB (and others, including C#) are high level languages. The framework manages things for us like, for example, memory management, garbage collection, and their library of namespaces/classes galore makes it very rare that you ever need to branch out beyond the framework to get things done.

    I don't know if that's what you're after or not but that's the elevator speech anyway.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    This I understood (and I even agree it's a good thing but --- ), I still half had it in my head that we could review the code. In my case merely to see if I could understand what was being done and maybe even why. (see a response err above from Viorel_)

    Truly, I don't enjoy asking questions here BECAUSE there is so much I know I don't understand... it's hard to answer a poorly phrased question as everyone keeps pointing out. Just because I thought and hoped I'd done it well, didn't change a thing.

    So, I tinker on things, I read, I think, I tinker some more to see if what I think works the way it should (or at least appears to). When code is obscured for "reasons" it ruins my game. And this thread happens OR I just choke on it and move on for a while.


    • Edited by Writeagame Tuesday, August 15, 2017 10:19 PM
    Tuesday, August 15, 2017 10:04 PM
  • The details about PointF are available:

    These parts were made in C#.

    For convenience, Visual Studio shows only the prototypes and description.

    According to documentation and articles, it is possible to see and execute these sources when you debug your program. Look for “Enable .NET Framework source stepping” in Debugging tab of Options dialog.


    If I can get this to work and review said code would this make the number 1) from my original post the actual correct interpretation with the exception that it would be an AND rather than an OR? (expanded - yes it is prototyping (or at least might be)... but not in Visual Basic code AND it is obscured for reasons "it's not native code and is hidden by default as you don't need to worry about it programmatically... it's a feature".

    I'm stopping now to await response before I again jump to conclusions about how knowing this will help me.

    Following the link, whoa... code. Not instruction on how to step through in the IDE. Woops. That makes a lot more sense now. (Not saying I understand it all, but I'm not exactly drowning either).

    Thank you!

    • Edited by Writeagame Tuesday, August 15, 2017 11:33 PM followed the link so updated
    Tuesday, August 15, 2017 10:17 PM

  • This I understood (and I even agree it's a good thing but --- ), I still half had it in my head that we could review the code. In my case merely to see if I could understand what was being done and maybe even why. (see a response below from Viorel_)

    Truly, I don't enjoy asking questions here BECAUSE there is so much I know I don't understand... it's hard to answer a poorly phrased question as everyone keeps pointing out. Just because I thought and hoped I'd done it well, didn't change a thing.

    So, I tinker on things, I read, I think, I tinker some more to see if what I think works the way it should (or at least appears to). When code is obscured for "reasons" it ruins my game. And this thread happens OR I just choke on it and move on for a while.

    I somewhat disagree here.

    Do you *really* know all the ins and outs of how a FileStream works or a WebClient or a (fill in blank)?

    I don't - but also, it's not of import.

    As I start to write more and more of my own class libraries, I've come to realize that beyond what's publically exposed (that's my choice), it's not needed to be known. In fact, many of the latest things that I've done will never be fully exposed; I know what's in there and how it works, but there's no reason that the consumer(s) of my library do.

    As an example:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/8222cb3e-99e7-48a7-9bfa-aa1cd913d9fa/binary-serializationdeserialization-a-library-to-compress-and-encrypt-the-data?forum=vbgeneral

    That's from a few months ago. I can't tell you certain parts of what makes it work, or I won't.

    It's a matter of "need to know" -- and you don't have a "need to know".

    Make sense?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Tuesday, August 15, 2017 10:20 PM
  • I somewhat disagree here.

    Do you *really* know all the ins and outs of how a FileStream works or a WebClient or a (fill in blank)?

    I don't - but also, it's not of import.

    As I start to write more and more of my own class libraries, I've come to realize that beyond what's publically exposed (that's my choice), it's not needed to be known. In fact, many of the latest things that I've done will never be fully exposed; I know what's in there and how it works, but there's no reason that the consumer(s) of my library do.

    As an example:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/8222cb3e-99e7-48a7-9bfa-aa1cd913d9fa/binary-serializationdeserialization-a-library-to-compress-and-encrypt-the-data?forum=vbgeneral

    That's from a few months ago. I can't tell you certain parts of what makes it work, or I won't.

    It's a matter of "need to know" -- and you don't have a "need to know".

    Make sense?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    I think there's a difference between trying to learn how to fly and trying to learn how to fly something you don't have authority to fly. I'm not trying to do the latter. That it ended up that that was what I was getting into, wasn't because of the intent. If I'd known enough to understand what I was and wasn't seeing it never would have been an issue.

    Wednesday, August 16, 2017 11:15 AM

  • I think there's a difference between trying to learn how to fly and trying to learn how to fly something you don't have authority to fly. I'm not trying to do the latter. That it ended up that that was what I was getting into, wasn't because of the intent. If I'd known enough to understand what I was and wasn't seeing it never would have been an issue.

    You don't have to know how a spring-wound watch works in order to tell the time -- but you did ask how it works, so you got answers to that. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Wednesday, August 16, 2017 11:27 AM
  • You don't have to know how a spring-wound watch works in order to tell the time -- but you did ask how it works, so you got answers to that. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    LOL, of course. But the how I wanted to know wasn't the one being answered. Which admittedly is my fault because I didn't communicate which how as well as I'd thought.

    I regret offending the pros with my amateur questions. Not only for the level disparity, but also my inability to be clear.

    I didn't come here in hopes of angering everyone. It wasn't even an ancillary benefit. This is why I direct my calculus inquiries to my son... he doesn't throw things at me too often.

    Anyway, thanks for talking with me.

    Wednesday, August 16, 2017 11:59 AM