10 Books Every Developer Should Read

LibraryWho doesn’t love a great library with books, right? Here is a picture of mine! Not really, I wish…

Over the years I’ve had countless discussions with developers and peers about the best books to read. It is a never ending quest to find the source of wisdom that will make us better at creating software products. Below is a collection of the 10 books that I would recommend to every software developer (and in general for everyone involved in the industry).

It is important to note that none of these books relate to a particular technology or a programming language. Being a great developer is not about knowing well some programming language or a specific platform. It is about being able to think and solve problems in the best possible way. This is not intended as a detailed review of all books on this list (that would be a material for a book itself), rather a brief description and “why” each book made the list.

Without further due, here is the list in no particular order:

The Mythical Man-Month: Essays on Software Engineering
by Frederick P. Brooks Jr.

This is a timeless read on software project management. Fred Brooks was a project manager for the IBM System/360 computer family and later for OS/360. His advise on managing complex projects is as actual today as it was many years ago.
Why: Because so many refuse to believe that adding manpower to a late software project makes it later. The bearing of a child takes nine months, no matter how many women are assigned.

Programming Pearls
by Jon Bentley

Jon’s essays are an excellent introduction to thinking effectively about the challenges of software engineering. His “pearls” will challenge you to think like an engineer and show you how to solve problems effectively.
Why: The best tutorial for learning to think like a programmer.

Algorithms + Data Structures = Programs
by Niklaus Wirth

A classic read for every developer! This is where it all starts and once you begin there is no way back. The basics of algorithms and data structures exposed in a very easy to understand way. Recursion, sorting, B-trees, and hashing, it has it all!
Why: This book is the cornerstone of programming knowledge.

Code Complete: A Practical Handbook of Software Construction
by Steve McConnell

Steve McConnell managed to combine the research and academical knowledge with everyday commercial practices to one of the best practical guides to programming. It drills down to gems like minimizing complexity, collaboration, defensive programming, resolving issues, and much more.
Why: The first readable encyclopedia of best practices on software quality.

Design Patterns: Elements of Reusable Object-Oriented Software
by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Regardless what programming technology you use, knowing object-oriented patterns and how to apply then is an invaluable tool to build applications. This is a classical collection of effective solutions to common problems. It shows great engineering that helps to improve re-usability and flexibility of code.
Why: The best way to start thinking about design patterns in object oriented way.

Refactoring: Improving the Design of Existing Code
by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts

We are so often locked into the stone age old mantra “don’t fix it if it ain’t broken”. It is a fact that very few developers plan and spend time on regular basis to improve existing code. Tools, platforms and new algorithms evolve over time. This provides a huge opportunity to improve existing applications. This is the foundation of methods to apply refactoring.
Why: Because “don’t fix it if it ain’t broken” is a myth.

Introduction to Algorithms
by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein

The best book on algorithms! It covers the theory and implementation of algorithms, from classical to moderns and specific applications. Most important – it makes you think! Applying algorithms from any “cookbook” is easy, but this one helps you to learn and understand what makes and efficient algorithm.
Why: Algorithms are the foundation of learning to solve problems efficiently.

The Design of Everyday Things
by Donald A. Norman

Oh, no! What does this one has to do with software development? Everything! Software development is mostly about solving everyday problems. The same rules that apply to all things are applicable in every software product: make things visible, exploit natural relationships that couple function and control, and make intelligent use of constraints. Who doesn’t want to build applications that guide the user effortlessly to the right action on the right control at the right time?
Why: Simple solutions are all around us.

Steve Jobs
by Walter Isaacson

Regardless if you like Apple products or not, if you are fascinated by Steve Jobs or not, it is undeniable that he was the innovating force that pushed the computer industry (and beyond that) to new levels. Steve Jobs indeed was here to put a dent in the universe and everybody can learn something from this visionary. Creativity, passion, perfection – just a few works to describe his work.
Why: As Steve said: “stay hungry, stay foolish” and “We’re here to put a dent in the universe”.

The Book of Joy: Lasting Happiness in a Changing World
by Dalai Lama, Desmond Tutu, Douglas Carlton Abrams

