Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,130
    Thanks
    4
    Thanked 455 Times in 444 Posts
    Quote Originally Posted by Vege View Post
    If all your classes are under one namespace then changing one line per page vs all the classnames on every page is a huge difference.
    Yeah, that's the part I don't get... how is that a "thing" in the first place, much less a "thing" to even be worried about? The mechanism of it still means you'd have to call externally... I don't see what it provides that a class (or better a singleton) does not, other than having no security restrictions. (one of the advantages of PHP's object implementation).

    It doesn't make sense to me, I've heard that claim many times and the reality of what it does simply fails to line up with that... at all, unless there is something fundamentally, radically, and perhaps horrifyingly wrong with the program structure itself.

    It might be easier to change it once in the block it's for, but you still have to change it all the places you CALL it, resulting in no real improvement. Unless you're running a bunch of isolated codebases at once that NEVER talk to each-other directly or are called from a single unified point, I just don't see that selling point holding up under scrutiny.

    It ranks right up there with nonsense like "don't store data on the DOM" that resulted in the halfwitted "Virtual DOM" bull****. It reeks of that same notion of taking something piss simple and making it harder to deal with and slower to implement.

    Quote Originally Posted by Vege View Post
    That's why it's used in every language.
    REALLY? That's news to me... been programming 40 years over dozens of languages, and PHP is the first time I've seen anything like it... and part of why it seems so utterly, ridiculously, and laughably pointless.

    I've not seen a single situation where it didn't make things HARDER to work with, providing zero real-world benefit. It doesn't even make SENSE!

    Though to be fair, I say the same thing about "visual programming" -- was never able to grasp the concepts.

    I think it just doesn't work the way I think about solving problems -- it creates more code, more complex and hard to follow code... actually yeah, that's what it reminds me most of, that ugly cryptic useless "nesting" garbage from SCSS. Because things are so generically abstracted, it's tread into being "false simplicity"... being so obsessed with making it LOOK simpler that it actually makes the TASK harder.
    Last edited by deathshadow; Jun 16th, 2018 at 12:59 PM.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  2. #17
    Regular Coder Vege's Avatar
    Join Date
    Jan 2008
    Posts
    982
    Thanks
    22
    Thanked 132 Times in 131 Posts
    Quote Originally Posted by deathshadow View Post
    Yeah, that's the part I don't get... how is that a "thing" in the first place, much less a "thing" to even be worried about? The mechanism of it still means you'd have to call externally... I don't see what it provides that a class (or better a singleton) does not, other than having no security restrictions. (one of the advantages of PHP's object implementation).

    It doesn't make sense to me, I've heard that claim many times and the reality of what it does simply fails to line up with that... at all, unless there is something fundamentally, radically, and perhaps horrifyingly wrong with the program structure itself.

    It might be easier to change it once in the block it's for, but you still have to change it all the places you CALL it, resulting in no real improvement. Unless you're running a bunch of isolated codebases at once that NEVER talk to each-other directly or are called from a single unified point, I just don't see that selling point holding up under scrutiny.
    I am indeed speaking of single codespace that uses other codespaces sparingly. If you are combining multiple codespaces really often I would ask why the separation?
    Nowadays people like to separate all their code into multiple folder and multiple namespaces. But to my taste that will complicate things as you mention.


    Quote Originally Posted by deathshadow View Post
    REALLY? That's news to me... been programming 40 years over dozens of languages, and PHP is the first time I've seen anything like it... and part of why it seems so utterly, ridiculously, and laughably pointless.
    Most of top programming languages have a concept of namespaces.
    You speak about your dislike of the PHP implementation not the functionality itself.

  3. #18
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,130
    Thanks
    4
    Thanked 455 Times in 444 Posts
    Quote Originally Posted by Vege View Post
    Most of top programming languages have a concept of namespaces.
    REALLY? Which ones? I can't think of any language that even approaches the concept. Well, maybe some of the bizzaroland stuff in node.js you couldn't pay me enough to use voluntarily. Hell, you put a gun to my head over it I'd say pull the trigger.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  4. #19
    Regular Coder Vege's Avatar
    Join Date
    Jan 2008
    Posts
    982
    Thanks
    22
    Thanked 132 Times in 131 Posts
    Quote Originally Posted by deathshadow View Post
    REALLY? Which ones? I can't think of any language that even approaches the concept. Well, maybe some of the bizzaroland stuff in node.js you couldn't pay me enough to use voluntarily. Hell, you put a gun to my head over it I'd say pull the trigger.
    C++, Java, Python, C#, Visual basic, Ruby, Perl, Go, Node to name a few?
    Even if it's named Package in Java it don't change the concept of namespaces?

  5. #20
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,130
    Thanks
    4
    Thanked 455 Times in 444 Posts
    Quote Originally Posted by Vege View Post
    C++
    I had to research this as the fact I was able to find that YES, they do exist in C++ online almost felt like a mandala effect. (Which I remember being named for the circular symbol representing a universe the loops back on itself, NOT Nelson Mandela!)

    Particularly given the number of professional C++ codebases I've been in the past thirty years and never ONCE seen this. But it seems I'm just 25+ years out of date... as it's nowhere to be found in ANY of the C++ books I have on my shelf.

    Turns out it was added to the specification in 1990, few people making compilers other than GNU gave a flying f***, resulting in it not showing up in the compilers I've used (mostly Borland) for another 5-6 years... and because for me it didn't "exist" in C++, it seems I never even looked for it in other languages.

    So my bad, I was wrong... can't know everything... I'm not often wrong, but when I am I tend to be SPECTACULARLY wrong!

    STILL seems idiotically pointless and self defeating. Never needed it, never wanted it. NOT even something I would think of using. I'm with Linus on this one, and 'namespaces' only further adds to the over-abstraction woes common to "generic" programming.

    Though to be fair I say the same about 'block level' scoping. If function/method level isn't "enough" for you, you're probably doing something WRONG. An attitude borne of having learned "forward declaration" languages BEFORE c-style inline declaration. The mere notion of being able to blindly declare a variable "anywhere" inside a scope just seems like BEGGING for errors and ineffciencies.
    Last edited by deathshadow; Jun 17th, 2018 at 12:03 PM.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  6. #21
    New Coder
    Join Date
    Jun 2018
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Dependency injection is a nice way to configure implementations.

    PHP Code:
    class myClass{

    public function 
    __constructAPI_Interface $api );


    Now I can just swap the API class that is passed to the constructor.

    Namespaces can do something similar, ie:

    PHP Code:
    use App/v2/API;

    class 
    myClass{

    public function 
    __constructAPI $api );


    To implement the v3 of the API, I could change the namespace to App/v3/API.
    In what way are those two methods mutually exclusive, or do they work together? Are there any significant pros or cons? The namespace way seems very simple, but I don't see how one could type hint against an interface.
    Last edited by paddelboot; Jun 18th, 2018 at 12:06 PM.

  7. #22
    Senior Coder benanamen's Avatar
    Join Date
    Oct 2015
    Posts
    1,544
    Thanks
    6
    Thanked 155 Times in 150 Posts
    I don't see how one could type hint against an interface.
    Rather than explain it, you can read this..
    https://phpenthusiast.com/object-ori...for-interfaces
    To save time, lets just assume I am almost never wrong.

    The XY Problem
    The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

    Make A Donation https://www.paypal.me/KevinRubio


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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