Working with primitive data structures

What I learned from Code Complete


Avoid string literals. Use name constants instead.


boolean can make tests in if statement clearer.

Enumerated types

it improves readability. You can use enumerated types in function parameter instead of true, false etc.

named constants

help make sure software is soft and easy to change.


consider use container class to access data sequentially, such as sets, queue, stack, before choosing using array. random access to array is error prone.

Type aliasing

example: alias an float, later easier to change to double and facilitate information hiding


pretty similar to js objects, can group related data together. For example, employee datas and supervisor datas.


a pointer point to a location in the memory. It does now know the meaning of the content.

Global data

you want to write class and functions that as little connection as possible to global data. Information hiding and modularity helps making big program maintainable.

Software Engineer