Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sacaldur

Member Since 25 Mar 2013
Offline Last Active Sep 14 2014 11:54 PM

Posts I've Made

In Topic: Thinking in Javascript

22 July 2014 - 08:03 AM

The main problem of many programmers is, in my opinion, the desire to do everything just like they did it in other languages. Best example: object orientation.
In JavaScript, there are no classes. The only JavaScript thing which is close to be what a class in other languages is, are the constructors. (And constructors are regular functions which are used for object instanciation elsewhere.)

While working with JavaScript, keep in Mind: there are no private members. Every member is public. (Same goes for Python: "private" members will only be translated, e. g. from "__privateMember" to "_MyClass_privateMember". Knowing this, you can still access private members, but it's evil...)
In general: instead of relying on specific types you should just use objects as if they are what you expect them to be. For at least some type safety or "method overloading" you could do some type checking, but for objects of types other than the primitive types you should just check if they provide the features (methods and/or members) you need.
This also means: you have to use inheritance much less compared to other languages.

You should definitely take a look at what closures are and what you can do using them in JavaScript. Those are used frequntly to hide implementation specific functions to keep the global context clean. (-> Anonymous function containing all library setup calls, which is called immidately.)
Also Closures are used to have some kind of private "members", but due to what a closure is, those are no members ob the object. You will run into some troubles if you want to combine it with inheritance. ;)


@gretty:
var someVariable = {"key":"value"}
This is not a map, it's an object. (You can assign values to an array usign a non numeric key as well, but it still would be an array.)

In Topic: What programming language to use?

11 September 2013 - 11:12 AM

You could try Mono (.NET for other platforms) and MonoDevelop (an IDE).
If you're familiar with C#, you might want to have a look at Unity, too. Using Unity you're able to create 3D (and also 2D, but many people doesn't like Unity for 2D) games quite fast.

In Topic: Why are static variables bad?

10 September 2013 - 03:38 PM

As soon as you have multiple universities with different unitsToGraduate values, you have to move the static variable into the university (regular member) and you should recognize: this value is a universities property.

 
Would a programmer really do something like that? Given your scenario, I would actually make the unitsToGraduate an instance variable for each instance of University class.

Aren't you saying the same thing I did?
public class University {
    private int unitsToGraduate;
    private List<Student> students;
    // no static
    
    [...]
}

public class Student {
    private String name;
    private int age;
    // no static
    
    [...]
}
 

The example I gave was demonstrated by a Stanford University professor.

I'm uncertain about the situation in other countries, but as far as I heard about you should not rely on everything IT professors are telling.

In Topic: Why are static variables bad?

09 September 2013 - 04:48 AM

Static variables has its benefits. Suppose when you want to access a method of a class without having creating the object of the class This acts as a convenience.

You want to do so when you have Code unrelated to any class or you're not able to use a non-static way (e. g. because your function does some mathematics and you're not able to extend the basic datatypes). If you're working object oriented you want to use methods and in most cases it's possible to do so. It requires a bit more time to get to a better solution and sometimes you're just using the first solution coming to you're mind.
 

A good example of a Student class using non-static and static variables would be

 

public class Student {
    
    private static int unitsToGraduate = 120;
    private int name;
    private int age;
    
    // [...]
    
}

... assuming there is only a single university or wathever the students are used by in your system. As soon as you have multiple universities with different unitsToGraduate values, you have to move the static variable into the university (regular member) and you should recognize: this value is a universities property.
That's why also this example is at last also not a good example for the usage of static variables.

In general speaking: You won't have to use static variables in most cases. And if you believe there is no other way without a static variable, there is probably still an other way. ;)

In Topic: What type of game can One person make ?

06 September 2013 - 08:11 AM

Zelda is an action adventure. (see Wikipedia or the answer on Yahoo Answers).
The main characteristic of an advantures is the puzzle solving whereas the main characteristic of an RPG is the character and it's progression in attributes and skills or the story. Since the main characteristic of Zelda is the puzzle solving (in every dungeon and between the dungeons) it's an adenvture.
The difference to classical adventure games (point&click adventures for example) is the involvement of the players skills into the puzzle solving. Thats why it's an action game - the genre is action adventure.
But I don't think this topic should be examined in this thread.

You reminded me of an other point:
I guess you (husainhz7) want to do also the game design part of your games. A rule of thumb for game designers is: the first games you make will most likely be bad so you should make them fast so you can move on to learn out of your mistakes an to make better games. It's possible to make a great game in first place but it's not very likely.
Maybe you already did some games so you don't have to bother about this...

PARTNERS