Discuss Procedural / OOP

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Boboo99

Scrub
Dank Tier VIP
Fleep Tier Donator
Feb 20, 2016
469
12,178
44
Hey guys, so I had some heartbreaking discussions with cNoEvil where he screamed at me and told me that he will kill me, you know the usual toxic-11year-old bullshit :kreygasm:

So the topic I want to discuss with you guys, procedural or object oriented style of coding, what are u prefering and why?
I have seen alot of procedural code in C# and less OO code, is there any special reason for it?

I will just put here two examples which do the same but are written in a diffrent way, to make my point more clear :fleep:

C#:
class Program
    {
        static void MakeCat()
        {
            Console.WriteLine("The cat does: Miauuu");
        }

        static void MakeDog()
        {
            Console.WriteLine("The dog does: Wufff");
        }

        static void MakeFrog()
        {
            Console.WriteLine("The frog does: Quack");
        }

        static void MakeHuman()
        {
            Console.WriteLine("The human does: I am a fag");
        }

        static void MakeNoob()
        {
            Console.WriteLine("The noob does: You are noob");
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Which animal do you want to hear?");
            switch (Console.ReadLine())
            {
                case "cat":
                    MakeCat();
                    break;
                case "dog":
                    MakeDog();
                    break;
                case "frog":
                    MakeFrog();
                    break;
                case "human":
                    MakeHuman();
                    break;
                case "noob":
                    MakeNoob();
                    break;
                default:
                    Console.WriteLine("No one found");
                    break;
            }
            Console.ReadKey();
        }
    }
C#:
abstract class Race
    {
        public abstract void Make();
    }

    class Cat : Race
    {
        public override void Make()
        {
            Console.WriteLine("The cat does: Miauuu");
        }
    }

    class Dog : Race
    {
        public override void Make()
        {
            Console.WriteLine("The dog does: Wufff");
        }
    }

    class Frog : Race
    {
        public override void Make()
        {
            Console.WriteLine("The frog does: Quack");
        }
    }

    class Human : Race
    {
        public override void Make()
        {
            Console.WriteLine("The human does: I am a fag");
        }
    }

    class Noob : Race
    {
        public override void Make()
        {
            Console.WriteLine("The noob does: You are noob");
        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, Race> dic = new Dictionary<string, Race>()
            {
                {"cat",new Cat() },
                {"dog",new Dog() },
                {"frog",new Frog() },
                {"human",new Human() },
                {"noob",new Noob() }
            };

            Console.WriteLine("Which animal do you want to hear?");
            try
            {
                dic[Console.ReadLine()].Make();
            }
            catch (Exception)
            {
                Console.WriteLine("No animal found");
            }
            Console.ReadKey();
        }
    }
PS: I do know these are just paradigms and after a while everyone has his own style where he uses what but how to say I am just curious :)
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,295
37,938
269
2 because less pollution and more readily organized
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods