Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

I've created a coding system and I would like you to comment about that

Hello. I have created a sort of coding system which appears quite weird and mindboggling. I would like to know what type of programming is that coding system, whether I'm making programming strategies which have already existing names, if people already thought in programming in this style (so that I may see whether I'm having a sort of "innovative" idea), how I could turn this code system more "normal", and what you think about that. Below is the description of the coding system. First, I will give an example of a code made using this coding system which will serve to illustrate the coding system, it consists of the creation of the function Function_AttemptAbstractEvent, which takes such a function as a principle to use the code system in the code (therefore the variables, expressions, and functions of the code are, in some sense, predicated to this single function), which is intended to return whether an event with (let's say "A") chances of happening within (let's say "B") possibilities has happened, and returns True if yes, and returns False if no:

Code:
function Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent(){}
function Default_Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent()
    {
    $Global:AttemptAbstractEvent_DoesAttemptResultMatchesEvent = $True;
    }
function SetVariables_Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent()
    {
    $Global:AttemptAbstractEvent_DoesAttemptResultMatchesEvent = $Global:AttemptAbstractEvent_GenerateAttempt_Result -lt $Global:AttemptAbstractEvent_NumberOfChances;
    }
Function Call_Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent()
    {
    SetVariables_Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent;
    Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent;
    }
function Function_AttemptAbstractEvent_GenerateAttempt(){}
function Default_Variable_Function_AttemptAbstractEvent_GenerateAttempt_Result()
    {
    $Global:AttemptAbstractEvent_GenerateAttempt_Result = 0;
    }
function SetVariables_Function_AttemptAbstractEvent_GenerateAttempt()
    {
    $Global:AttemptAbstractEvent_GenerateAttempt_Result = Get-Random -Maximum $Global:AttemptAbstractEvent_NumberOfPossibilities;
    }
function Call_Function_AttemptAbstractEvent_GenerateAttempt()
    {
    SetVariables_Function_AttemptAbstractEvent_GenerateAttempt;
    Function_AttemptAbstractEvent_GenerateAttempt;
    }
function Function_AttemptAbstractEvent()   
    {
    Call_Function_AttemptAbstractEvent_GenerateAttempt;
    Call_Function_AttemptAbstractEvent_DoesAttemptResultMatchesEvent;
    }
function Default_Variable_Function_AttemptAbstractEvent_NumberOfChances()
    {
    $Global:AttemptAbstractEvent_NumberOfChances = 1;
    }
function Default_Variable_Function_AttemptAbstractEvent_NumberOfPossibilities()
    {
    $Global:AttemptAbstractEvent_NumberOfPossibilities = 1;
    }
function SetVariables_Function_AttemptAbstractEvent()
    {
    $Global:AttemptAbstractEvent_NumberOfPossibilities = Get-Random -Minimum 1 -Maximum 10;
    $Global:AttemptAbstractEvent_NumberOfChances = Get-Random -Maximum ($Global:AttemptAbstractEvent_NumberOfPossibilities+1);
    }
function Call_Function_AttemptAbstractEvent()
    {
    SetVariables_Function_AttemptAbstractEvent;
    Function_AttemptAbstractEvent;
    $Global:AttemptAbstractEvent_DoesAttemptResultMatchesEvent;
    }

Here is the description of the coding system:

Every function have, in principle, a name which goes like "Function_"+[Name of the function]. For every function in which their name start with "Function_", there should be a function created specifically to set (define) the value of the variables and parameters of the function and then call the function, in which its name goes like "Call_"+[Name of the function]. For every function in which their name start with "Call_", there should be a function in which its name goes like "SetVariables_"+[Name of the function in which the function in which its name start with "Call_" refers to (corresponding to the string which goes after the string "Call_" of the name of the function in which its name start with "Call_")], which should set the value of the variables and parameters in which the corresponding function in which its name start with "Function_" shall deal with. For every "SetVariables_" function, there should be a function in which its name goes like "Default_Variable"+[Name of the function "Function_" in which the function "SetVariables_" relative to the function "Default_Variable" refers to]_[Name of the variable], which assigns default variable and parameter values to the corresponding function "Function_", so that the functions "SetVariables_" may be convenient to decide whether it will set a default value for a "Function_" variable and parameter, or change the default variable value so as to make a "customized" function "Function_" call. The "SetVariables_" function will serve as a way for the user to declare the variables of a function without having the cumbersomeness of having to modify the default value of every variable of a function "Function_". Furthermore, virtually every procedure within a function (let's say A) shall be done through a function (let's say B) which is specific to that function, with the name of the function B being [Name of function A]_+[Name of function B].

