More on this book
Kindle Notes & Highlights
Once we had enough memory that we no longer needed to commit atrocities in the name of space efficiency, state still bit us on the backside. Huge programs were written where many many functions used many many different bits of state. No part of the state could be changed without changing many parts of the program.
q: why excessive usage of states became a bad idea? Or excessive usage of serious results in side effects.
In spite of their conceptual and mathematical elegance, functional programming languages never caught on for commercial software. The problem is that programmers think and model in terms of state. State is a pretty darn good way to think about the world.
q: why functional programming did not do well in commerical sotwares - atleast till 1996 ( when this book was published)?
Objects represent a middle ground. State is good, but only when properly managed. It is manageable if it is chopped into little pieces, some alike and some different. Similarly, related programs are chopped into little pieces, some alike, some different. That way, changing part of the representation of the state of a program need lead to only a few, localized changes in the program.
Instance variables have a very important communicative role to play. They say once and for all and out in the open, “Here’s what I’m modeling with this object.” A set of objects reveals a lot that was in the mind of the original programmer just by what the instance variables are and what they are named. Be sure to declare instance variables in order of importance in the class definition.
Instance variables have a very important communicative role to play. They say once and for all and out in the open, “Here’s what I’m modeling with this object.” A set of objects reveals a lot that was in the mind of the original programmer just by what the instance variables are and what they are named. Be sure to declare instance variables in order of importance in the class definition.
Temporary variables let you store and reuse the value of expressions. They can be used to improve the performance or readability of methods. The following patterns motivate and guide the use of temporary variables. The examples are taken from Smalltalk, but the discussion applies to any language with procedure-scoped variables.
Long extent, wide scope, and large type all make variables difficult to manage. If all three factors are present in many variables, you have a program that can only be understood in its entirety. Limiting the scope, extent, and type of variables wherever possible produces programs that are easier to understand, modify, and reuse.
All performance tuning boils down to two techniques—either you execute code less often or you execute code that costs less. Of these, the first is often the most valuable. It relies on the fact that for reasons of readability, expressions are often executed several times even though they return the same value. Caching saves the value of the expression so that the next time the value is used instantly.
You’re creating a vocabulary, not writing a program. Be a poet for a moment. The simple, the punchy, the easily remembered will be far more effective in the long run than some long name that says it all, but in such a way that no one wants to say it at all.
o: By giving meaning full names you are creating a vocabulary. It is very important to give appropriate name.

