Salı, 29 Mayıs 2018 / Published in Uncategorized

In this article, we’ll look at how to update Angular projects to the latest version.

This article is part 6 of the SitePoint Angular 2+ Tutorial on how to create a CRUD App with the Angular CLI.

  1. Part 0 — The Ultimate Angular CLI Reference Guide
  2. Part 1 — Getting our first version of the Todo application up and running
  3. Part 2 — Creating separate components to display a list of todos and a single todo
  4. Part 3 — Update the Todo service to communicate with a REST API
  5. Part 4 — Use Angular router to resolve data
  6. Part 5 — Add authentication to protect private content
  7. Part 6 — How to Update Angular Projects to the latest version.

In part 1 we learned how to get our Todo application up and running and deploy it to GitHub pages. This worked just fine but, unfortunately, the whole app was crammed into a single component.

In part 2 we examined a more modular component architecture and learned how to break this single component into a structured tree of smaller components that are easier to understand, reuse and maintain.

In part 3 we updated our application to communicate with a REST API backend using RxJS and Angular’s HTTP service.

In part 4, we introduced Angular Router and learned how the router updates our application when the browser URL changes and how we can use the router to resolve data from our backend API.

In part 5, we added authentication to our application and learned how we can protect sections from our application from unauthorized access.

Don’t worry! You don’t need to have followed part 1, 2, 3, 4 or 5 of this tutorial for 6 to make sense. You can simply grab a copy of our repo, check out the code from part 5, and use that as a starting point. This is explained in more detail below.

Up and Running

To start on our goal to update Angular, make sure you have the latest version of the Angular CLI installed. If you don’t, you can install it with the following command:

npm install -g @angular/cli@latest

If you need to remove a previous version of the Angular CLI, you can:

npm uninstall -g @angular/cli angular-cli
npm cache clean
npm install -g @angular/cli@latest

After that, you’ll need a copy of the code from part 5. This is available on GitHub. Each article in this series has a corresponding tag in the repository so you can switch back and forth between the different states of the application.

The code that we ended with in part 5 and that we start with in this article is tagged as part-5. The code that we end this article with is tagged as part-6.

You can think of tags like an alias to a specific commit ID. You can switch between them using git checkout. You can read more on that here.

So, to get up and running (with the latest version of the Angular CLI installed) we would do this:

git clone git@github.com:sitepoint-editors/angular-todo-app.git
cd angular-todo-app
git checkout part-5
npm install
ng serve

Then visit http://localhost:4200/. If all’s well, you should see the working Todo app.

Update Angular: Our Plan of Attack

In this article, as we update Angular, we’ll learn the following:

  • how Angular versions work
  • where to find instructions on how to update Angular
  • how to update our code from Angular 4 to Angular 5 (Angular 5 being the latest version at time of writing).

By the end of this article, you’ll understand:

  • the underlying meaning of specific Angular versions
  • where to find exact instructions on how to update Angular applications
  • how to figure out which code changes are required (if any) for Angular 5.

Let’s get started!

The Meaning of Angular Versions

To support a thriving ecosystem, Angular needs to be both stable and evolutionary.

On one hand, Angular aims to provide developers with maximum stability for mission-critical applications. On the other hand, it constantly needs to adapt and advance to support the latest changes in web technologies.

Therefore, the Angular team has decided to use a time-based release cycle with semantic versioning.

A time-based release cycle means that we can expect new versions of Angular (Angular 5, Angular 6, Angular 7, etc.) every couple of weeks or months.

Semantic versioning means that the version number of Angular allows us to predict whether or not it will break our application if we upgrade to it.

In essence, a semantic version looks like this: Major.Minor.Patch.

So version v1.3.8 has a major component with a value of 1, a minor component with a value of 3 and a patch component with a value of 1.

When a new version is released, the new version implicitly indicates the type of change that was made to the code.

The following rules are applied when a semantic version is increased:

  1. Each increment happens numerically with an increment of 1.

  2. When a bug is fixed and the code stays backwards compatible, the patch component is increased:

    v0.0.3 // Before bugfix
    v0.0.4 // After bugfix
    
  3. When functionality is added and the code stays backwards compatible, the minor component is increased and the patch component is reset to zero:

    v0.2.4 // Before addition of new functionality
    v0.3.0 // After addition of new functionality
    
  4. When a change is implemented that causes the code to become backwards incompatible, also known as a breaking change, the major component is increased and the minor and patch components are reset to zero:

    v7.3.5 // Before implementing backwards incompatible changes
    v8.0.0 // After implementing backwards incompatible changes
    

If you’re not familiar with semantic versioning, make sure to check out this simple guide to semantic versioning.

The Angular team combines semantic versioning with a time-based release cycle to aim at:

  • a new patch release every week
  • a new minor release every month
  • a new major release every 6 months

The release schedule is not set in stone, as there may be holidays or special events, but it’s a good indicator of what we can expect in terms of upcoming versions.

You can follow the official Angular blog and the official change log to stay up to date on the latest developments.

A huge benefit of semantic versions is that we can safely update Angular applications with patch or minor releases without having to worry about breaking our applications.

But what if there’s a new major release?

The Angular Update Guide

We already learned that a major release can come with breaking changes. So how do we know if our existing application will break or not if we update it?

One way would be to read the official change log and go through the list of changes.

A much easier way is to use the Angular Update Guide to update Angular. You select your current version of Angular and the version you wish to upgrade to and the application tells you the exact steps you need to take:

For our Angular Todo application, we wish to upgrade from Angular 4.0 to Angular 5.0.

Let’s select app complexity level Advanced so we see all the possible measures we need to take:

We get a complete overview of all the steps we need to take to update our application.

How sweet is that!

Before Updating

The Before Updating list contains 12 items. None of the items apply to our Angular Todo application, so we can safely proceed to the next step.

During the Update

From the During the Update list, only the last item applies to our application. We need to update our dependencies, so let’s run the proposed commands in the root of our project:

$ npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@'^5.0.0' typescript@2.4.2 rxjs@'^5.5.2'

$ npm install typescript@2.4.2 --save-exact

Because we updated our Angular CLI to the latest version in the Up and Running section, we also update our local version:

$ npm install @angular/cli@latest --save-dev

To verify that our application runs correctly, we run:

$ ng serve

If ng serve fails to start, try deleting your node_modules directory and package-lock.json file and run npm install to recreate a clean node_modules directory and package-lock.json file.

Continue reading %How to Update Angular Projects to the Latest Version%



Salı, 29 Mayıs 2018 / Published in Uncategorized

This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.

I’ve danced the JavaScript framework shuffle for years starting with jQuery, then on to Angular. After being frustrated with Angular’s complexity, I found React and thought I was in the clear. What seemed simple on the surface ended up being a frustrating mess. Then I found Vue.js. It just felt right. It worked as expected. It was fast. The documentation was incredible. Templating was eloquent. There was a unanimous consensus around how to handle state management, conditional rendering, two-way binding, routing, and more.

This tutorial will take you step by step through scaffolding a Vue.js project, offloading secure authentication to Okta’s OpenID Connect API (OIDC), locking down protected routes, and performing CRUD operations through a backend REST API server. This tutorial uses the following technologies but doesn’t require intimate knowledge to follow along:

About Vue.js

Vue.js is a robust but simple Javascript framework. It has one of the lowest barriers to entry of any modern framework while providing all the required features for high performance web applications.