In the above code, the code is set to return whether an event with Chances of chances of happening within Possibilities possibilities has happened, being Chances a random number which can varies from 0 to Possibilities, and Possibilities being a random number which varies from 1 to 10, as you can see in the code, therefore the code is not set to return default values for Chances and Possibilities, and if it had, it would always return true, because a random number Get-Random -Maximum 1 will always return 0, when the default value of Possibilities is set to 1, which means the variable $Global:AttemptAbstractEvent_DoesAttemptResultMatchesEvent will always have the value True within the execution of the function Call_AttemptAbstractEvent;

Here are some ideas about the code system:

The intention of that is to have every variable and function accessible to the global scope so that every function may have the possibility to have agency over all the details of another function, in order to and also to give a greater "versatility" for me to improve the functions which are "predicated" to the function Function_AttemptAbstractEvent, knowing that this type of coding style likely allows me to define every detail of how things will be done in every procedure my code takes. Apparently, declaring parameters and variables through functions which declare parameters and values defines HOW parameters and variables will be declared as WHAT the parameters and variables will be, rather than simply WHAT parameters and variables will be, when the "HOW" of variables and parameters appears to give me a bigger "versatility" for me to improve my code rather than the "WHAT" of variables and parameters.

I don't know if I'm sort of "playing the fool" by creating a coding system which tends to generate a lot of line codes which is, at first seeing, cumbersome to write, when I could simply write an one-line function which satisfies the goal of returning whether an event with $A chances in $B possibilities of happening has happened, like this one:

Code:
function AttemptAbstractEvent($A,$B){if((Get-Random -Maximum $B) -lt $A){return $True;}return $False;}

And I know I apparently have many more possibilities to improve my code having the code which was created using my code system rather than this one-line code, when, if such an one-line code would be supposed to be edited so as to gradually add improvements to the function, such as "fineties", I suppose it would take more effort to modify this one-line function than it would take to modify the code which uses my coding system, I don't know if I could achieve the "versatility" I'm speaking about simply through specific instances of code which are supposed to use my one-line AttemptAbstractEvent function, please comment whether this code system can be considered decoupled programming, and, if not, what would be the name for it, and the fact that, using such a code system, I've left some functions empty. Please clarify me about these matters, Thanks.
 
Using global variables instead of arguments does make a program easier to change.

For small programs, this would be fine. There's more than one way to skin a rabbit, as they say.

There's always a trade-off, testing would be harder.

As for a name, how about "retro BASIC style"?
 
Well, I've found a better code and the code system it represents. Here is the code:
Code:
Class AttemptEvent
    {
    $DefaultNumberOfPossibilities = 1;
    $NumberOfPossibilities = 1;
    $DefaultComparisonResult = $True;
    $ComparisonResult = $True;
    $DefaultNumberOfChances = 1;
    $NumberOfChances = 1;
    $DefaultAttemptResult = 0;
    $AttemptResult = 0;
    [Bool]DefaultAttempt()
        {
        $this.NumberOfPossibilities = $this.DefaultNumberOfPossibilities;
        $this.ComparisonResult = $this.DefaultComparisonResult;
        $this.NumberOfChances = $this.DefaultNumberOfChances;
        return $this.SpecificAttempt();
        }
    Compare()
        {
        $this.ComparisonResult = $this.AttemptResult -lt ($this.NumberOfChances+1);
        }
    GenerateAttemptResult()
        {
        $this.AttemptResult = Get-Random -Maximum ($This.NumberOfPossibilities+1);
        }
    [Bool]SpecificAttempt()
        {
        $this.GenerateAttemptResult();
        $this.Compare();
        return $this.ComparisonResult;
        }
    }
Here is the description of the code system:

For a function which results unpredictable results and has more than one procedure, there shalt be a class for it. Every procedure of the function shall be written as functions within the class. Every result of expressions within functions representing procedures shalt be stored within a variable that has to be declared within the global scope of the class and for every variable there shalt be a variable which defines the default value of that variable, with exception of variables which define the default value of variables. There shalt be a function within the class which sets the values of variables which are not variables supposed to set a default value to variables to their default values by declaring their values to be the same value as the values of their respective variables which are supposed to set a default value to them through referentiation and then calls a function which "compiles" the class by executing all the functions of the class which represents procedures thereby returning the desired result of the function which represents the class, which shalt be created within the class, so that the user may have the possibility to call the function representing the class in a "default" way or a "specific" way.

