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!

What kind of programming style is that?

I've created a style of programming that basically goes that way: Every function is a class, and the procedures inside it are transformed into functions. The (parameters, variables, and results of expressions) of the expressions and functions of the function are stored as variables inside the class, including what would be the returning value of the function, and the class has a default function inside it which represents the function it represents which "compiles" all the features of the class other than it thereby producing the function is supposed to return. If a function is supposed to be called outside it, it has to be called through a object instantiation of it (would it be correct to call it a sort of "module import"?), so the program would function apparently like something which reminds me of Java. Here is an example. The first class represents a function which basically simulates whether an event with A chances of B chances of happening has happened. The second class shows how it "imports" the class event by instantiating an object of the class event and then extracts the result of the function by calling the function Call inside the class event object instantiation and then getting the variable $ComparisonResult which represents the returning value of the function. What type of programming style is that? Object-Oriented-Programming? Class oriented programming? Furthermore, could you please describe in "fancy" programmer terms what the code does and give comments about the code if any, like things I could improve?

Code:
Class Event
    {
    #Class Parameters
    $NumberOfPossibilities;
    $NumberOfChances;
    #Class Variables   
    $AttemptResult;
    #Class Returning Variable
    $ComparisonResult;
    Compare()
        {
        $this.ComparisonResult = $this.AttemptResult -lt ($this.NumberOfChances+1);
        }
    GenerateAttemptResult()
        {
        $this.AttemptResult = Get-Random -Maximum ($This.NumberOfPossibilities+1);
        }
    Call()
        {
        $this.GenerateAttemptResult();
        $this.Compare();
        }
    }


Class TwoEvents
    {
    #Importing Event Class Through Event Class Object Instance:
    $Class_Event = [Event]::New()
    Call()
        {
        #Event 1 has 1 in 2 chances of happening
        $Class_Event.NumberOfChances = 1;
        $Class_Event.NumberOfPossibilities = 2;
        $Class_Event.Call();
        $Event 1 = $Event.ComparisonResult;
        #Event 2 has 2 in 5 chances of happening
        $Class_Event.NumberOfChances = 2;
        $Class_Event.NumberOfPossibilities = 5;
        $Class_Event.Call();
        $Event 2 = $Event.ComparisonResult;
        }
    }
 
Back
Top Bottom