Secrets of the JavaScript Ninja

This book is heavily concentrated on explaining why JavaScript is a functional programming language and how that can be used by the developer. The first half of the book is dedicated to JavaScript functions, there is everything you will need to know about JavaScript functions: anonymous functions, recursions, inline named function and so on.

The second half of the book explains everything that you will need to develop well structured JavaScript code.

The only remark I have for this book is about the ‘Regular Expressions’ chapter, in my opinion it is not written very clear and can be confusing, but it is fer to say that the authors are suggesting additional literature for getting familiar with regular expressions.

Big plus is that all the source code form the book examples is very well structured and packed in zip file that enables you to quickly try the examples on computer.

Its a good buy, and I highly recommend it.

Javascript: The Good Parts

JavaScript: The Good Parts is a classic title from 2008 that many refer to as the go-to introduction to the language. Douglas Crockford, the author, is a familiar name in the JavaScript community and also serves on the ECMAScript committee. While being a little outdated and covering only the ES3 JavaScript specification, the book is valuable today and holds its key takeaways.

Use a subset of JavaScript

JavaScript: The Good Parts is easy to read and covers a subset of the language in 100 pages. It suits well to plowing trough in a few days while trying to grasp the basics of JavaScript. If the reader doesn’t mind the chapter on inheritance being a little hard to read, and take the railroad diagrams and modifying built-in objects with a grain of salt, the book is easy to digest.

JavaScript: The Good Parts presents that most programming languages contain good parts and bad parts. Imperfections are difficult to remove from a language, so they are destined to stay in the language. The programmer is better off by leveraging on the good parts and avoiding features that are more trouble than they are worth.

Good Parts, Bad Parts

The book describes a subset of ES3, the good parts, containing the clear and well-formed language constructs that leave the least room for errors when programming in JavaScript. What is left out is not considered that good. Here and there, the reader gets a taste of the unfavorable features and the fact that the language was originally put together in a very short period of time.

Few good language features get raised above others and are mentioned as the beautiful parts. Parts that are not so good that you cannot avoid using are entitled the awful parts. Parts that are not good but that you can easily avoid are called the bad parts.

The Pragmatic Programmer

pragmatic_programmer

The Pragmatic Programmer is one of those books which is usually included in the recommended readings for a software developer, and deservedly so. The book, released in 1999, has been so successful that the two authors, Andrew Hunt and David Thomas, have since created their own publishing company, the Pragmatic Bookshelf (with titles spanning a broad range of programming topics).

This book must really have been a breakthrough when it hit the bookstores about 15 years ago. 1999 is one year before Kent Beck released his seminal book Extreme Programming Explained: Embrace Change which exposed the agile software process to the masses. Both Andrew Hunt and David Thomas originally signed the Agile Manifesto, together with Kent Beck himself and a few others, and it shows. But it would be dismissive to describe this as a book on agile since it’s much more.

The book is structured as a series short 46 sections. Each section has challenges and even exercises where appropriate. It touches on design concepts such as orthogonality, decoupling, DRY (which it coined), Domain Specific Languages, Design By Contract, Metaprogramming, Refactoring; it has pages on process topics like build automation, “design to test”, test automation, estimation, requirements collection.

But where the book really shines is where it shows you how to “become a better programmer” (today we might say a software craftsman) and to take pride from it.

The pragmatic programmer is an early adopter, is inquisitive and realistic, and tries to be “familiar with a broad range of technologies and environments”.

The pragmatic programmer takes responsibility, values quality but recognizes when the software is “good enough”. The pragmatic programmer is a continuous learner (the “learn at least one new language every year” advice is often quoted), thinks critically about what he reads and hear, and knows how to communicate. The books explains how you can build these qualities.

All in all, the Pragmatic Programmer is easily one of the best book on software development I have ever read. It has really inspired me to continue my journey to become a “better programmer”.

The Mythical Man Month

mythical_man_month

The effects of manpower on scheduling
Brooks spends a lot of time covering scheduling and manpower. One of the most poignant statements he makes is coined Brooks Law:

Adding manpower to a late software project makes it later

He backs up his law with numerous examples and antecdotes, but he makes a key point as to why adding more people lengthens a schedule rather than shortens it:

Since software construction is inherently a systems effort – an exercise in complex interrelationships – communication effort is great, and it quickly domiantes the decrease in individual task time brought about by partioning. Adding more men then lengthens, not shortens, the schedule.

