When to Use Inheritance: A Wide Brush Approach

Inheritance is a fundamental concept in virtually any language which supports object-oriented programming. How inheritance works varies between languages, but virtually all languages with an object-oriented class system support it in some form. While most programming materials will teach you how to use inheritance, they don’t really touch on when it ends up detrimental to coding.

Inheritance is a tool in a programmer’s toolbox just like any other feature of a language.… Read the rest

Why Should You Use Lua?

Lua is an extremely powerful interpreted language. It is most well known for its use in API’s (Application Programming Interface). From World of Warcraft to Kaseya’s VSA, all sorts of applications in different industries rely on Lua to make things work. Lua is almost everywhere, but is still relatively unknown.

Lua is more than just a language for API’s, it excels as a programming language in its own right.… Read the rest

Getting Classy With Inheritance In Lua

We’re going to cover the basics of inheritance in Lua. Lua doesn’t have native classes, so don’t expect things like multiple inheritance or similar to be practical. I basically have never used inheritance in Lua in any serious capacity outside of very few specific situations.

We’re going to cover basic inheritance using the default “class system” in Lua, how to add functions, and how to override functions.… Read the rest

Lua OS Library

We’re going to go over the default OS library included in Lua. This library is very useful, but is also platform specific. What works on one OS may not work on another.

Once you start using an OS library, you run the risk of your code losing portability. If you use a clock or the time for a random number seed, it’s not going to impact your program (except possibly cryptographic functions), but how do you get a list of files in a directory?… Read the rest

Lua Math Library

This section is more of a reference to how to use the math library in Lua. We aren’t going to go too into depth for each function. The math library can be divided up into several different classes of functions. We have rounding, trigonometrical, etc.

Math Constants

ConstantDescription
math.hugeInfinity
math.maxintegerThe biggest integer
math.minintegerThe smallest integer
math.piA constant for Pi

Math Functions

Conversion and Rounding

FunctionDescription
math.abs(
Read the rest

Improving Code Documentation

The debate between whether to use comments or to write self-documenting code has raged on for ages. Both approaches are equally valid, but each has its own advantages and disadvantages depending on the circumstances. Comments can be as much of a hindrance as a help in the wrong conditions, and self-documenting code can be opaque and unwieldy in others.

Self-documenting code tends to be quicker, but comments add clarity for usage and intention.… Read the rest