This tutorial covers two primary builds, a frontend web app and backend REST API server. The frontend will be a single page application (SPA) with a homepage, login and logout, and a posts manager.

Okta’s OpenID Connect (OIDC) will handle our web app’s authentication through the use of Okta’s Vue SDK. If an unauthenticated user navigates to the posts manager, the web app should attempt to authenticate the user.

The server will run Express with Sequelize and Epilogue. At a high level, with Sequelize and Epilogue you can quickly generate dynamic REST endpoints with just a few lines of code.

You will use JWT-based authentication when making requests from the web app and Okta’s JWT Verifier in an Express middleware to validate the token. Your app will expose the following endpoints which all require requests to have a valid access token.

- GET /posts
- GET /posts/:id
- POST /posts
- PUT /posts/:id
- DELETE /posts/:id

Create Your Vue.js App

To get your project off the ground quickly you can leverage the scaffolding functionality from vue-cli. For this tutorial, you are going to use the progressive web app (PWA) template that includes a handful of features including webpack, hot reloading, CSS extraction, and unit testing.

If you’re not familiar with the tenets of PWA, check out our ultimate guide to progressive web applications.

To install vue-cli run:

npm install -g vue-cli

Next, you need to initialize your project. When you run the vue init command just accept all the default values.

vue init pwa my-vue-app
cd ./my-vue-app
npm install
npm run dev

Point your favorite browser to http://localhost:8080 and you should see the fruits of your labor:

Extra Credit: Check out the other templates available for vue-cli.

Install Bootstrap

Let’s install bootstrap-vue so you can take advantage of the various premade components (plus you can keep the focus on functionality and not on custom CSS):

npm i --save bootstrap-vue bootstrap

To complete the installation, modify ./src/main.js to include bootstrap-vue and import the required CSS files. Your ./src/main.js file should look like this:

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(BootstrapVue)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

Add Authentication with Okta

Dealing with authentication in a web app is the bane of every developer’s existence. That’s where Okta comes in to secure your web applications with minimal code. To get started, you will need to create an OIDC application in Okta. Sign up for a forever-free developer account (or log in if you already have one).

Once logged in, create a new application by clicking “Add Application”.

Select the “Single-Page App” platform option.

Continue reading %Build a Basic CRUD App with Vue.js and Node%



Salı, 29 Mayıs 2018 / Published in Uncategorized

This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.

I’ve danced the JavaScript framework shuffle for years starting with jQuery, then on to Angular. After being frustrated with Angular’s complexity, I found React and thought I was in the clear. What seemed simple on the surface ended up being a frustrating mess. Then I found Vue.js. It just felt right. It worked as expected. It was fast. The documentation was incredible. Templating was eloquent. There was a unanimous consensus around how to handle state management, conditional rendering, two-way binding, routing, and more.

This tutorial will take you step by step through scaffolding a Vue.js project, offloading secure authentication to Okta’s OpenID Connect API (OIDC), locking down protected routes, and performing CRUD operations through a backend REST API server. This tutorial uses the following technologies but doesn’t require intimate knowledge to follow along:

About Vue.js

Vue.js is a robust but simple Javascript framework. It has one of the lowest barriers to entry of any modern framework while providing all the required features for high performance web applications.

This tutorial covers two primary builds, a frontend web app and backend REST API server. The frontend will be a single page application (SPA) with a homepage, login and logout, and a posts manager.

Okta’s OpenID Connect (OIDC) will handle our web app’s authentication through the use of Okta’s Vue SDK. If an unauthenticated user navigates to the posts manager, the web app should attempt to authenticate the user.

The server will run Express with Sequelize and Epilogue. At a high level, with Sequelize and Epilogue you can quickly generate dynamic REST endpoints with just a few lines of code.

You will use JWT-based authentication when making requests from the web app and Okta’s JWT Verifier in an Express middleware to validate the token. Your app will expose the following endpoints which all require requests to have a valid access token.

- GET /posts
- GET /posts/:id
- POST /posts
- PUT /posts/:id
- DELETE /posts/:id

Create Your Vue.js App

To get your project off the ground quickly you can leverage the scaffolding functionality from vue-cli. For this tutorial, you are going to use the progressive web app (PWA) template that includes a handful of features including webpack, hot reloading, CSS extraction, and unit testing.

If you’re not familiar with the tenets of PWA, check out our ultimate guide to progressive web applications.

To install vue-cli run:

npm install -g vue-cli

Next, you need to initialize your project. When you run the vue init command just accept all the default values.

vue init pwa my-vue-app
cd ./my-vue-app
npm install
npm run dev

Point your favorite browser to http://localhost:8080 and you should see the fruits of your labor:

Extra Credit: Check out the other templates available for vue-cli.

Install Bootstrap

Let’s install bootstrap-vue so you can take advantage of the various premade components (plus you can keep the focus on functionality and not on custom CSS):

npm i --save bootstrap-vue bootstrap

To complete the installation, modify ./src/main.js to include bootstrap-vue and import the required CSS files. Your ./src/main.js file should look like this:

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(BootstrapVue)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

Add Authentication with Okta

Dealing with authentication in a web app is the bane of every developer’s existence. That’s where Okta comes in to secure your web applications with minimal code. To get started, you will need to create an OIDC application in Okta. Sign up for a forever-free developer account (or log in if you already have one).

Once logged in, create a new application by clicking “Add Application”.

Select the “Single-Page App” platform option.

Continue reading %Build a Basic CRUD App with Vue.js and Node%



Salı, 29 Mayıs 2018 / Published in Uncategorized

This article was created in partnership with JotForm. Thank you for supporting the partners who make SitePoint possible.

The Problem

It all started in October 2017, when we were searching for HackWeek project ideas.

Our team at JotForm noticed that our new form design, JotForm Cards, didn’t look as good as a standalone version when it was embedded in a user’s website. Uh oh.

Basically, the design of JotForm Cards wasn’t a great fit for the website in question. Although the form itself looked beautiful, using the design in a context that was so different to the standard use case was ruining it.

And as we continued embedding JotForm Cards into websites, we became aware that this situation was pretty common. Double uh oh.

We noticed things like forms being squeezed into columns…:

And feature colors that didn’t match the website:

And repeated titles with different typefaces.

These issues don’t seem huge at first glance, but because we only had our 7 day HackWeek to fix them, we were nervous, real nervous.

Structure

Before I dive into implementation, I’ll share some structural information about JotForm Cards.

The styling structure on the front-end uses SCSS (basically SASS with fancy syntax) as a preprocessor and PostCSS as post processor. The remaining front-end structure (markup, logics) is mostly based on React.

Side note: the CSS files of the forms are prepared and served by PHP, which is the main back-end language for this implementation.

Challenges

We decided to automate the design to achieve the following goals:

Continue reading %How to Automate a Design%



Salı, 29 Mayıs 2018 / Published in Uncategorized

This article was created in partnership with KTree. Thank you for supporting the partners who make SitePoint possible.

This article discusses various features that are essential for your eCommerce store’s search engine. If your store search experience is bad, your customer might hop to the next available site to make that purchase.

If you have huge a product catalogue, optimizing and organizing it and improving the search experience is key to the success of your store, and is the most important job of the eCommerce manager. Before we go further, let’s go over some key terms which will help us understand the article better:

  • Category listing page or catalogue listing page: A list of products segregated based on category with filters/facets typically on the left side.
  • Search result page: This is similar to a category listing page. The only difference is that the list of products may come from different categories.
  • Customer: One who is visiting the site to make a purchase from your ecommerce store.
  • Filter/facet: These are the options usually displayed on the left, up top, to narrow down product listings.
  • Admin: You or your store eCommerce manager.

