※当サイトの記事には、広告・プロモーションが含まれます。

オブジェクト指向の定義を調べてみた

www.itmedia.co.jp

⇧ 設定ミスとか気付きにくそう...

オブジェクト指向の定義を調べてみた

Wikipediaさんによりますと、

オブジェクト指向は「objects」として表されるって仰っていて、

In computer science, an object can be a variable, a data structure, a function, or a method. As regions of memory, they contain value and are referenced by identifiers.

https://en.wikipedia.org/wiki/Object_(computer_science)

In the object-oriented programming paradigmobject can be a combination of variables, functions, and data structures; in particular in class-based variations of the paradigm it refers to a particular instance of a class.

https://en.wikipedia.org/wiki/Object_(computer_science)

⇧ う~む、いまいち、よう分からんけど、「オブジェクト指向〇〇」という形で、「オブジェクト指向」には領域が複数あるっぽい。

何の領域における「オブジェクト指向」の話なのかは、事前に確認しておかないと訳の分からないことになりそうね...

プログラミング言語の領域では、

Object-based languages

An important distinction in programming languages is the difference between an object-oriented language and an object-based language. A language is usually considered object-based if it includes the basic capabilities for an object: identity, properties, and attributes. A language is considered object-oriented if it is object-based and also has the capability of polymorphisminheritanceencapsulation, and, possibly, composition.

https://en.wikipedia.org/wiki/Object_(computer_science)

⇧ 上記によりますと、

  • Object-oriented language
    • polymorphism
    • inheritance
    • encapsulation
    • possibly composition
    • Object-based languages
      • object
        • identity
        • properties
        • attributes

⇧ のような特性で定義されており、

⇧ の4つを利用していることが「オブジェクト指向言語」ということになるっぽい。

上記の4つの特性を利用している場合は、「オブジェクト指向」と言って良いということになるんでしょうかね?

上記の4つの特性の内、1つでも使われていたら、それは「オブジェクト指向」を利用していると言って良いと仮定してみると、知らず知らずのうちに「オブジェクト指向」を利用していることもありそうということですね。

そして、Javaを使っている場合、フレームワークとか使ってたら確実に「オブジェクト指向」を利用していることになるってことな気がする。

まぁ、そもそもが、Javaの標準APIが「オブジェクト指向」を利用してるっぽいから、Javaで開発する場合は「オブジェクト指向」を利用していくのが自然な気もするかな。

docs.oracle.com

stackoverflow.com

Javaは互換性を考慮してるって話だし、互換性の切り捨てをしない限り「オブジェクト指向」から抜け出せなさそうではありそう。

2023年2月25日(土)時点のWikipediaの情報だと、

Many of the most widely used programming languages (such as C++, Java, Python, etc.) are multi-paradigm and they support object-oriented programming to a greater or lesser degree, typically in combination with imperativeprocedural programming.

https://en.wikipedia.org/wiki/Object-oriented_programming

⇧ 上記が「オブジェクト指向言語」と認識されてるっぽい。

ちなみに、Rustはと言うと、

Rust(ラスト)は、性能、メモリ安全性、安全な並行性を目指して設計されたマルチパラダイムプログラミング言語である。

Rust (プログラミング言語) - Wikipedia

Javaと同様、マルチパラダイムプログラミング言語らしいので「オブジェクト指向」を利用してるケースも有り得るっぽい。

話が脱線しましたが、「ドメイン駆動設計(DDD:Domain Driven Design)」の概念とかも考慮すると、「オブジェクト指向プログラミング」の代替が思いつかんな...

いまのところ「オブジェクト指向」を利用せざるを得ないかな...

2023年3月1日(水)追記:↓ ここから

「関数型」で「ドメイン駆動設計(DDD:Domain Driven Design)」を試みてる方がおられました。

canro91.github.io

⇧ 開発するシステムの規模によっては「関数型」でもいけるんかな?

2023年3月1日(水)追記:↑ ここまで

毎度モヤモヤ感が半端ない...

今回はこのへんで。