Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:10:21+00:00 2026-06-09T21:10:21+00:00

Background : I am having a discussion with a friend regarding the correct way

  • 0

Background:

I am having a discussion with a friend regarding the correct way to refer to elements within a 2D array for something I’m designing. I was unhappy with using XNA’s Point and Vector2 structs as array references because the properties of them are labelled X and Y.

I created my structs for these, ArrayPoint and ArrayVector2 and called my own properties I and J. My friend thinks this is a massive waste of time, however, I do not like swapping the X and Y references because my maths background has always taught me to use i and j for matrices, e.g using myArray[i, j] instead of myArray[y, x].

What is the best way to deal with this situation?

Is it simply a case of swapping x and y? Or creating your own structs to deal with it how you like? Is it all down to personal preference since this is pretty much all arbitrary anyway?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:10:22+00:00Added an answer on June 9, 2026 at 9:10 pm

    Listen to your friend!

    There are so many reasons this is a bad idea, here are a few:

    • Your maths background may say i and j. But for arrays that map into 2D space (eg: a tile map, as opposed to a matrix) then x and y are actually preferable as they convey semantic meaning that makes your code easier to understand. (ie: you have X and Y axes, not I and J).

    • (Usually the cases where i and j make more semantic sense, you won’t be storing the indexers in a struct anyway – they’ll just be temporary locals.)

    • Without a genuine reason, less code is always preferable to more code. Writing and testing code takes up valuable time. Using someone else’s code (like the built-in XNA types) saves you time.

    • One day you might write some utility function that takes a Point. If you have two versions of Point then you could well end up with two versions of that function. More code and, worse still: duplicate code!

    • “Not Invented Here” is a really, really, really bad habit to get into as a programmer. Learn to live with other people’s code (as long as it works – which, in this case, it does).

    • No one else does this. Your code is going to confuse and annoy everyone who tries to work with it.

    • Small performance hit needlessly copying things around. (Plus a few other esoteric things that will have a minor affect on performance.)

    (Also: indexing into an array with a Vector2 (floating point) is kinda weird.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems trying to get a background upload system working using WebWorkers
Background I'm having a bit of trouble finding out just how to programmatically post
The background: I'm having some problems with Thoughtbot's Factory Girl gem, with is used
Having a background in Java, which is very verbose and strict, I find the
If I have a background thread and having Join to wait for completing background
I am coming at Javascript from a classical OOP background and am having trouble
As a newbie to Python, and mainly having a background of writing scripts for
Am having a problem setting the gradient background of the selected listviewitem. Everytime I
I am having trouble getting a background-image to overlay the border of another div.
I am having a problem setting the background of UITableView to a UIImageView (see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.