Avoiding redundant code at all cost?

For OOP, hopefully each class holds its own variables and hopefully they are not all accessible by getters and setters as that would break encapsulation and expose class internals.

Then you would even more build an architecture from object composition instead of inheritance.
Can’t see the relation to redundancy here, maybe I just don’t get what you mean.

I don’t know any convention leading to heap space errors or generally slow code.

I think the only thing that is to be avoided at all cost is gasp that the paying user/player runs into a bug.

Anything else affecting your code should be avoided, but never at all costs. Trying to refactor an existing codebase into a better design, over and over again, is exactly the reason the developers on this forum are barely productive. We have so few finished game releases per month that it’s a bit shameful. Sometimes not having a fancy IDE is what makes you productive, because you simply have to move on with what you have and you just want to get it over with. The next game will have a better design, not this one.

+1 to this. There’s always a better way of doing something. It’s an endless cycle. Where do you stop?

Seconded.

As suggested earlier I’ve just stop trying to make it “pro” and start to use THE, or more like, MY easy way to code things, mainly to have at least different steps working for the game. Let me tell you that it works like a charm, not really a professional code but meh, it works, and more importantly I start to have fun again while coding.

( that awkward feeling of being stuck… I almost missed the time under Game Maker at some point, things seems more “easy & fun” to code script )

Regardless of your skill, you’ll always look back at three year old code, and wonder what the hell you were thinking. Striving for perfection should be postponed indefinitely. Now get back to writing code making games, folks!

I look at code I’m typing and think: “This is the worst thing on the planet…oh well, next”.

I admire your discipline.

When I started with Java, I think it was on Java 1.4. I thought the class structure was awesome and attempted to solve every by just using Objects. However, when you go crazy with the idea and try to make simple things, like each car in a busy street, its own object. You end up with 1000 objects and code that ends up breaking down at the seams.

My definition of redundant code is variables and functions within a class that are written over and over if you can obviously use a loop, or functions that repeat from class to class that are not conventionally used. I like inheritance and extending code a lot, but it ends up a lot of times giving me functions with empty brackets.

I think you have a valid point Riven.

However, the people who come looking for help in a gaming development forum come for ideas on how to make their game code better. The most interesting part about JGO is that it is one of the best Java development forums even if you are not doing gaming. Eventually, they will end up trying the code that makes the code run better, and head toward re-factoring perfection.

I believe the community should strive to help users within the confines of the framework they are in. If a user in working in Java2D, help him/her make the program in Java2D. Don’t try and tell them to convert to Slick2D or LWJGL. Same for those users working with Slick2D, we shouldn’t try to convert them to LibGDX. If they had a problem grasping the concept within Java2D, changing to a new framework (or language) is going to cost them even more time. The saddest part is the problem they had in the first place will just follow them to the new framework. (It is the same reason why it doesn’t make sense to fix a bug by changing from Java to Python.)

Creating games is another layer of difficulty beyond just being a good programmer who is using the right tools. We really have some really powerful tools when it comes to game development on this forum. However, the key to building any structure is knowing what tools would get the job done. Do you need 1000 FPS and 3D graphics to develop Pong, for instance? Probably not, so why over-complicate it.

I realize all programmers are good at building tools. We like to have classes that do specific tasks and do them well. Somewhere in all of that, we lose the ability to convert the tools we write into games. We feel that since we spent “X hours” on this tool, it has to fit in the game somewhere. We never sit down and ask ourselves, “What is the core idea of this game? What is my game about?”

If we did that more often, we’d realize that our code is expendable. That we don’t have to use every single tool we write (or every framework we come across). We would realize that trying to fit a square peg into a round hole is a big waste of time.

You write code to build your game. You don’t write games around your code.

Building games is the ability to realize that your code isn’t perfect. You will have to dump code to get your game running. If your code looks like an unreadable jungle, keep going and hacking away at it. No one gets it right the first time. As a gaming community, I wish that this notion was the defining factor… but, I think we are just way to preoccupied for writing the best tools to get any real games done. :stuck_out_tongue:

I wonder if it isn’t that which is slowing game developers? Or at least hobbyists.

I mean, so far, I’ve been struggling to make several tools, supposedly to help me building my engine, supposedly*2 to make the game easy to create in the end.
But I may admit that sometimes, you’re just not motivated.
Having a tool isn’t necessarily a step in the game creation, so when I’m stuck on on I just feel like I’m not progressing and start to lose interest gradually over it.

Well, since I already went over that part using Game Maker (still, making the tools was funny because it was like creating a game for a game), I know that this kind of pain is definitely worth it. But sometimes, the motivation is just not here, so you just end up browsing JGO or playing games instead of making them ;D

Not discipline…self awareness. The vast majority of the time the temptation to re-write, do fancy stuff, etc, in my case would only serve the purpose of proving to myself how clever and/or knowledgeable I think I am about coding. SO, instead I do nothing and pat myself on the back for how clever and/or knowledgeable I think I am about about getting stuff done. Scratch the same-ish itch in a different way and in less real-time.

Yes, we are not very productive. But that is because lots of the people here are still learning Java game programming and need to know what works and what doesn’t. Therefore, they will go through a lot of refactoring and restarting until they get something that works. Then, at a certain stage, they will realise their capabilities and resources and settle down on a project that they can achieve and that they find fun. (I myself just reached this stage a few weeks ago then I started Far From Home)

My ideas on the types of people using these forums:

  • n00bs who aren’t trying hard to learn and are looking for code to copy-paste. Then they quit programming because something goes wrong and everyone tells them to fix it themselves but they can’t because they don’t know what’s wrong
  • n00bs creating n00b magnet projects which fail right away for obvious reasons…
  • n00bs who are trying hard to learn, and progressing
  • Amateur developers who are working on some of their first real projects
  • Professional developers who are working, and working, and working…
  • People that create Awesome code with epic performance (that is of no use to anybody) because they can

Half of the types of people are n00bs. Two Thirds of the types of n00b are wasting everyone’s time. :emo:

(Do unused imports count as redundant code? Because I spend a lot of time removing those as Eclipse gets carried away sometimes)

“At all cost” ?

No. But once you start cursing your code because you missed to update a few of the 17 copies of the code block in question during a bugfix, and the bug still exists in some of the copies, you might want to consider having less redundant code to make bug fixing easier. (Not to mention finding all the copies in first place …)

Unlike some of the previous posters I believe that OOP makes it even easier to have less redundant code, but I agree that for performance it sometimes is better to have redundant code. You’ll have to find a middle way that works for your project. If development starts hurting, you know you have too little/too much redundancy ;D