Tutorial [Java] Removing Static!

Discussion in 'Resources' started by Antybarrel, Jan 17, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Antybarrel

    Snip
     
    Last edited: Jan 18, 2015
  2. Offline

    teej107

    Have you even tried instantiating a JavaPlugin class?

    The reason why static gets hate is because people don't understand when it is appropriate to use it. Static is not Object Oriented Programming! Static is Class Oriented. It is best to program with OOP in mind. Let's take the Player object for example. They have a name, location, health, etc..... Those members for Player are not static. Each Player can have a different name, location and health. If those members were static, every Player would have the same name, location, and health regardless of the amount of Player objects you create because those members are shared among the Player classes.

    Speaking of OOP, you shouldn't expect that creating a new Object will contain the same values and another Object of the same class. You can't instantiate a JavaPlugin class on your own but Bukkit does. Each of the JavaPlugin classes that Bukkit instantiates have different values inside it eg: plugin name, version, description, commands, etc. If you instantiated a BukkitForumUser object and you have a method to get the user name. One object may return teej107 for that method but another object may return Antybarrel. This is basic OOP in a nutshell.

    Will you make a Java tutorial about encapsulation and how many Bukkit plugins disregard it as well?
     
    mine-care and Shawckz like this.
  3. Offline

    Shawckz

    ... You cannot have more than one instance of a JavaPlugin...
    Not to be rude, but this is a terrible tutorial and I do not recommend it to be followed for newbies.
    Sometimes, static is OK. It's never actually necessary, but it's not absolutely terrible to use.
     
    xTrollxDudex likes this.
  4. Offline

    API_Tutorials

    @Antybarrel
    You don't even follow Java naming conventions.
     
    xTrollxDudex likes this.
  5. Offline

    NonameSL

    1. You can't create more than one object of a javaplugin, instead just make Listeners have a constructor with the Main instance.
    2. Don't use UpperCamelCase (<-- example) in variable/method names, instead use lowerCamelCase(<-- example).
    3. This tutorial isn't good because it just says "STATIC IS BAD, DON'T USE IT, INSTEAD USE SOMETHING ELSE. THE END" instead of explaining why (in your opinion) static is bad, when should you use static and when you shouldn't, what is the meaning of static... If this tutorial was meant for newbies then they won't understand what you just did here.
     
    xTrollxDudex likes this.
  6. Locked, there's nothing to see anymore.
     
    teej107 and mrCookieSlime like this.
Thread Status:
Not open for further replies.

Share This Page