Code Cleanup?

Post Reply New Topic
RELATED
PRODUCTS

Post

So I my progress with Java development I noticed some of my data was becoming stale on a console restart or reloading the scripts with the gui.

Is there a recommendation for what I should put in cleanup? Should I destroy all my objects and data on exit()? Or should I just re-initialize them in init()?
----------------------------------------------------------------------
http://instagram.com/kirkwoodwest/
http://soundcloud.com/kirkwoodwest

Post

In general, there is no need for memory cleanup in Java. But if you have open files, streams etc. you need to close them. But with a "normal" controller extension there should be no need to cleanup anything.

What do you mean by "stale data"?

Again: Learn Java first :-)

Post

moss wrote: Thu Oct 01, 2020 8:24 am In general, there is no need for memory cleanup in Java. But if you have open files, streams etc. you need to close them. But with a "normal" controller extension there should be no need to cleanup anything.

What do you mean by "stale data"?

Again: Learn Java first :-)
i am learning it :)

yes... seems its possible to have data from a a static class and static variable in that class. the class is never unloaded fully on reload. so i had some indexes there that were not resetting. basically my singleton implementation sucked so i fixed it. this is how i learn it
----------------------------------------------------------------------
http://instagram.com/kirkwoodwest/
http://soundcloud.com/kirkwoodwest

Post

6 Reasons Why You Should Avoid Singletons:
https://www.davidtanzer.net/david%27s%2 ... etons.html

:D

Post

moss wrote: Thu Oct 01, 2020 10:56 am 6 Reasons Why You Should Avoid Singletons:
https://www.davidtanzer.net/david%27s%2 ... etons.html

:D
Oh man thanks for sharing this! too good... "A little more than a decade ago, I used singletons a lot. " ... well, its been more than 15 years since I studied Java... :D Also while learning Java and developing some software in ActionsScript for a company I spent months writing the worst architected program in my life. I was passing the same objects through hundreds of constructors over and over that could have been resolved with a simple set of globals or a Singleton class.

When I got to Volition everything changed for me and our process was much more on the level of just find ways to keep it simple and get the work done. It was more important that lower level systems had stronger architecture than the higher level systems like gameplay or interface which is what I focused on.

When it comes to code seperation like (Model/View/Controller) this is something I never really fully grokked in practice. Sometimes it just makes more sense to group many parts together... and avoid code seperation because it can be unneccessary. For example you could write a simple controller script in the API in two Java Classes(what gets spit out of the help auto-generate script).. It would be totally functional and readable.

Maybe someday I could convince you to help me via a code review, I would learn a lot and you could have a laugh. :ud:
----------------------------------------------------------------------
http://instagram.com/kirkwoodwest/
http://soundcloud.com/kirkwoodwest

Post Reply

Return to “Controller Scripting”