Posts Tagged interface

Making Enums More Flexible and Extensible

Tags: , ,

Enums are great at what they do: creating a simple integer type with specific values. Their main purpose is to choose one value out of many like enum Color { Red, Green, Blue }. But what if you have data attached to those choices? What if the data is one type for one choice and another type for another choice? What if there are two pieces of data to attach to one choice and only one for another? Today’s article shows a simple pattern you can use instead of enum in these cases to get a lot more flexibility and extensibility. Read on to see how!

Read the rest of this article »

5 Comments

A Model-View-Controller (MVC) Pattern for Unity

Tags: , , , , ,

What do you do if you want to use the Model-View-Controller (MVC) design pattern in your Unity app but you don’t want to use a framework like StrangeIoC? With a little thinking about the problem I think I’ve come up with a simple yet effective pattern to follow that doesn’t require you to use any framework. In today’s article I’ll talk about each part, how the parts fit together, and how you can use MVC to cleanly organize your “pure code” app. Whether you’re an MVC newbie or just want to see a new take on MVC in Unity, you’re sure to learn something today!

Read the rest of this article »

180 Comments

From AS3 to C#, Part 13: Where Everything Goes

Tags: , , , ,

Today we continue the series by wrapping up C#’s class/interface/struct/enum system with a discussion of where to put them all. We’ll focus on package/namespace, organizing types into files, and some details of using/import.

Read the rest of this article »

2 Comments

From AS3 to C#, Part 11: Generic Classes, Interfaces, Methods, and Delegates

Tags: , , , ,

Continuing once again, today we cover an exciting new topic: generics! Have you ever wished your classes could be parameterized with a type like Vector.<Type> is? With C# generics, you can! Even better, you can parameterize your interfaces, methods, and delegates too. Read on to learn how.

Read the rest of this article »

12 Comments

From AS3 to C#, Part 2: Extending Classes and Implementing Interfaces

Tags: , ,

Let’s continue the From AS3 to C# series from last time by continuing to investigate C# classes from an AS3 developer’s point of view. Today’s article will cover class inheritance, interface implementing, and interface inheritance.

Read the rest of this article »

15 Comments

Making describeTypeJSON 50x Faster than describeType

Tags: , , , , , , , , , , ,

The hidden describeTypeJSON function is faster than the XML-based describeType function by default, but we can make it even faster. Today’s article describe just how this is done and achieves a nearly 10x speedup!

Read the rest of this article »

1 Comment

Better Ways To Check Class Inheritance

Tags: , , ,

If you want to check if one class inherits another without actually having instances of those classes, you may have read my article on Checking Class Inheritance. However, as the many comments quickly pointed out, the methods of checking this may have some flaws. There were also additional methods posted in the comments that should be added and tested. Today I’m adding them, testing them, and checking all of their validity to find the ultimate approach to check class inheritance.

Read the rest of this article »

2 Comments

Function Performance Update

Tags: , , , , , , , ,

Above all others, there is one article I refer back to most: 2009’s Function Performance. It was updated for Flash Player 10.1 and 10.2, but not 10.3, 11.0, 11.1, or 11.2. Today I’m updating this article for Flash Player 11.2, adding some missing function types, and including a set of graphs to make for the ultimate function performance reference.

Read the rest of this article »

4 Comments

Function Performance

Tags: , , , , ,

With access specifiers, statics, plain functions, and overriding, there are a lot of ways you can dress up a function in AS3. But how many programmers really know the performance implications of these options? Read on to find a straightforward test showing just that. EDIT: added functions defined in interfaces, getters, setters, and final functions.

Read the rest of this article »

48 Comments

Runnables as Function Pointers

Tags: , , ,

Last Friday’s article expressed some longing for C-style function pointers. It attempted to use AS3’s Namespace class to fake a function pointer. Unfortunately, this resulted in far slower code than simple direct access. Today’s article shows a technique that actually results in far faster code!

Read the rest of this article »

16 Comments