Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Is It Okay To Static-ify Random?  (Read 7582 times)
0 Members and 1 Guest are viewing this topic.
Offline wookoouk

Senior Newbie

« Reply #30 - Posted 2013-10-21 20:21:23 »

What i mean by static println is: I read through someones github code a few days ago and there was a static method called println(String input), that just shortened 'System.out.println'. Its pretty pointless, much like a static Random(). Just create one, use it as much as possible and where not possible create another. Again, I am sure this is bad practice but it works for me.
Offline Cero
« Reply #31 - Posted 2013-10-21 20:30:58 »

Now I avoid it if possible like the plague.
You are just doing this because you learned it that way, which isn't wrong, but game code is special...
Look at libgdx how much of it is static. Intersection checks, file operations, graphic calls, audio calls. LWJGL too of course
In game dev, static/global has a lot of value if you wanna be productive

Offline wookoouk

Senior Newbie

« Reply #32 - Posted 2013-10-21 20:35:38 »

I am getting into static code more and more, (never used it 6 months ago).

Most 'utility' code in my new game is static and I have found it VERY useful to do so. such as my method for getting 'real' mouse position (camer.unproject() etc from libgdx).

I am picking up the importance of static code and instantly seeing the benefits.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Opiop
« Reply #33 - Posted 2013-10-21 21:11:00 »

Well, of course. Static for utility methods is a godsend. Everything else, pretty much no.
Offline ags1

JGO Kernel

Medals: 356
Projects: 7

Make code not war!

« Reply #34 - Posted 2013-10-21 21:53:01 »

On my website, a lot of the code is static. The reason is that I get all the google app engine objects from factories and I have no idea when or how long I can keep references to those objects, so my code is all pretty much stateless static, except for the objects in my data model, which are throwaway instances. If I want to retain a reference to something, I use a stateless static method and the memcache service to store a default return value. There's a better way to do it, I'm sure, but I don't have the time or energy at midnight to figure it out.

Pages: 1 [2]
  ignore  |  Print  

Ecumene (150 views)
2017-09-30 02:57:34

theagentd (225 views)
2017-09-26 18:23:31

cybrmynd (302 views)
2017-08-02 12:28:51

cybrmynd (290 views)
2017-08-02 12:19:43

cybrmynd (298 views)
2017-08-02 12:18:09

Sralse (291 views)
2017-07-25 17:13:48

Archive (979 views)
2017-04-27 17:45:51

buddyBro (1104 views)
2017-04-05 03:38:00

CopyableCougar4 (1681 views)
2017-03-24 15:39:42

theagentd (1431 views)
2017-03-24 15:32:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!