Since Wireless Sensor Networks (WSNs) are regarded as large-scale distributed systems in nature, it is (i) difficult to implement their distributed low-level codes, (ii) hard to analyze their performance and (iii) almost impossible to operate a number of nodes manually. In this paper, we propose an integrated environment called D-sense to solve these problems in WSN development. By providing algorithm-level APIs, D-sense tries to hide distributed, low-level operations in the NesC programming language. The algorithm-level APIs and other NesC codes can automatically be converted into simulator codes to avoid code-writing for simulation purpose. In addition, D-sense provides useful functions like monitoring, logging and debugging of distributed programs. We have implemented several known protocols and evaluated the performance by simulation and real environmental experiments to demonstrate the functions of D-sense.