Minimum eCommerce Search Engine Features

Breadcrumb navigation

Breadcrumb navigation helps users get back to the previous category or page. This is normally available in ecommerce or CMS applications.

Facets

Facets give users the ability to iteratively refine or expand their search results and ultimately helps the user to browse the list of products which he intended to quickly. This filtering is now usually done via Ajax or using Single Page Applications to make the results load faster.

  1. Refine or expand results
  2. Show the count for each filtering option
  3. Show only popular filtering options — for the rest, provide a ‘More’ link.
  4. Show certain filtering options as a range of values

  1. These facets/filters are product attributes and they should be configurable, meaning a product attribute should have config settings to make it searchable and to show as facet or filter in the catalogue list view.

Sort By

Users should be able to sort the search results. For example, sort Price (Low to High) helps the user find products in the budget range they’re looking for.

Various ‘Sort By’ options which are normally found in eCommerce search engines:

  • Price (Low – High)
  • Brand (A – Z)
  • Best match
  • Created date
  • Category
  • Sorting order options, such as newly added products first
  • Sort by reviews
  • Sort by best sellers
  • Recommended products
  • Featured

Auto-suggest Functionality

Made popular by Google’s search engine, this helps the user to choose the product based on a few letters entered. This helps customers search products with keyword or partial key terms, or some other attribute of the product. Typically, this is one of the most used features that customers use to search for products.

In auto-suggest, these can be displayed:

  • Search terms: These are the terms that were already searched by other users on your sites. These can be created by store admins, and if necessary synonyms can be added to search terms. See the next picture.

  • Actual products.

  • Attributes of the products, such as color or size.

  • If there is no result, or too few results, we can correct the user by using ‘Did you mean’ or auto-correct functionality.

    Other advanced eCommerce search functionalities:

    • Search within result
    • Enhance search with snippets & highlights
    • Enhance search with redirects to a particular page

    What Technical Products Are Best for Search Engines?

    There are plenty of choices for implementing search engines, and again it depends on your eCommerce application and the language which it is written in. In general, these are good suggestions:

    • A regular database (MySQL, PostgresQL, MongoDB).
    • Sphinx: Sphinx is a full text search engine that provides text search functionality to client applications.
    • Apache SOLR: Open-sourced by Apache, SOLR is a merged effort of the former SOLR and Lucene. This is also one of amongst the popular option available.
    • ElasticSearch: ElasticSearch is currently the number one leader in the search market. This product is also open source, and also a fork of Lucene.
      • Inbuilt cluster.
      • Has many features out-of-the-box.
      • Plugins are typically available for major ecommerce platforms such as Magento and OpenCart.
    • Amazon ES service: Amazon AWS’s provided service for ElasticSearch.
    • Amazon CloudSearch: An Amazon AWS product, can be used as a solution for your eCommerce search engine.

    Continue reading %eCommerce Search & Personalization%



Salı, 29 Mayıs 2018 / Published in Uncategorized

How to Build an Agile Team for Your Software Development Project

Agile companies believe that teamwork is essential to delivering

working software

, and that great Agile teams are about “we” rather than “I.” Unfortunately, many companies claim they have an Agile team, but in reality they don’t. It’s important to learn what an Agile team really is, and to find ways to build them within your own company.

It takes a while to transform a group of people into a real Agile team. However, it pays off later on, as Agile project management brings a lot of value to the team and to the client.

Let me just mention the most common Agile benefits: 93 percent of teams said Agile helped them improve speed to market, 93 percent said it helped them switch gears more quickly and effectively, 87 percent said it helped them to be more productive, 80 percent said Agile led to enhanced prioritization of the things that matter, and 80 percent said adopting Agile helped them deliver a better and more relevant end product.

One of the key success factors is to provide continuous mentoring and shared skill sets.

When team members learn from each other, it makes the process of Agile transformation much easier and more pleasant.

Qualities of an Agile Team

More than anything, teams should understand that change is inevitable. Being able to adapt to rapidly changing circumstances is key for Agile development and Agile project management.

Able to Incorporate Feedback Quickly

This change most often comes from receiving and giving feedback. Feedback is one of the essential parts of Agile development. It doesn’t matter how fast you can deliver the desired product or feature; if it is not in demand anymore, everything that the team has done may simply go to a rubbish bin. And unfortunately, that happens a lot in software development.

How does it feel when you actually face a situation where a project you have been working on for some time won’t be published or used? It’s very frustrating and disappointing.

So, in order to be on track with your stakeholders, you need to constantly communicate with them; therefore, feedback is highly related to internal and external communication.

But for Agile teams, you can’t just listen to the feedback. You also need to incorporate it quickly. Feedback, in an Agile sense, is about short-term advances.

Normally, we are talking about two-week sprints—optimal time to code, test, and get feedback on the most important functionality. It also helps to launch quality minimum viable product faster and get return on investment faster.

Work Together as a Team

There is a very good saying: “If you want to go fast, go alone. If you want to go far, go together.” And in Agile software development, this is crucial. You learn from your peers even more than from books and courses.

A very important part of building an Agile team is to empower the team to work independently.

Not only does this give all the team members a sense of belonging and ownership, it also shows trust and respect.

At the end of each sprint, there are always features that you need to deliver. When teams work using Scrum methodology, they have user stories; tickets they need to move from “to do” to “done.” And when all of them are on the stage “done,” it motivates team members, as they can actually see the result of what they are working on. By placing more emphasis on the results, team members feel empowered to make decisions, solve problems, and develop innovative solutions.

Goals in every Agile team are different. At Apiumhub, we put working software over a number of functionalities, always doing test-driven development (TDD) and continuous integration (CI). Having goals helps Agile teams see the progress and move forward in the right way.

The best way to help make these goals clear is having a product owner role on an Agile team. I strongly believe that it is a must nowadays. The product owner is responsible for the business direction of the product, and they are responsible for creating and prioritizing the user stories. The development team is responsible for the technical direction of the product, and the tech team will actually deliver these user stories.

However, it is important to note that the product owner always takes into account the feedback of the tech team regarding the priorities of user stories.

Be Organized and Use Tools

Being Agile is about efficiency and automation. The fewer manual tasks that are done, the better. That means that using such tools as Jira is a big must. You can find other Agile project management tools here. Being Agile also means having several important meetings during the sprint: sprint planning, sprint review, sprint retrospective, and, of course, daily standups. Having meetings often means that there is a higher likelihood that everyone understands their role and what they need to achieve.

Each Agile team has its own definition of “done.” But every Agile team needs to agree on what they consider to be “done.” It is key to delivering high-quality products and satisfying your stakeholders in terms of project management and results, and functionalities and quality. Basically, it is a checklist of features and activities that adds or demonstrates value and that needs to be completed.

As we mentioned in the beginning of the article, unfortunately, many teams try to be Agile, but they fail. In the software development world, based on our experience, it’s very important to learn best practices, and to be truly Agile, you must practice TDD, CI, and

unit testing

.

There are actually common stages that the team goes through to become an Agile team. Let’s look at them.

How To Build an Agile Team

Creating an Agile team takes time, and members often go through different stages from being just a group of people to an Agile team with common goals and right processes. I don’t want to reinvent the wheel here; let me just share with you Bruce Tuckman’s stages, highlighting the important things to better understand them. They will definitely help you make your team more effective.

