CodeBlanks Logo Icon CodeBlanks

System design

Learn the modular design of an inventory system.

Modular design

Instead of writing an inventory system as one piece, splitting it into small modules makes the work easier. Each module does only one job: storing data, managing slots, or updating the interface. This way when one module changes the others are not affected.

string veriModulu = "ItemData";
string arayuzModulu = "SlotUI";

Modular systems stay organized as they grow.

The design plan

Before starting the system a plan is needed. First decide how the data is held, then how the operations are done, and finally how the interface looks. This order sets the place of the modules.

string planSirasi = "Veri > Mantik > Arayuz";

Planning ahead prevents rewriting the code later.

Practice Record the plan

In a class named TasarimPlani, define a string adim field with the value "Veri". In the Start method, set the adim value first to "Mantik", then to "Arayuz", and print the final value joined with the text "Son adim: " using Debug.Log.

Starter code

Player.cs
using UnityEngine;

public class TasarimPlani : MonoBehaviour
{
    // string adim alanini "Veri" degeriyle tanimla

    void Start()
    {
        // adim degerini once "Mantik", sonra "Arayuz" yap
        // "Son adim: " metnini adim ile birlestirip yazdir
    }
}

Sample solution

Player.cs
using UnityEngine;

public class TasarimPlani : MonoBehaviour
{
    string adim = "Veri";

    void Start()
    {
        adim = "Mantik";
        adim = "Arayuz";
        Debug.Log("Son adim: " + adim);
    }
}

Expected output

Son adim: Arayuz

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the biggest advantage of modular design?

  • The system runs slower
  • All code is gathered in one file
  • One module changes without affecting the others Correct answer
  • More variables are needed

Explanation: Because each module does only one job, a change in one does not leak into the others.

2 Write the last step of the plan

Question
    string planSirasi = "Veri > Mantik > ____";
Answer
    string planSirasi = "Veri > Mantik > Arayuz";

Explanation: The design plan proceeds in the order data, logic and interface; the last step is the interface.

3 Design terms

Term Meaning
Modüler tasarım Splitting the system into small parts
Modül An independent part that does one job
Tasarım planı The order prepared before writing
Veri katmanı The section where information is stored

All lessons in Advanced