官术网_书友最值得收藏!

How it works...

At the heart of generics lies the ability to reuse a single class or method. It allows developers to essentially not repeat similar code throughout your code base. This conforms well to the Don't Repeat Yourself (DRY) principle. This design principle states that a specific bit of logic should be represented in code only once.

Using generic classes, for example, also allows developers to create a class that is type safe when compiling. Type safe basically means that the developer can be assured of the type of the object and can use the class in a specific way without experiencing any unexpected behavior. Therefore, the compiler takes over the burden of type safety.

Generics also allow developers to write less code, because code can be reused and less code also performs better.

主站蜘蛛池模板: 色达县| 宝应县| 浦东新区| 南投县| 达州市| 罗源县| 镇康县| 忻州市| 平顶山市| 哈密市| 通榆县| 滨州市| 金堂县| 巩留县| 响水县| 云和县| 林州市| 嵩明县| 东城区| 托里县| 平安县| 洛隆县| 岐山县| 施秉县| 甘洛县| 唐河县| 绥中县| 离岛区| 富源县| 株洲县| 汨罗市| 密山市| 丰原市| 信阳市| 台东县| 卢氏县| 高尔夫| 云安县| 翁牛特旗| 临夏县| 原平市|