DRY and OOP

4

Stats

2,041 visits, 2,684 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 28 Aug, 2019.

If you've ever worked on big programming projects using modern languages before, you probably know what these mean, and save yourself some time: Skip ahead.

If you're wondering why I'm telling you to stop being wet, then read along.

DRY: Don't Repeat Yourself

DRY is a very important, yet very simple concept in programming: If you every need to run a bit of code twice at two different places, make it common.

The rule is simple: Don't repeat yourself. You have an enemy that throws arrows and snowballs? Make a common throwing code bit and make both your features use it.

A very common mistake among younger programmers is to just copy paste code around everywhere they need it.

Even if you didn't know about this rule, you might still see how it can be useful.

It makes code easier to read, maintain and update

So please use functions.

OOP did I say

functions?

OOP. Object Oriented Programming. Everything is an object and you can create a multitude of small objects that all inherit from one big object: That's the class system. Classes are the best modern way to efficiently write game code.

Good thing Construct doesn't have classes :D. Construct has families though! I made a whole article already on how to properly use them to simulate a class like behavior using events, so read through this if you didn't do it already: https://www.construct.net/en/blogs/skymen-13/optimal-write-events-construct-1049

Next Tutorial In Course

  • 0 Comments

Want to leave a comment? Login or Register an account!