In object oriented programming we are modeling objects, but simply that won't create a program. Ex, if I want to create a forest simulation, I can create a tree class, lion class, and so on. But these are just objects, where is the "program flow?".
Like, should your program be like a chain reaction? For example dominoes, where you start everything with a single action and they all start falling?
I've made a simple "java helper ". It works, but I'm not sure if i designed it well:
The program flow starts with the main() method and usually (like you have it) simply launches the program, often by creating an object. From there, you can execute code in the constructor of the object you just created, or create a method in the object you create to run the upper-level processing. For instance:
All things are lawful, but not all things are profitable.
Ahmad Auada wrote:Ex, if I want to create a forest simulation, I can create a tree class, lion class, and so on. But these are just objects, where is the "program flow?".
Well, a "simulation" usually has a "simulator" - ie, a class that creates "scenarios" for the simulation, often driven by random selections of 'driver' components.
For example, an old classic is a simulation for a bank of lifts (or, for those on the wrong side of the pond, elevators) in an office building. So, in addition to all the classes you might expect like Lift, Building, Passenger etc, you'll have a LiftSimulator class that can supply passengers at random intervals and pre-set thing like how long doors take to open and close, and which floors "express" lifts miss out.
In addition, you may want to measure the "success" (or not) of a particular simulation run - for example, in the case of the LiftSimulator above: passenger throughput and/or average travel time - and this is usually best done with a separate "Metrics" class.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here