WSZYSTKO CO POWINNIŚCIE WIEDZIEĆ O PROGRAMOWANIU
Jakiś czas temu, kiedy studenci oddawali mi pierwsze programy a w programie był fragment, który był nieczytelny miał pięć ekranów długości i pięciokrotnie zagnieżdżoną pętlę for,
na moje pytanie: "Czemu to uczyniliście" odpowiedź zawsze brzmiała: "Bo tak jest szybciej"
W tej prezentacji chcę przekonać was że nie warto optymalizować za szybko oraz że czytelność jest warta więcej niż szybkość wykonania.
Premature optimization is the root of all evil
Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.
Oba Cytaty: Donald Knuth: "Structured programming with go-to statements"
Programs must be written for people to read, and only incidentally for machines to execute.
-Abelson & Sussman, Structure and Interpretation of Computer Programs
class G4UserEventAction
{
public:
G4UserEventAction();
virtual ~G4UserEventAction();
inline void SetEventManager(G4EventManager* value) .//<--- Virtual
{ fpEventManager = value; }
public: // with description
virtual void BeginOfEventAction(const G4Event* anEvent);
virtual void EndOfEventAction(const G4Event* anEvent);
// Two virtual method the user can override.
protected:
G4EventManager* fpEventManager;
};