Question: Could you please give me tips on how to name variables, tell me whether there is an advantage to use default values to functions, and whether there is a better than than "specific" to designate a function which does not call a function through its default values necessarily? Also, is there an advantage to make a distinction between initial value and default value in programming so that you have declared an initial value for an object attribute, and a default value for it which can be set through a function? Sorry if I don't sound clear. EDIT: Also, the advantage of this code in comparison with the first code of the post is that, with a class which can be used to create objects, I could create customized class objects representing a function which can be customized to behave the way I want, when in the first code it would be cumbersome to do something like that, isn't it?
 
"Beware of your data becoming code-like, and your code becoming interpreter-like." -- Somebody wrote this? (1990-ish)

This could be a warning about subroutines that are too general.

As code is simplified, data gets more complicated.

Deciding beforehand "exactly" how to structure programs, is futile.

Naming conventions, on the other hand, are well worth pondering.
 
Sorry to be a bit blunt, but the description of your (improved) system reads like so much gibberish. That last sentence with 119 words and just one comma.... 😵
The code of your (original) system was unreadable, with names up to a ridiculous length of 73 characters, defining functions with brackets but calling them without brackets. At least the 'improved system' looks rather like what you'd see in Java, C# or Python, but using hyphens as part of a variable name, using
-lt instead of <, using [Bool] instead of just bool ? It looks like you are just trying to be different. A line like this

$this.AttemptResult = Get-Random -Maximum ($This.NumberOfPossibilities+1);

makes absolutely no sense to me.

It seems your main focus is on naming conventions, which I won't comment on - being quite happy to name a counter count instead of NumberOfIterationsSoFarPerformed. If long names are tour thing, go for it.

All in all, I'm sure this is a nice experiment and brain exercise but frankly, I don't see it going anywhere.
 
Last edited by a moderator:
"Beware of your data becoming code-like, and your code becoming interpreter-like."
Could you please explain this quote to me?
using
-lt instead of <
The code is in Powershell. As far as I started programming in it, I've came to know that the symbol < doesn't work whereas the symbol for less than is -lt
using [Bool] instead of just bool
It simply appears more "nice and neaty" to me to use [Bool] instead of [bool], it is pretty much like a matter of personal aesthetic choice
$this.AttemptResult = Get-Random -Maximum ($This.NumberOfPossibilities+1);
My reasoning was that if the number of possibilities turned to be 0, then the expression attributed to the attempt result variable would make the Powershell to have an error because the Powershell returns an error when there is an expression Get-Random -Maximum, so I add 1 to the number of possibilities so that the -Maximum may never be 0 in normal conditions. To be sincere, the logics of GenerateAttempt result and Compare are apparently flawed, I'm going to check it. EDIT: Yes, the function logic was flawed. If the function was supposed to simulate an event with A chances in B possibilities of happening, it would simulate an event with (A+1) chances in (B+1) possibilities of happening. Here is a correction of the code:
Code:
Class AttemptEvent
    {
    $DefaultNumberOfPossibilities = 1;
    $NumberOfPossibilities = 1;
    $DefaultComparisonResult = $True;
    $ComparisonResult = $True;
    $DefaultNumberOfChances = 1;
    $NumberOfChances = 1;
    $DefaultAttemptResult = 0;
    $AttemptResult = 0;
    [Bool]DefaultAttempt()
        {
        $this.NumberOfPossibilities = $this.DefaultNumberOfPossibilities;
        $this.ComparisonResult = $this.DefaultComparisonResult;
        $this.NumberOfChances = $this.DefaultNumberOfChances;
        return $this.SpecificAttempt();
        }
    Compare()
        {
        $this.ComparisonResult = $this.AttemptResult -lt$this.NumberOfChances;
        }
    GenerateAttemptResult()
        {
        $this.AttemptResult = Get-Random -Maximum $This.NumberOfPossibilities;
        }
    [Bool]SpecificAttempt()
        {
    if($this.NumberOfPossibilities -eq 0)
        {
        $this.AttemptResult = 0;
        $this.ComparisonResult = $False;
        return $this.ComparisonResult;
        }
    else
        {
        $this.GenerateAttemptResult();
        $this.Compare();
        return $this.ComparisonResult;
        }
        }
    }
 
Last edited:
Oh, PowerShell .... You did not mention that. Sure, then the < will not work here, as it's an I/O redirection symbol, not a "less than" operator.
But sorry to say, I still have no clue what you are trying to achieve here. Inventing your own PowerShell variant with nicer and neater syntax ?
 
Oh, PowerShell .... You did not mention that. Sure, then the < will not work here, as it's an I/O redirection symbol, not a "less than" operator.
But sorry to say, I still have no clue what you are trying to achieve here. Inventing your own PowerShell variant with nicer and neater syntax ?
By "nice and neaty" I meant an expression that was intended to mean using "bool" with lowercase "cringes" me and "hits my nerves"
 
Back
Top Bottom