Jump to content

wadej30084

New Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by wadej30084

  1. 4 minutes ago, Phi11W said:

    the convention around here is "New question, new thread". 
    That allows for short, direct answer to short, direct questions instead of long, rambling threads where all the "Goodness" gets lost. 

     

    Some comments on the above: 

    • the use of "global" breaks encapsulation, requiring the environment "outside" the function to provide the variable. 
      It is better to pass the data as an argument to the function. 
    • What value does admin['gender'] have? 
      Any value passed that resolves to true will cause the ternary operator to return "Mr" and everything else will return "Mrs". 
    • The code makes no attempt to ensure that the array indexes used actually exist; this may or may not be an issue.  
    • What if the individual is female and not married
      They might object to being called "Mrs". 
    • What if the individual is not gender-identifying
      They would object most strongly to be referred to by either of the terms used here. 

    Marital status and/or gender are both Personal Data and should be stored in the User's "record" (whatever form that takes) so that it can be managed by/on behalf of the User and changed over time.  

    Regards, 
       Phill  W.

     

    Wow, this a big explanation, many thanks Phill!
    P.S. I keep in mind about new thread.

  2. Hi, maybe I'm saying something wrong, but I'm talking about this piece of code, another from first post:

    function getAdminName()
    {
        global $admin;
        return ($admin['gender'] ? 'Mr' : 'Mrs').' '.$admin['fullname'];
    }

     

    Help is needed with it, be answering on the question:
    "This code isn't ideal. Explain what the problem is and what you could do to fix it"

  3. 31 minutes ago, maxxd said:

    The portion of your last code bit in parenthesis is called a ternary operator. I recommend reading up on it as it's something you'll see often if my experience is at all typical.

    Thanks, for reply. I know what is ternary operator, also I know about latest deprecated features about this operator in 7.4 version, but i don't see here any problem with it, any complex use like 1 ? 2 : 3 ? 4 : 5; , the problem is what i don't understand what I'm must looking for in this piece of code. Any advice?

  4. Ok, I see you like it, I have another one.
    Same situation have code piece:
     

    function getAdminName()
    {
        global $admin;
        return ($admin['gender'] ? 'Mr' : 'Mrs').' '.$admin['fullname'];
    }

    and simple question:

    "This code isn't ideal. Explain what the problem is and what you could do to fix it"

    it's all, please help! Today I have no idea what's wrong except this is creepy realization and I do this in totally another way.

    P.S. ginerjm asking what is it, this is a part of practical tasks of technical php test and I trying do my best to solve it, but even if I fail on exam I need to understand what's it about.

    All this about: "You need to think globally, we need to see how you think."
    And like
    Ross Geller's little hand monkey, but in my head, beating in cymbals plates, with deep understanding of this code problem eyes look.

    Thanks for help!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.