We report on an object-oriented based simulation of a passively modelocked fiber laser containing a long period fiber grating. Object oriented concepts, such as polymorphism, encapsulation, operator overload and delegation can be used efficiently to implement extendable and reusable C++ code for scientific computing. It was found that decreasing the level of encapsulation reduces the computational time. The numerical model is based on the normalized complex Ginzburg-Landau equation and the nonlinear coupled mode equations of the grating. The modelocked pulse energy was found to exhibit a wide range of nonlinear dynamics. To accurately capture these dynamics highly robust and numerically stable variations of the split step Fourier method were implemented.