Jump to content

  • Log In with Google      Sign In   
  • Create Account


Mikea15

Member Since 05 Dec 2008
Offline Last Active Today, 03:48 AM
-----

Topics I've Started

Constructor Chaining Order to Parameters or Parameterless.

06 April 2014 - 10:54 AM

Hello.

 

So I've been dwelling on this topic today. Which is, which way do you want to chain your constructor.

 

Say you have a basic BaseMap class.

public class BaseMap
{
    protected int _height;
    protected int _width;

    protected Node[,] _map;

    public BaseMap()
    {
        _width = 0;
        _height = 0;
        _map = null;
    }

    public BaseMap(int width, int height)
    {
        _width = width;
        _height = height;
        _map = new Node[_width, _height];

        for (int x = 0; x < _width; x++)
        {
            for (int y = 0; y < _height; y++)
            {
                _map[x, y] = new Node(x, y);
            }
        }
    }
}

Now my question is, how you chain the constructors? So far, I've been chaining them this way:

public class BaseMap
{
    protected int _height;
    protected int _width;

    protected Node[,] _map;

    public BaseMap()
    {
        _width = 0;
        _height = 0;
        _map = null;
    }

    public BaseMap(int width, int height) 
        : this( )
    {
        _width = width;
        _height = height;
        _map = new Node[_width, _height];

        for (int x = 0; x < _width; x++)
        {
            for (int y = 0; y < _height; y++)
            {
                _map[x, y] = new Node(x, y);
            }
        }
    }
}

But I've searched online and found people where chaining the other way around. Like this:

public class BaseMap
{
    protected int _height;
    protected int _width;

    protected Node[,] _map;

    public BaseMap()
        : this( 10, 10 ) // default values
    {

    }

    public BaseMap(int width, int height) 
    {
        _width = width;
        _height = height;
        _map = new Node[_width, _height];

        for (int x = 0; x < _width; x++)
        {
            for (int y = 0; y < _height; y++)
            {
                _map[x, y] = new Node(x, y);
            }
        }
    }
}

So, from what I understand, people are instantiating with default values, when calling the default constructor, leaving it empty. My Approach was to start with the constructors with parameters, and call this( ) to instantiate variables, before getting into the parameter constructor's body. This particular example isn't the most obvious tho, but say you have a node with edges.

public Node( )
{
	Adjacents = new List<Node>();
	State = EnumNodeState.UNKNOWN;
}

public Node( int x, int y )
	: this( )
{
	PosX = x;
	PosY = y;
}

This makes sense, right? I instantiate the List and state, then define position, when calling Node( 10 , 10 );
Is it 'better' to do it the other way around?

 

Thanks. smile.png


Master Thesis Theme and Inspiration Needed

17 September 2013 - 02:43 AM

Hello, I'm Michael. I'm a game developer, at least I want to be. I'm currently finishing my MSc in Computer Science and Engineering. I'm in my last year, and I need to make a thesis, but the thing is, I'm really undecided.

 

I like making video games, I've been making small demos and games since I know how to program. I finished only 2 or 3 minigames in the large number of projects I've started, mostly due to lack of time and school. But I'm about to release a game for Android/iOS/WP8 next month, so hopefully that will change :)

 

To be honest, all the themes our teachers give us here for our thesis, suck. I want to do something else than a "Casual Game for iPhone". And I don't want to make something that would take 1 month to make, if you know what I mean. That said, I want something new and challenging.

 

What I would like to know is what are the trends the gaming industry is going to? Where could I make a difference?

 

What I know, What I do, what I like.

  • Work with Hardware device Microsoft Kinect. ( 3 years )
  • Work with Unity3D ( 1+ year )
  • I like Computer Graphics ( not much experience, but not afraid to learn )
  • I like making video games
  • I love planning video games.
  • I've played a little with Augmented Reality ( Qualcomm Vuforia )

So far, I'm more experienced with C#, but I know C++. I also know some OpenGL / OGL ES.

 

So based on that, I'd gratefully accept your help in my "quest" in finding a good master thesis. In Computer Graphics, Video Games, or even Artificial Intelligence, just as long as I can use that in video games as to not loose interest and stay motivated through the end.

 

So basically, what are the trends? Where is the industry lacking? Where could one technology be helped? What could be optimized? 

 

Thank you. :)

 

PS: Also, I'm from Portugal :) Cheers.


PARTNERS