Forming Stage

The first stage is the forming stage, which is very similar to orientation day at universities. It is essential and helps people get to know each other, find useful information, and write down the rules. This stage is about focusing on defining and assigning tasks, establishing a schedule, organizing the team’s work, etc.

Storming Stage

Being on a team is like being in a relationship. At first, you may think that a person is perfect, but then you realize they actually are not. And then you either learn to manage the relationship or it will end quickly. This stage is also about goals and guidelines that each team should follow to be on the same wavelength and achieve the common goal. In this stage, teams brainstorm ideas to find solutions to the issues they have.

Norming Stage

In this stage, team members develop their purpose and strategy for achieving their goals. This is when everyone is focused on developing shared values and determining ways to best work together. People start to notice and appreciate their team members’ strengths and everyone contributes and works as a cohesive unit.

Performing Stage

In this stage, team members are confident, motivated, and able to easily work together on interdependent tasks. It also gets easy for them to communicate and coordinate with each other in an effective manner. Basically, the fourth stage is the one that all Agile teams strive to reach.

Team-Building Activities for a More Agile Team

Games are fun and they are very effective for team building. Here are some examples of the games that are quite short, but very effective. Let’s look at the most famous ones:

Buy a Feature

This game teaches feature prioritization and it takes around 15 minutes to play. The optimal number of people for groups is three to eight. Each player receives two items: a handout with a menu of features and their prices, and a sum of play money.

Features can be anything, for example: items to have on a vacation. The sum total of all players’ money should be less than the total of all feature prices. This introduces scarcity and forces the team to make trade-offs, because it’s not possible to purchase all items on the list.

Players take turns using their individual sums of money to pay for features they find most valuable. Once players have spent most of their funds, and either they don’t have enough individually to make another purchase or they don’t value what’s left on the menu to buy anything else, the group will pool the remaining funds and discuss what to buy from the remaining items. This game helps team members to learn how to prioritize user stories and how to do resource management.

The White Elephant Sizing

In all software projects, Agile teams need to estimate user stories as well as product backlog. And this game is fantastic to learn how to estimate user stories. In this Agile game, players have 50 user stories and have four hours to estimate them. Everyone’s voices are heard, and everyone contributes equally.

The goal of this game is to get a quick estimate of the size of an Agile project and the size of the individual stories before the project starts. I believe this game is absolutely a must, as most Agile teams have issues with estimating their projects in terms of time.

Battleships

This Agile game is generally used to introduce people to iterative development and to explain the concepts behind it. The idea is to get people to understand that up-front, large plans are just not a good idea!

In this game, you have two teams: A and B. Each will have a “battleships sheet” and some dots. Each team will have around two minutes to plan how they would like to place their ships. Team A will have five minutes to plan its hits up front and will mark them on their sheet, and will then communicate them to Team B, which will tell Team A which ships sunk, hits that missed, etc. Team B then also gets five minutes to play each one of their hits, but this time with real-time feedback from Team A on misses, hits, and ships that sunk.

Results are obvious. Team B gets the chance to change its plans due to the fact that they follow iterative rules, which will make them score higher. It seems obvious in this game; however, many teams forget it when they work on real projects.

The Ball Point Game

This game helps a lot when introducing Scrum to new Agile teams. It helps to estimate user stories, sprint, and the project overall.

The rules are simple: You need to give the team as many balls as possible in two minutes. Each ball has to pass by each team member. In order to get a point, it’s important that the first person who gets the ball be the last one to touch it. So the team will get five iterations, and before each one, it has to estimate how many balls they believe will be passed. Then, the actual number is recorded at the end of each iteration and is compared with the estimations given by the team.

Often, at the first iteration, it is very difficult to give an estimation, as the team doesn’t really know how long it may take to get one ball through the whole team. But, after each iteration, there are retrospectives, and therefore the team adapts the process. With each iteration, normally, the results become better and better. This game helps Agile teams work together and learn how to make estimations, taking into account not only personal capabilities, but also capabilities of the team as a whole. Also, it helps to understand the need for iterative progress and development.

Build an Agile Team to Streamline Software Development

Statistics say that by using Agile project management, on average, the time to market is 37 percent faster and the efficiency of an Agile team is increased by 16 percent.

Switching to Agile is a great idea and I really hope this article gave you a good overview of what it is and how you can master it. And if you know other interesting Agile games, feel free to share them in the comments section below.

Salı, 29 Mayıs 2018 / Published in Uncategorized

8 Non-Programming Books That Will Boost Your Programmer Career

There are

many lists of books about becoming a better programmer

. They likely include books like Refactoring, Code Complete, The Mythical Man Month, etc.

However, in the workplace, it isn’t just programming knowledge that we programmers need. Learning programming is an essential part of our work — but it’s not everything.

The authors of iconic programming books had remarkable careers, but it wasn’t just their coding knowledge that made their careers noteworthy. They were well-rounded experts and we should strive to emulate that quality as well.

The difficulty with non-programming books that are important for programmers is that they fall into that nebulous category of “we don’t know what we don’t know.” These books won’t figuratively have our names written on them.

Instead, we have to seek them out. Often, we find these books through recommendations of trusted friends. The following books are some of my favourite non-programming books that have made a big impact in how I approach my work.

How — precisely — have they made an impact? Well, all of these books are about taking a higher-level perspective on yourself and your work. They won’t tell you how to solve a specific problem; instead they’ll give you the tools you need so that you’re prepared when you see the problem emerge. Winston Churchill said it best:

“To each there comes in their lifetime a special moment when they are figuratively tapped on the shoulder and offered the chance to do a very special thing, unique to them and fitted to their talents. What a tragedy if that moment finds them unprepared or unqualified for that which could have been their finest hour.”

We want to prepare ourselves for these situations, so let’s take a look at eight non-programming books you should read to boost your programming career.

Note — I wouldn’t recommend a product I do not own nor use. I own all of these books and they are covered with my own notes. If you choose to buy one, I suggest you do the same. These are not books to be read once and tossed aside.

I wasn’t kidding.

DevOps is a movement, a culture change, a mindset. It is not tooling.

The DevOps Handbook is a nonfiction companion to The Phoenix Project. The Phoenix Project is a novel about how an IT organization falls apart and then is put back together with DevOps practices.

Personally, I found the novel format of The Phoenix Project dense and obtuse whereas the DevOps Handbook is far more practical and usable. The DevOps Handbook talks you through the important notion of a value stream, which is essentially the full flow of how work comes in and out of a business. Think of it like the production line of a technology business.

As a programmer, we’re at the heart of this value stream — so we’re often made responsible for the outcomes, which is usually, but not always, a product.

Ownership of the value stream shouldn’t be a programmer’s job. But that’s a whole blog post in itself. Irrespective of who should rightly own the value stream, programmers are often left in the tricky position of being held responsible for it. So we need to understand not only what the value stream is, but also how to optimise it.

The DevOps Handbook gives you many different ways you can optimise this value stream, including things like “value stream mapping” (making the value stream visible) and optimizing our deployment processes.

Scrum is a very widely adopted framework in the software world and this book is a great intro to the Scrum framework.

Most other Scrum books dive straight into the mechanics of working in a Scrum format. This book, on the other hand, takes the time to explain the origins and the meaning behind the framework.

The purpose of Scrum is far more important than understanding the precise roles, artifacts, etc.

Why? Because knowing the rules is different than embodying them. Unfortunately, many programmers do still dive straight into the Scrum framework without understanding the origins and the purpose.