When it comes to scheduling and manpower, Brooks makes the point that “the number of months of a project depends upon its sequential constraints. The maximum number of men depends upon the number of independent subtasks.” In other words, independence of tasks in the most important factor in determining if adding people to a project will reduce schedule.

Assembling schedules
At numerous points, Brooks hammers home the point that test and debug are the most misunderstood and under estimated tasks in a schedule. From his experience he uses the following formula for creating a schedule: “1/3 planning, 1/6 coding, 1/4 component test and early system test, 1/4 system test all components in hand.” He follows with this observation:

In examining conventionally scheduled projects, I have found that few allowed one-half of the projected schedule for testing, but that most did indeed spend half of the actual schedule for that purpose

The risk of not putting in enough time for system test and debug is the following:

Failure to allow enough time for system test, in particular, is peculiarly disastrous. Since the delay comes at the end of the schedule, no one is aware of schedule trouble until almost the delivery date. Bad news, late and without warning, is unsettling to customers and to managers.

There’s a lot of suggestions, recommendations, and tips that you can pull from book that will help everyone involved in a project do a better job of estimating schedules, or at a minimum, recognizing problems with their scheduling philosophies.

Additional quote and excerpts
Here is a collection of other quotes that I highlighted while reading the book. Many of these stand on their own, although they are even more powerful when read in the overall of context of the book.

The architect of a system, like the architect of a building, is the user’s agent. It is his job to bring professional and technical knowledge to bear in the unalloyed interest of the user, as opposed to the interests of the salesman, the fabricator, etc.

The architect must always be prepared to show an implementation for any feature he describes, but he must not attempt to dictate the implementation.

The task of the manager is to develop a plan and then to realize it.

Where a new system concept or new technology is used, one has to build a system to throw away, for even the best planning is not so omniscient as to get it right the first time.

Many poor systems come from an attempt to salvage a bad basic design and patch it with all kinds of cosmetic relief.

It is more important that [schedule] milestones be sharp-edged and unambiguous than that they be easily verifiable by the boss.

…each software organization must determine and proclaim that great designers are as important to its success as great managera are, and that they can be expected to be similarly nurtured and rewarded.

It is necessary to separate the architecture, the definition of the product as perceivable by the user, from its implementation.

Having a system architect is the most important single step toward conceptual integrity.

Obviously, I could go on and on, but you should get the point by now. The point being if you are involved in software development in anyway whatsoever, be it development, project management, personnel management, or executive management, the book is worth your time. Sure, a few concepts are dated, but the vast majority still apply today and will help you avoid making mistakes that were discovered forty years ago and are still made today.

I continue to be amazed by how books about such dynamic subjects can stay relevant, and at times become more relevant, than when they were written. To me, it clearly demonstrates how well Brooks approached his work. For Brooks to take a subject as dynamic as software development, which has changed immensely over 40 years and which continues to evolve rapidly today, and create a timeless classic is quite an accomplishment. It goes to show that fundamentally sound ideas are timeless. In other words, one of the biggest lessons I took from the book is that following good, sound advice is better than chasing the latest development trend or fad of the day.

Rapid Development

rapid_development

I recently finished Rapid Development which I half-jokingly refer to as an encyclopedia of software development practices. McConnell is probably best known for Code Complete 2. That book cover how to code well in a similarly encyclopedic manner. Code Complete 2 is a lot more applicable when you first start developing. Rapid Development is more useful when you’ve been doing it for a few years.

Part 1 – Efficient Development
The first 100 pages is about how to develop software efficiently and rapidly. To develop software rapidly means different things, increasing speed, decreasing risk and increased visibility to business owners are all dimensions to rapid software development. And at some point you have to make trade-offs between these types of rapidity. The other big takeaway from this section is that developing software successfully is more about not screwing up than doing one thing really well. He actually has a checklist of common mistakes (which can be found online here) that lead to projects being delayed. If you make any of the common mistakes then the project is likely to be delayed or fail.

He groups the problems into four categories peoples, process, product and technology. Even when the book was written in the early 90s the people and products category had three times more problems than technology and product. Since then the ratio has become even more skewed. Technology problems are the ones we concentrate the most on because they are the most comfortable for us to solve. But we often to don’t notice people or process problems or just accept them as the cost of doing business. The checklist was what initially got me interested in the book, and it was nice to see the reasoning behind each item on it.

