Author Topic: Question on nesting [Ruby]  (Read 6273 times)

SarahW

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
    • Email
Question on nesting [Ruby]
« on: November 10, 2018, 10:09:32 PM »
Is nesting your source code generally considered bad practice? When looking at the source of other games, it seems like nesting is more common than I realized.

I often use classes and sub classes, rather than nesting, as that tends to flow most similarly to the original language I'm used to for Renpy. When I was designing Terminal Shooter, I was deliberately avoiding nesting if I could. After a point, is nesting unavoidable?

Right now, i'm wanting to do more of a Hacklike with espionage/stealth elements. But struggling with logistics at the moment.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Question on nesting [Ruby]
« Reply #1 on: November 11, 2018, 07:45:09 AM »
Nesting is "bad practice" in a sense that it can make the source code more difficult to read. But other than that it's not that important. I guess in theory it can be easier to produce bugs with code that is less readable and confusing, which is often true. That said the compiler doesn't care about the way you structure the source code. If the game works as intended the source code has done its job, no matter how bad it is. I would say most source code ever written for games are from medium to extremely poor quality, because game developers seem to be bad programmers for whatever reason.

SarahW

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
    • Email
Re: Question on nesting [Ruby]
« Reply #2 on: November 11, 2018, 09:37:55 AM »
Cool, well it does seem to work as intended.

Made a simple game of navigate, and be followed by pet.

The main change is variables instead of booleans to determine navigation routes.

The error codes in Ruby legitimately needs to be rewritten to be more understandable. As it makes figuring out exactly what my error is impossible at times. I don't get many errors anymore, so there really isn't a very good reason for software not to point to a specific issue on a specific line.
« Last Edit: November 11, 2018, 09:39:42 AM by SarahW »