This leads to confusion as practitioners start barking orders for a 15-minute meeting every morning without really knowing why we need Scrum in the first place. This notion I’ve explained in greater detail in this article.

Read the book, understand the purpose, and be a better practitioner.

My favourite quote, and one that could possibly sum up the The Fifth Discipline, is this:

“Different people in the same systems produce similar results.”

I’ve watched this quote come to life many times before, and after reading The Fifth Discipline. For instance: When a company lets a developer go, and then hires a new developer into the same team and the same business, interestingly the same results appear again.

At this point you might be wondering why team structure is important to you as a programmer.

Because if not, we can fall into the trap of seeing ourselves as only our little role in a much bigger machine that we believe is out of our control. If we fail to see, and address, the bigger picture (the system), the results and impact we have are limited. We could be that new hire, brought into a new team and doomed to failure — no matter how good we are.

The solution? To understand and be able to communicate the difficulties presented in complex systems and how to solve them. Cultivate a system mindset that goes beyond complaining about the other teams “not doing their job,” and instead think about how the way we have set up our organization is affecting us more than we realise.

Every organisation has politics. It’s an irrefutable fact.

When it comes to politics, you have two choices: You can take the blue pill and pretend power plays do not exist. Or, alternatively, you can take the red pill and dive into the world of power, to understand it.

Interestingly, the author Robert Greene even argues that the denial of power plays is in itself a power play. I’ll leave you to ponder this statement.

The 48 Laws of Power presents 48 different ways that people use and wield power. Greene takes you through each one in detail with in-depth stories from history that demonstrate the power play. To top off each chapter, Greene closes with a reversal, an argument in opposition to each power play.

Admittedly, on my first read, I didn’t really “get it.” However, when I came back to it (after working for a company for a few years), a lot of the ideas started to click. I could relate to the different power plays and how I’d seen them act out in the workplace. So don’t quit on the book before giving it a real go. Once it clicks, you’ll understand what I mean. The 48 Laws of Power is not a newspaper, nor is it a Buzzfeed article — it’s not meant to be an easy read, but it will be worth it.

Nassim Nicholas Taleb once said “Never read a book you would not reread.” The 48 Laws of Power falls in this category. It simply cannot be read only once. And for that reason, I’d recommend getting a hard copy and keeping it for life. As each time you re-read it, you’ll relate different areas to your new experiences.

I believe the best programmers are also teachers.

These programmers have an abundance mindset, rather than a scarcity mindset. Knowing that sharing knowledge and helping others will in fact help them in return rather than act against them.

The Coaching Habit is a very straightforward and practical introduction to ideas of coaching. It takes you through seven individual questions that you can ask another programmer as part of a coaching session, or in more general conversation.

These are questions like: “What’s on your mind?” and “What’s the real problem here for you?” Don’t be fooled into thinking these are just a few questions thrown together haphazardly. Each question is carefully crafted to ensure that you can have the biggest impact on others.

It’s seriously like having Jedi mind powers.

The Coaching Habit is recommended reading for anyone who works with people (read: everyone). And if you’re still not convinced, I’ve previously translated the coaching questions to show how they’re useful for a programmer, specifically.

Sprint takes you through a five-day set of exercises, starting with brainstorming ideas/features and prioritizing one of them; then, you’ll elicit the main ideas, sketch it, design it, prototype it, and test it.

It’s a very practical and full framework.

Often all we need is some basic structure when it comes to our “ways of working,” as it prevents us arguing and debating in endless circles. Instead, you can propose to your team: Shall we run a design sprint? And then take the team through this method step by step.

Whether you run these types of workshops in their entirety or not, this book can serve as great inspiration for how to align stakeholders and get to a functioning product.

If you’re not familiar with the ideas of The Lean Startup and you’ve already started writing code, you might have already made a terrible mistake in doing so.

The Lean Startup has now become somewhat of a classic in software and products. It advocates that all ideas are just opinions until proven otherwise, which means that we need to test our ideas aggressively before we pursue them to ensure that we’re not being clouded by faulty judgement, or leading with ego.

If you think you’ve got decent proof that your product or feature will be a success, think again. Author Eric Ries will challenge you to think of faster and cheaper ways to get validation on your product before you start building it.

Why is validation important? Because building products can be incredibly expensive. Not only that, but once built, code is notoriously difficult to change. So building the right product and features is essential from the beginning. There are so many ways we can validate ideas without writing any code at all, such a: paper prototypes, splash pages and guerilla/hallway user testing.

You might be thinking about now: Does the idea of constant validation mean that companies will need fewer programmers?

Not at all.

In fact, it means that programmers’ time will be spent more effectively on activities like being creative and thinking of ways to build prototypes, demos, and splash pages. It also means that when it comes time to build, there’s less chance that the business will come back to the programmers every five minutes for re-work, or worse, to blame programmers for a failed product.

All new products and features are simply opinion until proven a success. Before you, or anyone who works with you, start writing any code, read this book.

The other books I’ve presented have been more about the organizations that we work for, rather than about our own self and our career.

Key Person Of Influence takes you through five steps that influential people have taken (knowingly or unknowingly) to rise to the top of their industry.

Being at the top of an industry means getting better opportunities with less (or no) struggle and being rewarded appropriately. No more fighting with your employer for a raise or debating with your boss to showcase your value. With author Daniel Priestley’s five steps, your value will become crystal clear to you, and then Priestley takes you through how you can then showcase this value to others.

Priestley argues that you are already “standing on a mountain of value.” All of your experiences, stories, ideas, and information to date is worth more than you realize. But, you just can’t see the mountain. Why? Because you’re standing on it!

I cannot overstate the impact this book has had on my career thus far. And I believe it’s only the beginning. After reading the book, I realized that I wasn’t taking the most effective steps to build my own career. As soon as I finished it, I put it down and created a plan that will span my entire career. I now consider this book to be the backbone of that plan. All other books seem to slot in to the plan I have created around the five steps that Priestley outlines.

Just like with the laws of power, you can choose to ignore the ideas presented in the book. But, the five steps of the book line up with the career history of any person of influence in any industry.

Ignore this book at your own peril.

Your Finest Hour

There you have it, the best books I’ve read so far that aren’t directly related to writing code.

Be wary not to fall in the trap thinking that more coding knowledge is what you need. It is very likely that one of these books presents the breakthrough you didn’t even know you needed.

Whether that is fighting a political battle with the 48 Laws of Power or realizing that your organization has a systemic issue and starting to tackle it with the Fifth Discipline and The DevOps Handbook. Or putting in place a grand strategy for your career with Key Person of Influence.

Ignoring books, especially these books, might buy you a little time in the short term but can prove to be devastatingly costly in the long run if you’re not careful.

If you read these books, when your figurative tap on the shoulder comes, you will be ready.

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

Salı, 29 Mayıs 2018 / Published in Uncategorized

Top 50 Coding Interview Questions

There are a lot of computer science graduates and programmers applying for programming, coding, and software development roles at startups like Uber and Netflix;

big organizations like Amazon, Microsoft, and Google

; and service-based companies like Infosys or Luxoft, but many of them have no idea of what kind of coding questions are expected in the interviews with these companies.

In this article, I’ll share some frequently asked coding interview questions from different interviews for programmers at different levels of experience, from people who have just graduated from college to programmers with one to two years of experience. 

Coding interviews are comprised mainly of data structure and algorithm-based questions as well as some of the logical questions such as, How do you swap two integers without using a temporary variable?

