Esrup / Antflow

Is no longer being developed
https://www.draftlab.dk/
MIT License
20 stars 1 forks source link

Feedback for code #2

Open mariuszhermansdorfer opened 4 years ago

mariuszhermansdorfer commented 4 years ago

Hey @Esrup, great initiative to open source the plugin!

You asked for some suggestions to your code, so here it comes :)

It is generally a good idea to make your class variables private and add some checks before changing their values. You would typically do this with getter/setter methods. Here, I have changed the g variable for you. Also, note the upper and lowercase naming convention. Public variables -> Uppercase, private -> lowercase

namespace Antflow
{
    class A_star
    {
        public A_star Parent;
        public Point3d Position;

        private double g;

        public double G 
        {
        get { return g; }

        set 
        {
            if (value > 0)
                g = value;
            else 
                g = 0;
        }
    } 

        public A_star(A_star parent, Point3d position)
        {
            Parent = parent;
            Position = position;
        }
    }
}  
Esrup commented 4 years ago

Thank you @mariuszhermansdorfer I appreciate it! I'll do a clean up of the code to follow the standards and follow your suggestion with private classes

Sonderwoods commented 4 years ago

You can also use:

public int Name { get => name; set => name = value; }

Takes up less space.

ons. 7. okt. 2020 11.52 skrev Esrup notifications@github.com:

Thank you @mariuszhermansdorfer https://github.com/mariuszhermansdorfer I appreciate it! I'll do a clean up of the code to follow the standards and follow your suggestion with private classes

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Esrup/Antflow/issues/2#issuecomment-704825795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDLJYXNL5TNIANM2TW37LSJQ25LANCNFSM4SG7BBWA .

Sonderwoods commented 4 years ago

Bad example of me, as you'll use string for a name, but you get the point! :D

ons. 7. okt. 2020 19.55 skrev Mathias Sønderskov < sonderskovmathias@gmail.com>:

You can also use:

public int Name { get => name; set => name = value; }

Takes up less space.

ons. 7. okt. 2020 11.52 skrev Esrup notifications@github.com:

Thank you @mariuszhermansdorfer https://github.com/mariuszhermansdorfer I appreciate it! I'll do a clean up of the code to follow the standards and follow your suggestion with private classes

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Esrup/Antflow/issues/2#issuecomment-704825795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDLJYXNL5TNIANM2TW37LSJQ25LANCNFSM4SG7BBWA .