Design Issue - Dynamic Memory Allocation
A common design issue for software engineers is the use of
dynamic memory allocation. In the past, many programmers were uncomfortable
with dynamic allocation and resisted using it. This is no longer
an option. Object-oriented languages, especially C++, require a good
understanding of dynamic allocation.
The issue is simple but the decision is often difficult;
under what circumstances should you allocate objects dynamically?
- A collection will contain an unknown number of elements.
- A sorted collection requires fast insertion/deletion.
- Polymorphism is used in the design; run-time binding requires
dynamically allocated objects.
Notes:
1. Some languages don't support dynamic allocation; what then?
2. Think about allocation granularity; dynamic allocation takes time.
Last updated on 10/29/98