Could you use Minecraft to teach programming?

Tags:

There are two mods (that I’m aware of) for Minecraft which let you build computers inside the game. ComputerCraft allows you to have Lua-programmable computers and robots, with basic wired and wireless networking capabilities. RedPower 2 on the other hand has a 6502-like CPU based computers, which are programmable either using 6502 Assembly or FORTH. What if you used Minecraft …

Exceptions and abstraction

Tags:

So you already know how to handle your errors properly. Even if you’re already using exceptions, there are some nuances to the use of exceptions that are important to know and understand in order to write code that is easier to reuse and more decoupled. Let’s talk about exceptions and how they relate to your classes and abstraction.

Should a failed function return a value or throw an exception?

Tags:

You have created a nice, well written function, but you realize you forgot something: The failure case. What should a function do when it fails? There are two schools for this – the “throw an exception” school and the “return an error value” school. But which of these is the correct approach?

A simple way to make your code better: Stop adding more parameters

Tags:

You need to add some new functionality to your function or class. Let’s say you need to remove all objects stored, but optionally also call a method on them. It’s pretty simple, isn’t it? Let’s just add a parameter to removeAllObjects! If you make it true, the additional method is called, otherwise not. Except it’s not really such a good …

Is commenting your code useless?

Tags:

James Carr has written a well argumented post about comments. To sum it up shortly, he says comments are the lowest form of communication, and that commenting freshly written code is not a good idea. I tend to disagree, and here’s why.

Improving code with peer reviews

Tags:

Peer reviewing is the practice of looking at code written by others to find errors or ways to improve the code. Sometimes also called desktop reviewing, this approach can be useful for various reasons: If you have a coworker who is more experienced than you, you can learn from him/her It’s often helpful to have another set of eyes take …

Food for thought: utilizing models in MVC

Tags:

“What is a model” and “Is Zend_Db_Table a model” seem to be asked once in a while on #zftalk. Frameworks say they have a full model available, thus they are MVC frameworks ORM libraries say they generate models. It seems the ActiveRecord pattern has become somewhat synonymous with model. Pádraic Brady wrote an excellent post on how models are misunderstood, …

Base classes in OOP programming languages

Tags:

David Otton posted a short but thought-provoking post about stdClass, which many think is the “base class” all PHP classes automatically inherit from. I have to admit that I had this misconception as well. On the other hand, “true” OOP languages such as C# and Java both have a base class which all other classes inherit, even if you don’t …