I think it’s helpful to divide coding interview questions into different topic areas. The topic areas I’ve seen most often in interviews are array, linked list, string, binary tree, as well as questions from algorithms (e.g. string algorithm, sorting algorithms like quicksort or radix sort, and other miscellaneous ones), and that’s what you will find in this article.

It’s not guaranteed that you will be asked these coding or data structure and algorithmic questions, but they will give you enough of an idea of the kinds of questions you can expect in a real programming job interview.

By the way, the more questions you solve in practice, the better your preparation will be. So, if you think 50 is not enough and you need more, then check out these additional 50 programming questions for telephone interviews and these books and courses for more thorough preparation.

Once you have gone through these questions, you should feel confident enough to attend any telephonic or face-to-face interviews.

Without any further ado, here is my list of some of the most frequently asked coding interview questions from programming job interviews:

Array Coding Interview Questions

An array is the most fundamental data structure, which stores elements at a contiguous memory location. It is also one of the darling topics of interviewers and you will hear a lot of questions about an array in any coding interview, e.g. reversing an array, sorting the array, or searching elements on the array.

The key benefit of an array data structure is that it offers fast O(1) search if you know the index, but adding and removing an element from an array is slow because you cannot change the size of the array once it’s created.

In order to create a shorter or longer array, you need to create a new array and copy all elements from old to new. The key to solving array-based questions is having a good knowledge of array data structure as well as basic programming constructors such as loop, recursion, and fundamental operators.

Here are some of the popular array-based coding interview questions for your practice:

  1. How do you find the missing number in a given integer array of 1 to 100? (solution)
  2. How do you find the duplicate number on a given integer array? (solution)
  3. How do you find the largest and smallest number in an unsorted integer array? (solution)
  4. How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
  5. How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
  6. How are duplicates removed from a given array in Java? (solution)
  7. How is an integer array sorted in place using the quicksort algorithm? (solution)
  8. How do you remove duplicates from an array in place? (solution)
  9. How do you reverse an array in place in Java? (solution)
  10. How are duplicates removed from an array without using any library? (solution)

These questions will not only help you to develop your problem-solving skills but also improve your knowledge of array data structure. And if you feel 10 is not enough questions and you need more practice, then you can also check out this list of 30 array questions. 

Linked List Coding Interview Questions

A

linked list

is another common data structure that complements the array data structure. Similar to the array, it is also a linear data structure and stores elements in a linear fashion. However, unlike the array, it doesn’t store them in contiguous locations; instead, they are scattered everywhere in memory, which is connected to each other using nodes.

A linked list is nothing but a list of nodes where each node contains the value stored and the address of the next node.

Because of this structure, it’s easy to add and remove elements in a linked list, as you just need to change the link instead of creating the array, but the search is difficult and often requires O(n) time to find an element in the singly linked list.

This article provides more information on the difference between array and linked list data structures.

It also comes in varieties like a singly linked list, which allows you to traverse in one direction (forward or reverse); a doubly linked list, which allows you to traverse in both directions (forward and backward); and finally, the circular linked list, which forms a circle.

In order to solve linked list-based questions, a good knowledge of recursion is important, because a linked list is a recursive data structure.

If you take one node from a linked list, the remaining data structure is still a linked list, and because of that, many linked list problems have simpler recursive solutions than iterative ones.

Here are some of the most common and popular linked list interview questions and their solutions:

  1. How do you find the middle element of a singly linked list in one pass? (solution)
  2. How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle? (solution)
  3. How do you reverse a linked list? (solution)
  4. How do you reverse a singly linked list without recursion? (solution)
  5. How are duplicate nodes removed in an unsorted linked list? (solution)
  6. How do you find the length of a singly linked list? (solution)
  7. How do you find the third node from the end in a singly linked list? (solution)
  8. How do you find the sum of two linked lists using Stack? (solution)

These questions will help you to develop your problem-solving skills as well as improve your knowledge of the linked list data structure. You can also check out this list of 30 linked list interview questions for more practice questions.

String Coding Interview Questions

Along with array and linked list data structures, a string is another popular topic on programming job interviews. I have never participated in a coding interview where no string-based question was asked.

A good thing about the string is that if you know the array, you can solve string-based questions easily, because strings are nothing but a character array.

So all the techniques you learn by solving array-based coding questions can be used to solve string programming questions as well.

Here is my list of frequently asked string coding questions from programming job interviews:

  1. How do you print duplicate characters from a string? (solution)
  2. How do you check if two strings are anagrams of each other? (solution)
  3. How do you print the first non-repeated character from a string? (solution)
  4. How can a given string be reversed using recursion? (solution)
  5. How do you check if a string contains only digits? (solution)
  6. How are duplicate characters found in a string? (solution)
  7. How do you count a number of vowels and consonants in a given string? (solution)
  8. How do you count the occurrence of a given character in a string? (solution)
  9. How do you find all permutations of a string? (solution)
  10. How do you reverse words in a given sentence without using any library method? (solution)
  11. How do you check if two strings are a rotation of each other? (solution)
  12. How do you check if a given string is a palindrome? (solution)

These questions help improve your knowledge of string as a data structure. If you need more practice, here is another list of 20 string coding questions.

Binary Tree Coding Interview Questions

So far, we have looked at only the linear data structure, but all information in the real world cannot be represented in linear fashion, and that’s where tree data structure helps.

Tree data structure is a data structure that allows you to store your data in a hierarchical fashion. Depending on how you store data, there are different types of trees, such as a binary tree, where each node has, at most, two child nodes.

Along with its close cousin binary search tree, it’s also one of the most popular tree data structures. Therefore, you will find a lot of questions based upon them, such as how to traverse them, count nodes, find depth, and check if they are balanced or not.

A key point to solving binary tree questions is a strong knowledge of theory, e.g. what is the size or depth of the binary tree, what is a leaf, and what is a node, as well as an understanding of the popular traversing algorithms, e.g. pre-, post-, and in-order traversal.

Here is a list of popular binary tree-based coding questions from software engineer or developer job interviews:

  1. How is a binary search tree implemented? (solution)
  2. How do you perform preorder traversal in a given binary tree? (solution)
  3. How do you traverse a given binary tree in preorder without recursion? (solution)
  4. How do you perform an inorder traversal in a given binary tree? (solution)
  5. How do you print all nodes of a given binary tree using inorder traversal without recursion? (solution)
  6. How do you implement a postorder traversal algorithm? (solution)
  7. How do you traverse a binary tree in postorder traversal without recursion? (solution)
  8. How are all leaves of a binary search tree printed? (solution)
  9. How do you count a number of leaf nodes in a given binary tree? (solution)
  10. How do you perform a binary search in a given array? (solution)

If you feel that your understanding of binary tree coding is inadequate and you can’t solve these questions on your own, I suggest you go back and pick a good data structure and algorithm book. If you need some recommendations, here is my list of useful data structure algorithm books and courses to start with.

Miscellaneous Coding Interview Questions

Apart from data structure-based questions, most of the programming job interviews also ask algorithm, design, bit manipulation, and general logic-based questions, which I’ll describe in this section.

