in reply to Re: Understanding a OOp code
in thread Understanding a OOp code

hi

Thanks for so quick a reply,

but, please, I am still not able to get it, I get some data with 'my $licObj = LIC_INFO($licCode);'

but , I do not understand the objective(logic) behind calling the same sub-routine with '$licObj->LicenseData();'

'sub LicenseData' is the sub-routine where "my licObj is created"

Replies are listed 'Best First'.
Re^3: Understanding a OOp code (updated)
by haukex (Archbishop) on Sep 26, 2016 at 10:17 UTC

    Hi sachinz2,

    the objective(logic) behind calling the same sub-routine

    It's possible likely there are two subs with the name LicenseData in different packages (classes). Inside the sub, you could try doing print __PACKAGE__, " / ", ref($hash), "\n";, that will print the current package and the package of $hash (more specifically, the package that $hash is blessed into, or in OO terminology the object's class).

    Otherwise, if there's only one sub LicenseData, then this would indeed be a recursive call, and the next call to LicenseData would receive in its $lic parameter the $hash value of the caller. How the recursion ends depends on what LIC_INFO is doing.

    Update: Actually, what I wrote above about there being two (or more) sub LicenseDatas is much more likely, since I don't see a clean way for the recursion to end if there's only one sub LicenseData.

    Hope this helps,
    -- Hauke D

      Hi

      Thanks Friends

      Yes @Hauke there were 2 sub-routines.

Re^3: Understanding a OOp code
by GrandFather (Saint) on Sep 26, 2016 at 19:52 UTC

    $licObj->LicenseData(); doesn't call the same sub. It is another example of unfortunate naming in the code. There is an element of truth in:

    There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton

    Naming things well is hard. However the big item here is that you aren't up to speed with what OO is about. The key is that $licObj is an object and methods (LicenceData() in this case) do things with the object. Maybe Not quite an OO tutorial will help make it a little clearer. A huge amount has been written about OO, but until the "Ah ha" moment comes it doesn't make much sense and even then it's likely not obvious where the benefit is. Used well it does make sense and there is a benefit.

    Premature optimization is the root of all job security