Part 2 – Rapid Development
The second section is the meat of the book and covers in detail the areas that affect development speed. He covers every topic that can affect it from estimation, to teamwork, feature control, life cycle planning, etc. Each of these topics gets between 20 to 50 pages, with an extensive further reading section at the end of each chapter. These chapters are designed for people to skip parts of so if you find a certain section dragging it’s easy (and even encouraged) to go to the next one. If you want a fuller understanding of all the issues related to developing software on time though it’s worth reading every chapter. A nice thing about the encyclopedic nature of this book is that each section will reference the other related sections. This means the book is set up for wiki-walk style reading, once you find an issue that you’re interested in you can jump into the related topics and those topics have related topics, etc

Part 3 – Best Practices
McConnell finishes with some rapid development practices that can be used to improve the different dimensions of rapid development (speed,risk,visibility). These practices can be used together or in a alone and McConnell lists the pros and cons of each. Getting your team to do “Voluntary Overtime” for the project will get it done much faster but has a high chance of burnout. A lot of these practices seem to be standard practice if you’re doing some form of agile, although they may go by different names. One I had not seen before that seemed especially useful was having the developers maintain a top 10 risks list for a project.

Conclusion
This book was an interesting mix of (current) best practice, dated ideas and timeless advice. At almost 20 years old that is to be expected but it still threw me for a loop. When the book goes on about the importance of source control, nightly builds, and iterative design I had to remind myself that those things became standard practice in part because of this book. In that way it is a victim of its own success. Other parts like hearing about 4GLs and RAD just reminded me that the next big thing can fall to the wayside quickly. The parts of this book I found most helpful were the parts on estimation, feature scrubbing and development styles. Good technique in these categories has not changed huge amount. Process and people change slower than product and technology.

This is a book I would recommend to a developer with two caveats. One it covers the people and process topics amazingly in depth and you should concentrate on those parts. The product and technology part seem to have aged the poorest and the advice in it may be out of date so you may just want to skim them. Secondly some of the process suggestions felt specific to shrink-wrap software. Which has different maintenance and development costs than web development. It’s still worth reading and if you can’t read the book at least print out a copy of the checklist of common mistakes, laminate it, hang it next to your Kanban board and think about if you’re making a mistake on it every day.

Code Complete 2

code_complete2

I recently embarked on a journey to read (or re-read) all the great classic books in the software literature. This is the first in a series I will do on this site.

Code Complete is a massive work, so this summary is, necessarily, very high level. It is not a book that one can absorb completely in one reading, but one can absorb its high level themes (summarized nicely in the second to last chapter).

“Conquer Complexity”
High quality code manages complexity. No one can think of all of the levels of abstraction needed to fully understand a program at once; just admit it and try to make your code less complex. Complexity can be managed at every level of the development process from having a well thought out high level design to choosing good variable names.

“Pick Your Process”
Having a process is important. It does not matter exactly what the process is; in fact, the process should be tailored to the problem at hand. The purpose of a process is to allow for coordination between people. When a project is small (1, maybe 2 people), then it is the talent of the individual that matters most. When a project is large, it is managing communication that matters most.

“Write Programs for People First, Computers Second”
Computers do not care about programs being readable, but people do, and people are going to read your programs many time. Readable code has a plethora of advantages including lower error rates, being easier to debug and modify, and having shorter development time. Make code readable first, and only optimize when you can make measurable improvements to measurable performance bottlenecks.

“Program into Your Language, Not in It”
Do not limit your programming by the features your language supports. Write libraries that will support the programming features you want for the problem at hand. One example McConnell gives writing an assertion library if your language does not support assertions.

“Focus Your Attention with the Help of Conventions”
Conventions, like processes, do not matter in their particulars. Some conventions are better than others, but for the most part, conventions tend to be arbitrary. However, having conventions makes code easier to read and modify because a convention can communicate a lot without using much space or requiring much thinking.

“Program in Terms of the Problem Domain”
This is a particular method of managing complexity. Higher level code should be supported by lower level code that hides implementation specific details from the higher level code. When done well, this makes the code easier to read and easier to modify. Even at the construction level, this can be done by choosing good class names and abstractions, factoring code into methods to maintain a common level of abstraction, and choosing good variable names.

“Watch for Falling Rocks”
Look out for warning signs, such as classes with an abnormally high number of defects. These warning signs do not necessarily mean that something is wrong with that part of the program, but they are a good indicator that you should be a little bit suspicious. These warning signs could show up after construction (error rate) or during construction (compiler warning, indications from your self or other that your program is hard to understand).

“Iterate, Repeatedly, Again and Again”
In addition to being my favorite section heading in the book, this principle emphasizes that iteration is appropriate at all points of the software development process. Requirements are rarely fixed in stone, bugs are always present, and developers can always find a better way to rewrite code. Iteration gives all of these improvements a chance to actually make it into the product under development.