It’s important that you practice these concepts because sometimes they become tricky to solve in the actual interview. Having practiced them before not only makes you familiar with them, but also gives you more confidence in explaining the solution to the interviewer.

  1. How is a bubble sort algorithm implemented? (solution)
  2. How is an iterative quicksort algorithm implemented? (solution)
  3. How do you implement an insertion sort algorithm? (solution)
  4. How is a merge sort algorithm implemented? (solution)
  5. How do you implement a bucket sort algorithm? (solution)
  6. How do you implement a counting sort algorithm? (solution)
  7. How is a radix sort algorithm implemented? (solution)
  8. How do you swap two numbers without using the third variable? (solution)
  9. How do you check if two rectangles overlap with each other? (solution)
  10. How do you design a vending machine? (solution)

Now You’re Ready for the Coding Interview

These are some of the most common questions outside of data structure and algorithms that help you to do really well on your interview. If you need more examples of such questions, I suggest checking out my list of top 30 programming interview questions.

I have also shared a lot of these questions on my blog, so if you are really interested, you can always go there and search for them.

 These common coding, data structure, and algorithm questions are the ones you need to know to successfully interview with any company, big or small, for any level of programing job.

If you are looking for a programming or software development job in 2018, you can start your preparation with this list of coding questions.

This list provides good topics to prepare and also helps assess your preparation to find out your areas of strength and weakness.

A good knowledge of data structure and algorithms is important for success in coding interviews and that’s where you should focus most of your attention. If you need some resources, you can check out this list of free data structure and algorithm courses to start your preparation.

Salı, 29 Mayıs 2018 / Published in Uncategorized

Importance of Programming in Focused Time Blocks

In this day and age, there are a seemingly infinite number of things that are pulling your attention to various places. With the invention of the computer and the internet, people are always trying to take your focus through texting, calling, social media, forums, and email.

You name it, there are tons of ways you can get distracted. It has made the ability to focus an extremely scarce skill to find in people, which in hand has made it all the more valuable.

Luckily, there are ways to improve your focus, such as working in time blocks. It’s incredibly important to work in focused time blocks as a programmer, and I’ll be describing how I do it so you can start getting more done in less time today!

Why Work With Complete Focus?

Most programmers work with their phone on their desk, and as soon as they get a text or call they answer right away. They completely interrupt their train of thought on the code they were working on.

Now, answering to your family or friends is probably really important to you. You are probably sitting there thinking, “What’s the harm in answering right now? I’ll just take a quick second, then I’ll pick right back up where I left off.” This is not the case. What is happening here is you are switching tasks. This comes with plenty of detrimental effects.

You end up reducing your productivity by about 40 percent by attempting to multitask. On top of that, you are not really multitasking; you are simply doing one thing, switching tasks to the second thing, and then switching back. Doing this increases the likelihood of you making errors in both tasks and also increases the time it takes to get the tasks done.

This is especially true for tasks that are complex and take more brain power, which is exactly what is happening when you are programming that project at work. As programmers, we tend to develop applications that involve plenty of math and we are writing in a different language.

If you are trying to develop anything great, you will need deeper focus which will allows you to come up with solutions faster and more holistically. If you interrupted those thoughts, you might not have come up with a solution as robust because each time your brain switches tasks you have to spend time getting back to where you were previously.

So, now you see that this constant switching between your work and social life can have plenty of bad effects. How then should we work in order to increase our accuracy and productivity while developing the world’s next best application?

Prerequisites: Set Up Your Environment

So, there are some things you should start doing right now before you get to work. First: remove distractions. This means all distractions—so don’t hang onto the ones you want to keep.

For instance, if you have a TV in your room and you love to binge-watch Silicon Valley, then I suggest you do your work somewhere else. The goal of this step is to make it extremely difficult for you to become distracted. You don’t want to make it easy for your focus to get interrupted.

I grab some headphones and listen to music to block out external noises. I take my phone and place it out-of-reach and put it in Do Not Disturb mode or Silent. I make sure that I do not have a view of something that would distract me, like a TV in the background or a window that is overlooking people playing a sport outside. Once this step is done, you can move on to getting the things you need.

As a programmer, I like to have my laptop with at least one extra monitor and a notebook to take notes on application programming interfaces (APIs) or to work through an algorithm I may be struggling with. Also, I make sure to have some water handy and a charger for my computer so the battery won’t die.

Really, these steps will differ from person to person based on the distractions in their environment and the materials they may need to work. I suggest listing all possible things that could distract you and remove them from your environment, and list all the things you need and grab them.

Now on to how to actually spend the time you are going to be working!

Set a Goal with a Time Limit

One thing I came across that changed my mindset when it came to getting things done is Parkinson’s Law. It states that the work you do will expand to fill the time allotted for it.

For example, if you are given a deadline to finish making changes on your feature branch by Friday of this week, you will find a way to get it done in that time period. I have started implementing this in my life and found how powerful it actually is.

Now, how do we use this law in our day-to-day work?

I tend to ask myself this question: “What is the one thing that I could do right now that would make the rest of my day easier?” Asking this helps you to focus on one thing that can have the greatest benefit for your entire day. Once you have answered it, pick a time period that you think you can get that task done in. Then I would suggest you try to cut that time period even more.

Now, start working with that goal in mind, and attempt to get the task complete in the time period you have allotted.

Let’s say you are working on a bug fix for your company’s web application. For some reason, the user’s address is not displaying properly and it shows a different user’s address information.

If you are experienced with databases (especially the one you are currently working with) and web development, then you may think you can fix this bug within a half-hour. Then, using what you just learned, you cut this down to 25 minutes.

In three minutes, you remove your distractions and set up your environment for the day. You then set a timer for 25 minutes and get straight to work.

At the end of that time period, you solve the bug with a couple of minutes to spare. You were highly focused, never got distracted, and were able to analyze a complex situation extremely fast.

Get Focused Today!

Now, after reading this, I hope you are thinking about the different ways you can take your phone and hide it so you will not get distracted.

Can you imagine all the hours you spent not being at high productivity? You lost 40 percent of that time that you simply will not get back. Not anymore, though!

As programmers, working in focused time blocks is even more important. We solve complex problems day-in and day-out. In order to be able to solve these problems accurately and efficiently, we must focus on one goal at a time, tackle it in a timely manner, and move onto the next difficult task.

Today is the day you stop getting distracted. Go set up your environment for success, and use focused time blocks in order to become a productive programmer!

Salı, 29 Mayıs 2018 / Published in Uncategorized

I’m sure answers are jumping to mind, but hear me out, please. The use of Null in a purely logical landscape is problematic. It’s been called The Billion Dollar Mistake and The Worst Mistake of Computer Science. The NullReference Error is the runtime bane of .NET developers everywhere, and I would assume Java too.

Logically-speaking, there is no such thing as Null, yet we’ve decided to represent it in our programs. Now, before you jump on Twitter and @ me with all kinds of explanations, please know that I’ve been programming for 25 years in both functional and OO settings. I find that the people I talk to about this instantly flip on the condescension switch and try to mansplain this shit to me as if.

Null is a crutch. It’s a placeholder for I don’t know and didn’t want to think about it further in our code and this is evidenced by it popping up at runtime, shouting at us exceptionally saying “ARE YOU THINKING ABOUT IT NOW?”.

Scott Hanselman has a great post which discusses abstraction and our willingness to dive into it:

My wife lost her wedding ring down the drain. She freaked out and came running declaring that it was lost. Should we call a plumber?

I am not a plumber and I have no interest in being a plumber. While I advocate that folks try to be handy around the house, I choose to put a limit on how much I know about plumbing.

While my wife has an advanced degree in something I don’t understand, she also, is not a plumber. As a user of plumbing she has an understandably narrow view of how it works. She turns on the water, a miracle happens, and water comes out of the tap. That water travels about 8 inches and then disappears into the drain never to be seen again. It’s the mystery of plumbing as far as she is concerned.

