1. A method comprising: for an executable graphical model that is associated with first and second events and that includes executable components, where occurrence of the first event is in response to one or more first conditions being satisfied, and occurrence of the second event is in response to one or more second conditions being satisfied, determining, by one or more processors, a first set of executable components that are triggerable to be executed by the occurrence of the first event, the executable components of the first set being from first non-contiguous areas of the executable graphical model; determining or obtaining data dependencies among the executable components of the first set; and generating, by the one or more processors, code in a programming language for the executable graphical model, the generating including mapping the first set of executable components into a first function in the code, the first set of executable components mapped into the first function according to the data dependencies, wherein the code includes first instructions to in response to a first function call that represents the occurrence of the first event in response to the one or more first conditions being satisfied, execute the first function that represents executing the first set of executable components.