Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121317 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24823 invoked from network); 15 Oct 2023 00:05:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Oct 2023 00:05:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 55868180504 for ; Sat, 14 Oct 2023 17:05:12 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, LOTS_OF_MONEY,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 14 Oct 2023 17:05:11 -0700 (PDT) Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-3513b5a9e8eso13599245ab.0 for ; Sat, 14 Oct 2023 17:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697328311; x=1697933111; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5tFkX/sJ4wUm08L+HhcqbfJMGr8taG/3x6Z5tuJcpxM=; b=QaCbAa+HFnJgaGTBjzIDzHR3Vq8DviUt+7+8iJwKbnI9ijE38W9SVMPL0lXy2/KYgG sdGckxzW2mWJfJwgHZnXO2Sd5t+2j2G8MrLcJM6EPviGuTyYkZyGJhNpf7ygDzprZcbN eC713ZhPls7AYu/n2FYJd1/GZTcdFviozCc/aeD37kpoyGUoFc6RFxUIRhNcpp6uA/ay EqRntfXBe2thtOJmGxB6sqEsfV6hBU++IeECpf0IPxAziD3gSeHseAOrBGVOtBZ7mCP2 g1ujYXoLf+lwLz75hdLqpwUcYxd+nijqHr8E/J6DrdEzbkSLba9bzs4UkZX4sEKKwI3k GwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697328311; x=1697933111; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5tFkX/sJ4wUm08L+HhcqbfJMGr8taG/3x6Z5tuJcpxM=; b=Z7MELjkP4iLhSxnLZW5NglWZVY+5gHWrhYyYDnS+w4zK2vrmZ83mXR7CkxlbTenbdM HZgqSDiZosnxq9amFsEUkEYvkbrIL3fWTo6WxClJVfpl/RRJOZyIW1dZlwz8xEwryFwO i6vXkqBesAAOvSVsOu3YffKi6iY+f2mRzpZumi5YceqJZScJ44hTo1YlQJOXhaymArW1 TLY+nWSm5g3AhTOvHYAYGi3ICV6hszv1K1vw710Ee5pEV9GN31OVOt6j0p1Rvn7vD16h qCo2zz7SydWOPKfaO9y8L0GN2vWcY+ifwIfkD/gAxlJdTw3sLZ3bVzanT4RkluU3BVs+ JJQg== X-Gm-Message-State: AOJu0YxkUfBBPejq+whOEcrofYG9BXo5TLYUFpqgtYe9Op0tVbCZRueH BcOZtFFsy0gS8d7pwKuYP6j8IDFgaYKo6WcK0XoUnesdtYI= X-Google-Smtp-Source: AGHT+IFyup3wHtBDxBuzL4o4DFx2WYToUwbKa085Z7SO1Aiyz5mwwTxEQbWlPinrwCNq+ix7jo6aKQ+MHQe6AMJGKpQ= X-Received: by 2002:a92:da83:0:b0:357:6e14:835f with SMTP id u3-20020a92da83000000b003576e14835fmr4012921iln.15.1697328310933; Sat, 14 Oct 2023 17:05:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 15 Oct 2023 01:04:59 +0100 Message-ID: To: David Grudl Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000a605f0607b60b42" Subject: Re: [PHP-DEV] Better name for method Randomizer::nextFloat() From: fenniclog@gmail.com (tag Knife) --0000000000000a605f0607b60b42 Content-Type: text/plain; charset="UTF-8" On Sat, 14 Oct 2023 at 18:48, David Grudl wrote: > > A) The problem with nextFloat() is that the name creates a false > expectation. Take a look at the following code: > ``` > $randomizer = new \Random\Randomizer(); > $a = $randomizer->getFloat(100, 200); // number between 100..200 > $b = $randomizer->nextFloat(); // another number between 100..200 ??? > ``` > I don't even get the point of nextFloat. Its a random function, there is no thing as "next". I think the major pet peeve i have is that the "Randomizer" class is encapsulating all random functions. I would like to see each randomizer have its own class, since they are under the Random namespace anyway, I believe they should be Random/StringRandomizer, Random/IntRandomizer, Random/FloatRandomizer, so on so forth. Basically Ramdom/{Type}Randomizer. This would also allow more granular and specific functionality for each type. For example, for this discussion, the class, Random/FloatRandomizer (and IntRandomizer) could be instatiated with its boundries. ```php $randomFloat = new Random/FloatRandomizer($lowerBound, $upperBound, $boundryInterval) $a = $randomFloat->get(); $b = $randomFLoat->next(); ``` Is that not more intuitive? --0000000000000a605f0607b60b42--