Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 2129 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.
Online 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 opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« 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 Ninja


Medals: 62
Projects: 3
Exp: 5 years


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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!