Coding is one of those obsessive activities that captivates our minds and letting go is a very difficult task. But one should always look around and see that there is a lot of joy in life, beyond the keyboard. The stories and wisdom of Dalai Lama and Desmond Tutu drive deep into the world of love, happiness and joy. Finding fulfillment and purpose in life will bring more joy in your coding and bring more happiness to your customers.
Why: As Dalai Lama said: “What is the purpose of life? After much consideration, I believe that the purpose of life is to find happiness”.

Is this a comprehensive list? No, but this will give you a great foundation to become a master of engineering software products. As much as I was eager to include in this list books like Knuth’s “The Art of Computer Programming” (which is an advanced reading for those in the top 5 percentile of computer science world), or “The Hitchhiker’s Guide to the Galaxy” (because everyone needs to know that 42 is the answer to the meaning of life, the universe, and everything), I intentionally dropped them from my top 10 list.

Here are some additional readings from my library, for those with passion to learn:

The Art of Computer Programming by Donald E. Knuth
The Hitchhiker’s Guide to the Galaxy by Douglas Adams
The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt, David Thomas
Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
Don’t Make Me Think, Revisited: A Common Sense Approach to Web Usability by Steve Krug
Test Driven Development: By Example by Kent Beck
Patterns of Enterprise Application Architecture by Martin Fowler
Coders at Work by Peter Seibel
CODE by Charles Petzold
Extreme Programming Explained: Embrace Change by Kent Beck, Cynthia Andres
Peopleware by Demarco and Lister
Compilers: Principles, Techniques and Tools by Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman
Best Software Writing I by Joel Spolsky
Getting Real by 37 Signals
Rework by Jason Freid, David Heinemeier Hansson

Implementing In-App purchases in your NativeScript application (Part 1)

Many mobile applications nowadays leverage the in-app purchase capabilities of both Android and iOS which gives users ability to buy digital goods. But since there are some tricks to get the native part going I’ve decided to write a 3-part in depth tutorial that will guide you through the full process of setting up in-app purchases in your NativeScript app. So let’s get going!

Creating the sample application

As of the writing of this article the most recent NatvieScript version is 2.5.1. Make sure you have installed and configured it correctly. For this tutorial we will be using vanilla TypeScript app so let’s run the following and create it:

tns create purchase-sample --tsc

Adding the nativescript-purchase plugin

After we created our sample app it is time to add the nativescript-purchase plugin. The plugin will do the heavy lifting of consuming in-app purchases in our application:

tns plugin add nativescript-purchase

Configuring available purchases for the application

Now it is time to start wiring things in our application. First stop is to specify what purchases will be available to our users. This is done in the app.ts file of the application (the main entry point of the NativeScript app). You can do this by adding the following block just above the app.start(...) line:

import * as purchase from "nativescript-purchase";

purchase.init([
    "org.nativescript.purchasesample.product1",
    "org.nativescript.purchasesample.product2"
]);

With this we are telling that products with ids org.nativescript.purchasesample.product1 and org.nativescript.purchasesample.product2 should be available to the users. Note that it is not necessary to prefix your products’ ids with the application id but this makes it really clear what product with which application is associated. If you do not like those long ids you can use just product1 and product2. Just note what ids you use here as we will need them in the next parts of the tutorial when we set up everything in iTunes Connect and Google Play Store.

Designing the UI

Now let’s move on to creating a simple UI that will show a list of products and give users ability to buy new products or restore their previous purchases (in case they changed their device):

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
    <Page.actionBar>
        <ActionBar title="In-App Purchase Sample" class="action-bar">
            <ActionBar.items>
                <ActionItem ios.position="right" text="Restore" tap="onRestoreTap"/>
            </ActionBar.items>
        </ActionBar>
    </Page.actionBar>

    <GridLayout>
        <ListView items="{{ items }}" itemTap="onProductTap">
            <ListView.itemTemplate>
                <GridLayout rows="auto, auto" columns="*, auto" padding="5">
                    <Label row="0" col="0" class="h2" text="{{ localizedTitle }}"/>
                    <Label row="1" col="0" text="{{ localizedDescription }}" textWrap="true" color="#999999"/>
                    <Label text="{{ priceFormatted }}" row="0" rowSpan="2" col="1" class="h1" style="margin-left: 5"/>
                </GridLayout>
            </ListView.itemTemplate>
        </ListView>
        <ActivityIndicator busy="{{ loading }}" />
    </GridLayout>
</Page>

