{
  "id": "enwiki-001352397558",
  "slug": "god-object",
  "title": "God object",
  "qid": "",
  "lead": "In object-oriented programming, a god object (sometimes also called an omniscient or all-knowing object) is an object that references a large number of distinct types, has too many unrelated or uncategorized methods, or some combination of both. The god object is an example of an anti-pattern and a code smell.",
  "body": "In object-oriented programming, a god object (sometimes also called an omniscient or all-knowing object) is an object that references a large number of distinct types, has too many unrelated or uncategorized methods, or some combination of both. The god object is an example of an anti-pattern and a code smell. import std; using std::string; using std::vector; class GameManager { private: vector players; int score = 0; bool running = false; public: GameManager() = default; ~GameManager() = default; void addPlayer(const string& name) { players.push_back(name); std::println(\"Added player: {}\", name); } void listPlayers() const { std::println(\"Players:\"); for (const string& p : players) { std::println(\" - {}\", p); } } void startGame() { running = true; score = 0; std::println(\"Game started!\"); } void updateGame() { if (running) { score += 10; std::println(\"Score updated: {}\", score); } } void endGame() { running = false; std::println(\"Game over! Final score: {}\", score); } void draw() { std::println(\"[Rendering Game Screen]\"); } void handleInput(const string& input) { if (input == \"quit\") { endGame(); } else if (input == \"score\") { std::println(\"Current score: {}\", score); } else { std::println(\"Unknown input\"); } } void saveGame() { std::println(\"Saving game state to disk...\"); } void loadGame() { std::println(\"Loading game state from disk...\"); } void run() { // ... } }; Instead, this could be more appropriately divided among separated responsibilities: import std; using std::string; using std::vector; class PlayerManager { private: vector players; public: PlayerManager() = default; ~PlayerManager() = default; void addPlayer(const string& name) { players.push_back(name); std::println(\"Added player: {}\", name); } void listPlayers() const { std::println(\"Players:\"); for (const string& p : players) { std::println(\" - {}\", p); } } }; class GameLogic { private: int score = 0; bool running = false; public: GameLogic() = default; ~GameLogic() = default; void startGame() { running = true; score = 0; std::println(\"Game started!\"); } void updateGame() { if (running) { score += 10; std::println(\"Score updated: {}\", score); } } int getScore() const noexcept { return score; } void endGame() { running = false; std::println(\"Game over! Final score: {}\", score); } }; class Renderer { public: Renderer() = default; ~Renderer() = default; void draw() { std::println(\"[Rendering Game Screen]\"); } }; class InputHandler { private: GameLogic& logic; public: explicit InputHandler(GameLogic& logic): logic{logic} {} ~InputHandler() = default; void handleInput(const string& input) { if (input == \"quit\") { logic.endGame(); } else if (input == \"score\") { std::println(\"Current score: {}\", logic.getScore()); } else { std::println(\"Unknown input\"); } } }; class SaveSystem { public: SaveSystem() = default; ~SaveSystem() = default; void saveGame() { std::println(\"Saving game state to disk...\"); } void loadGame() { std::println(\"Loading game state from disk...\"); } }; class GameManager { private: PlayerManager players; GameLogic logic; Renderer renderer; InputHandler input(logic); SaveSystem saves; public: GameManager() = default; ~GameManager() = default; void run() { // ... } };",
  "categories": [
    "106844734",
    "23118434",
    "23214813",
    "23603337",
    "23617849",
    "24745114",
    "27177379",
    "43573932"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1352397558",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1777844969.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001352397558",
    "type": "webpage",
    "title": "God object",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/god-object",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          21
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          21
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001352397558",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1352397558",
    "note": "Immutable snapshot enwiki-001352397558"
  }
}