Unusual Data Types

xiaoxiao2021-03-06  70

Structures1. Use structures to clarify data relationship.2. Use structures to simplify operations on blocks of data.3. Use sturctures to simplify parameter lists.4. Use structures to reduce maintenance.

Global DataCommon problems with global data1. Inadvertent changes to global data2. Bizarre and exciting aliasing problems with global data.3. Re-entrant code problems with global data.4. Code reuse hindered by global data.5. Uncertain initization-order issues with Global Data.6. Modularity and Intellectual ManageAbility Damaged by Global Data.

Reason to user global data1. Preservation of global values.2. Emulation of named constants.3. Streamlining use of extremely common data.4. Eliminating TRAMP DATA.

How to reduce the risks of using global data1. Develop a naming convention that makes global varables obvious.2. Create a well-annotated list of all your global variables.3. Do not use global variables to contain intermediate results.4. Don 't pretend you're not useful global data by Putting All Yoru Data Into a Monster Object and Passing It Everywhere

转载请注明原文地址:https://www.9cbs.com/read-109315.html

New Post(0)