“Thou Shalt Rend Software and Religion Asunder”
No one convention, process, or tool set is the be all and end all of software development. Developers should be wary of absolutes and try to avoid blind faith in the processes they use. Solutions should be adapted to the problem at hand, not vice versa. The key to keeping an open mind and becoming effective and flexible is experimentation. Be willing to try new things, measure the effectiveness of those experiments, and be willing to change based on the results.

Those are the high level principles. These principles occur over and over again through the seven parts of this book.

“Laying the Foundation”
This section discusses the general process of software development and the role of construction (a.k.a. programming) in that process. Construction is important, according to McConnell, because it is the only part of the software development process that absolutely must happen to produce a working software project. Construction is also an area that, traditionally, has not has as much attention to it as other areas (such as high level design or testing). However, McConnell stresses that all parts of the development process are important in creating a successful project and gives pointers throughout the text to resources that discuss other parts of the software development process in more depth. He notes that pre-construction planning is particularly important since no amount of good construction and through testing can save a bad design.

“Creating High-Quality Code”
This section introduces a point emphasized again and again throughout the book. Software’s “Primary Technical Imperative” is managing complexity. High quality code exposes people reading it to consistent levels of abstraction separated by clear boundaries. Complexity is managed by minimizing the essential complexity one has to deal with at any given time and trying to keep accidental complexity from spreading throughout the code base. High quality classes and routines provide consistent abstractions, document their assumptions, and check their invariants defensively; they fail sooner rather than later. Even a simple class or routine is worthwhile if it decreases the complexity of reading the code where it is used.

One of the most practically useful facts I got out of Code Complete was learning about the “Pseudocode Programming Process”. This process is a way of developing code by starting with detailed pseudocode. When constructing a program, a developer should (iteratively) write pseudocode that is high level enough to be in the domain of the problem but low level enough for translation to real code to be nearly mechanical. Developing pseudocode ensures that the developer understands the problem at a low enough level for implementation, encourages the programmer to think about error checking before implementing the nominal path through the code, may indicate what when to factor code into separate routines (and suggest names for those routines). Those parts of the high level pseudocode that the developer decides to leave in provide automatic, high level commenting of code.

“Variables”
The chapters in this section discuss data initialization (do it close as close to the declaration as possible), variable scope (keep it as small as possible), limiting variables to a single purpose, effective variable names (keep them specific, use a naming conventions), and tips for using fundamental and more complex data types.

“Statements”
This section discusses methods for effectively organizing and using straight line code, conditionals, and loops as well as more exotic control structures such as exceptions, gotos, and various table driven control structures. This section discusses how deep nesting of control structures tends to make code complex. If possible, it should be avoided by restructuring the code or factoring the nested code into its own routine. The more paths there are through a code fragment, the more complex it is; the number of paths a developer must consider at a single time should be minimized.

“Code Improvements”
Discusses software quality, collaboration, developer testing, debugging, refactoring, and code tuning. One key point of this section is that the goals of a certain construction project should be clear. Some goals are bound to go against each other, and if developers do not know which are most important, they will do a bad job of trying to optimize all of them at once. The most obvious example of this tendency is that aggressive optimization may make code less readable and prevent beneficial refactorings. This section also points out that code reviews, testing, debugging, refactoring, and code tuning all have the potential to improve code quality, but it is when they are used thoughtfully in unison that their potential is maximized.

“System Considerations”
Discusses some higher level issues in constructing a system. As project size increases, project quality and development speed tend to go down in a faster than linear manner. This is because as the project increases, more and more overhead gets taken up by managing communication and more details tend to get lost in the cracks. It is for this reason that having a process and conventions becomes more important on large projects; the more that is automatic, the less that quality and and development time will suffer. This section also discusses how to manage programmers and essential tools that every developer should know about and use. This section also discusses several integration processes and emphasizes that which process is right depends on the project being developed.

“Software Craftsmanship”
This section talks about good practices in actually structuring code and how to write good, effective comments and code that documents itself as much as possible. This section also describes the importance of personal character in becoming an excellent developer. McConnell posits that intelligence is less important than other personal characteristics such as humility, curiosity, intellectual honesty, communication and cooperation, creativity and discipline, effective laziness, and good habits. The point emphasized throughout the discussion on personal character is that a good developer needs to be happy and willing to learn from other developers and be willing to admit when their are right and wrong if they want to earn the trust and respect of others.