Using mobile agent systems, cooperative distributed applications that run over the Internet can be constructed flexibly. However, there are some problems: it is difficult to understand collaborations among agents as a whole; it is difficult to define behaviors of agents because they are influenced by their external context dynamically. So, in general, constructions of cooperative distributed applications based on mobile agent systems are considered as very hard and difficult works. In this paper, the concept of RoleEP (Role Based Evolutionary Programming) is proposed in order to alleviate these problems. RoleEP provides a systematic evolutionary programming style. In RoleEP, a field where a group of agents collaborate with each other is regarded as an environment and a function that an agent assumes in an environment is defined as a role. Descriptions only concerning to collaborations among agents can be abstracted by environments. An object becomes an agent by binding itself with a role that is defined in an environment, and acquires functions needed for collaborating with other agents that exist in the same environment. Distributed applications based on mobile agent systems, which may change their functions dynamically in order to adapt themselves to their external context, can be constructed by synthesizing environments dynamically.