The UI is quite simple: we have an action bar with a button to restore previous purchases. Then bellow we have a list view that will display the available purchases and when tapped we will trigger our purchase workflow.Finally we have an activity indicator to show the user when we are doing some backend operations.

Purchase workflow code

With the setup and the UI ready it is time to go in the main-page.ts file and write the actual purchase workflow code that we will use to show the available products to the user and allow the user to buy and restore their purchases.
We will start by adding some required imports at the top for things that we will need:

import * as applicationSettings from "application-settings";
import * as purchase from "nativescript-purchase";
import { Transaction, TransactionState } from "nativescript-purchase/transaction";
import { Product } from "nativescript-purchase/product";
import { ItemEventData } from "ui/list-view";

let viewModel: Observable;

The next step will be to add the code that will load our products and put them in the model for the page.:

export function navigatingTo(args: EventData) {
    let page = <Page>args.object;

    viewModel = new Observable({
        items: [],
        loading: true
    });

    page.bindingContext = viewModel;

    purchase.getProducts()
        .then((res) => {
            viewModel.set("items", res);
            viewModel.set("loading", false);
        })
        .catch((e) => console.log(e));
}

NB: For simplicity we are be using a local model for the page that is defined in the same TS file. In a real life scenario you should always separate your models from the code behind of the view!

We set some default values in the model and bind it to the page. Next we call the getProducts() method of the nativescript-purchase plugin that will load our product details from iTunes Connect/Google Play Store – like price, title, etc. You can check all the available product properties here. The method will return an array with the products, which we set in the model and stop the loading animation.

There is one more thing that we should do in the navigatingTo event handler – to subscribe to the exposed transactionUpdated event of the nativescript-purchase plugin where we will handle the transactions made by our users. You can add this at the end of the navigatingTo event handler:

purchase.on(purchase.transactionUpdatedEvent, (transaction: Transaction) => {
    if (transaction.transactionState === TransactionState.Restored) {
        applicationSettings.setBoolean(transaction.productIdentifier, true); /* 1 */
    }
    if (transaction.transactionState === TransactionState.Purchased) {
        if (transaction.productIdentifier.indexOf(".product2") >= 0) { /* 2 */
            purchase.consumePurchase(transaction.transactionReceipt) /* 3 */
                .then((responseCode) => {
                    if (responseCode === 0) {
                        // Provision your user with their digital goods bought. 
                    }
                })
                .catch((e) => console.log(e));
        }
        else {
            applicationSettings.setBoolean(transaction.productIdentifier, true); /* 4 */
        }
    }    
});    

A nice way to store locally what products are purchased is to use NativeScript’s application-settings module. This way you can add a key in the application settings for any product bought by the user and then you can enable/disable specific parts of your application depending on what the user has purchased. So in lines /* 1 */, after a purchase is restored, and on /* 4 */, when the user has purchased a product, we set the product id in the application settings. The special case for product2 on line /* 2 */ is because we will be setting up product2 as a consumable purchase. There are differences of how consumable purchases work on iOS and on Android. For iOS consumable purchases are automatically consumed after a successful purchase, so the user can make another one right away. For Android you are responsible for consuming a purchase and flag it for repurchase. That’s why on line /* 3 */ we call the consumePurchase() method. If the consume is successful and the return code is 0 you should provision your users with the digital goods corresponding to the product bought. Note that for iOS this method always returns response code 0.
In case you have many consumable purchases you can add some suffix to the product id (for example .consumable) so you can easily distinguish for what products you should call the consumePurchase() method.
In this event handler you also have access to various other properties of the transaction which you can use (for example for extended verification of the transaction on your backend server with Apple/Google). You can check the full list of available properties here.

Finally we should add our handlers for the restore button tap and the tap on the product that should trigger a purchase:

export function onProductTap(data: ItemEventData) {
    let product = viewModel.get("items")[data.index] as Product;

    purchase.buyProduct(product);
}

export function onRestoreTap() {
    purchase.restorePurchases();
}

NB: For the buyProduct() method it is really important that you pass the product instance as returned by the getProducts() method. If you just create a new product and populate its properties the method will fail on iOS!

Up next

If you go ahead and run the code now, you should get a nice empty list 🙂 This is because we need to configure the products on iTunes Connect and Google Play Store.
In the next part of this tutorial I will guide through the setup on iTunes Connect and then we will run our sample application on iOS and make some sandbox purchases! So stay tuned!