タグ

classに関するnantanのブックマーク (4)

  • Class構文について - JS.next

    概要 待ち焦がれた人も多いことだろう。ES2015の一番の目玉機能とも言えるクラス構文が、ついにV8でサポートされた。 Class構文は、『関数(コンストラクタ)定義』+『.prototypeへのメソッド定義』の糖衣構文である。 JSで今まで様々に工夫されてきたクラスの書き方を、綺麗に統一してくれる可能性を秘めている。 クラスを作る 従来、Catクラスを作ろうとした場合このように書いてきた。 function Cat(name) { this.name = name } Cat.prototype.meow = function () { alert( this.name + 'はミャオと鳴きました' ) } しかしこの書き方だとどうしても、コンストラクタとメソッドの定義が分離されているため、クラスとしてまとまりがなく分かりづらく感じる。 メソッドが増えてきた時も、Cat.prototyp

    Class構文について - JS.next
  • 非staticな内部クラスが持つ暗黙的な参照 - Kengo's blog

    Effective Java 第2版 (The Java Series)の項目22で言及されているように、原則として内部クラスはstaticにすることが推奨されます。主な理由は、staticでない内部クラスが暗黙的にエンクロージングクラス(トップレベルクラス)のインスタンスを参照するためです。 staticな内部クラスを持つクラスのヒープダンプ staticな内部クラスはエンクロージングクラスのインスタンスへの参照を持ちません。 class HiddenReferenceTest { private static class InnerClass {} } 非staticな内部クラスを持つクラスのヒープダンプ 一方、staticな内部クラスはエンクロージングクラスのインスタンスへの暗黙的な参照を持ちます。 class HiddenReferenceTest { private class

    非staticな内部クラスが持つ暗黙的な参照 - Kengo's blog
  • Naming Classes - How to avoid calling everything a "<WhatEver>Manager"?

    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. A long time ago I have read an article (I believe a blog e

    Naming Classes - How to avoid calling everything a "<WhatEver>Manager"?
  • Generics and Class.forName

  • 1