The orthogonal variable-spreading-factor (OVSF)-CDMA systems can support multimedia applications with different bandwidth requirements. Code management schemes, including code placement and replacement, significantly impact the code utilization of the system. Many researches have studied these two closely related problems and are solving them independently. For replacement, the optimality concerns the minimization of the reassignment number. There is no definition about the placement optimality yet.We formally define the placement optimality for code placement schemes and presented a novel graph model, constrained independent dominating set problem (CIDP), which is proved to be NP-complete for general graphs. A unified algorithm is provided to firstly address both OVSF code placement and replacement issues at the same time which achieves placement optimality in linear time complexity. This demonstrated that OVSF code placement optimality problem is in P. Another simple and practical unified solution is presented and is shown to be reasonably effective.