Null is every programmer’s sink drain. The point at which they don’t want to think further into the business problem in order to decide what a value means, or what it should be. This causes problems.

Representing Nothing as Something

The next volume of The Imposter’s Handbook is all about information: how we create it, deal with it, store it and analyze it. The first chapter sets the foundation for the rest of the book: I go over Aristotle’s Laws of Thought, then glide into Boolean Algebra, Binary This and That, Claude Shannon and Information Theory, Encoding, Encryption, Network Basics, Distributed Application Design and finally Analysis and Machine Learning. Believe it or not, all of this goes together and tells a pretty outstanding story!

I’m about 50% done with the writing process and should be done with the book in a month or so. I’ve been researching these topics for a year and a half – this stuff is deep! The reason I’m telling you all of this is that I found myself trying to explain how Null could exist in a binary world of true and false… and the ground opened up and swallowed me whole.

Not Logical

As I mention, I wanted to start the book from a solid logical footing so I could build a story from there, so I decided to start with Aristotle’s Laws of Thought:

  • Identity: something that is true or false is self-evident. Something that is true cannot present itself as false, and vise versa.
  • Contradiction: something that is true must also be not false and not not true.
  • Excluded Middle: something is either true or false, there is no other value in between

These laws apply to logical expressions about things that exist. In other words: you can’t apply these laws to the unknown, which also includes the future. This is where we arrive at the edge of the rabbit hole: null represents nothingness/unknownness, so what the hell is it doing in a deterministic system of 1s and 0s?

Computer systems are purely logical, but the applications that we write, if they embrace Nulls, are apparently not. Null is neither true nor false, though it can be coerced through a truthy operation, so it violates Identity and Contradiction. It also violates Excluded Middle for the same reason. So why is it even there?

The Billion Dollar Blunder

The idea of Null was first implemented in ALGOL by Tony Hoare, who had this to say about the whole thing:

I call it my billion-dollar mistake…At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

Null pointers and safe references make sense, but it’s a machine concern, not a logical one. With this one decision, uncertainty was introduced into programming through the use of the null pointer and, for some reason, we all just went along with it.

At this point, I will avoid falling further into hyperbole and philosophy and, instead, hold up a mirror and show you how three programming languages: C#, Ruby, and JavaScript, all deal with Null. You can then decide what you think.

Ruby

Ruby’s handling of Null is interesting. It’s handled by a class called NilClass that is represented globally as a singleton: nil. Here’s what happens if you try to do comparisons and math with it:

Ruby throws, which makes sense. Python does this as well with its None construct. When you try to do other fun things, however, like ask nil if it is, indeed nil or convert nil into an integer or array…

This is where coercion comes in and the fun begins. We rarely deal with Null directly; it tends to pop up as the value of a variable and is then coerced into logical operations. Here, Ruby is trying to be helpful by converting nil into an empty array, 0 and so on. This leads to an inconsistency: if to_i will turn nil into a 0, why won’t that coercion happen when trying to multiply?

I suppose it’s helpful if you know the rules, which you absolutely need to know because you can’t rely on logic to tell you what’s going to happen.

JavaScript

JavaScript has both null and undefined, but I’ll just focus on null. As you might imagine, you can do all kinds of fun things with it:

JavaScript won’t throw when trying to do things with null. Instead, it will coerce as needed.

Null in JavaScript is a primitive value and is not represented by an object. If you wanted to verify this, however, you would see this:

This is JavaScript lying to you, believe it or not, and is the result of a bug in the specification (from MDN):

In the first implementation of JavaScript, JavaScript values were represented as a type tag and a value. The type tag for objects was 0. null was represented as the NULL pointer (0x00 in most platforms). Consequently, null had 0 as type tag, hence the bogus typeof return value.

Object, not an object… whatever…

C#

Believe it or not, this is where things get strange. C# is a pretty “hefty” language, for lack of better words, and I thought it would do things that just make sense. I was wrong:

You can evaluate whether null is equal to itself, which it is. You cannot, however, apply a negation to it. I think I like this as C# is deciding not to coerce null into a truthy value.

Until lines 13 and 14, where I try to run logical comparisons. Neither of those is logically consistent and straight up violate logic altogether.

Finally, when I try to add or multiply, the result is null, which is weird. To .NET developers, this makes sense somehow, because clearly “anything multiplied by an unknown value is unknown.”

Which is what null represents in C#: unknown. Eric Lippert, one of the language architects, affirms this:

The concept of “null as missing information” also applies to reference types, which are of course always nullable. I am occasionally asked why C# does not simply treat null references passed to “foreach” as empty collections, or treat null strings as empty strings (*). It’s for the same reason as why we don’t treat null integers as zeroes. There is a semantic difference between “the collection of results is known to be empty” and “the collection of results could not even be determined in the first place,” and we want to allow you to preserve that distinction, not blur the line between them. By treating null as empty, we would diminish the value of being able to strongly distinguish between a missing or invalid collection and present, valid, empty collection.

If you’re a .NET person, you owe it to yourself to read another article Eric Wrote on the subject: “Nullable Comparisons are Weird”:

What is the practical upshot here? First, be careful when comparing nullable numbers. Second, if you need to sort a bunch of possibly-null values, you cannot simply use the comparison operators. Instead, you should use the default comparison object, as it produces a consistent total order with null at the bottom.

Eric’s explanations are fine, and all, but I had always read that a routine should throw if it didn’t have the information it needed to return a result. Surely 10 * null falls under this guideline, doesn’t it?

Why doesn’t C# throw? I had to find an answer.

Going Undercover

I figured that this question deserves a forum that’s not Twitter. I wanted to hear thoughts from others, so I decided to turn to StackOverflow.

If you follow me on Twitter, then you know that I recently aired some grievances about StackOverflow, rage-quitting the service because it has turned toxic. This is something they have acknowledged, which I think is GREAT. Seriously: kudos.

The reason I bring this up is that I received a lot of pushback on my opinion and some people asked me to basically “prove it”. Ahh yes: “prove to me how you feel about something so I can judge whether it’s valid”. Strange that the people asking me this couldn’t see the toxicity in the very Discourse we were having.

Anyway: a few of my friends have created “undercover” accounts on the service to see what it’s like as a new user with low rep, and I did the same. I decided to ask about nulls with respect to C# to see if I was missing something. There were some pointed suggestions that the question was argumentative, so I decided to target it to “Why doesn’t the C# compiler throw for logical comparisons of null”.

I think that’s a good question. You can read through the answers if you want to see the confusion and condescension. You can also see a rather positive experience with a very kind user named EJoshuaS, who left this comment:

 Excellent first question by the way – welcome to the site.

That was kind. Other commenters were a little more direct and more than a bit condescending. More of this please – you will create a better environment for others which will lead to better answers.

Read the question and you decide if it was asked/answered fairly. No one seems to know why C# behaves the way it does. The decision seems… arbitrary at best (to me).

Escaping Nullism

Some languages don’t have Null, like Swift and Haskell. I think it would be great fun to code in a language that embraced logic at every level, and I wonder if it’s possible to do this kind of thing intentionally.

I’m not sure Null should have a place in programming. Then again, this is the first time I’ve ever really thought about it. Maybe someday I’ll write a programming language and implement my ideas for Null. Why not? That’s what every other language has done, and we get to live with it.

TOP