Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
Programming

Code Complete 2 – Steve McConnell – Design in Construction

I just love Steve McConnell’s classic book Code Complete 2, and I recommend it to everyone in the Software ‘world’ who’s willing to progress and sharpen his skills.

My notes from Part 1: Laying the Foundation are here.

The second part of the book covers the following chapters:

  • Design in Construction
  • Working Classes
  • High-Quality Routines
  • Defensive Programming
  • The Pseudocode Programming Process

In this post I’ll share my notes from the:

Chapter 5: Design in Construction

The Wicked problem is the one that could be defined only by solving it or solving a part of it.

An example is Tacoma Narrows bridge. Only by building the bridge (solving the problem) could they learn about the additional consideration in the problem that allowed them to build another bridge that still stands.

According to Fred Brook, there are essential and accidental types of problems.

Managing complexity is the true primary technical goal in software design.

Internal design characteristics:

  • minimal complexity
  • high fan-in
  • ease of maintenace
  • low-to-medium fan-out
  • minimal connectedness
  • portability
  • extensibility
  • leanness
  • reusability

A good general rule is that a system-level diagram should be acyclic. In other words, a program shouldn’t contain any circular relationship in which Class A uses Class B, Class B uses Class C, and Class C uses Class A.

Steps in designing with objects

  1. Identify the objects and their attributes
    • Computer programs are usually based on real-world entities
  2. Determine what can be done to each object
    • A variety of operations can be performed on each object
  3. Determine what each object can do to the other objects
    • This step is just what it sounds like. The two generic things can do to each other are containment and inheritance
  4. Determine the parts of each object that will be visible to other objects
    • One of the key design decisions is identifying the parts of an object that should be made public and those that should be kept private
  5. Define each object’s public interface
    • Define the formal, syntactic, programing-language-level interfaces to each object. The data and methods the object exposes to every other object are called “public interface.”

Heuristics in terms of Software’s Primary Technical Imperative: Managing Complexity.

Summary of Design Heuristics

  • Find Real-World Objects
  • Form Consistent Abstractions
  • Encapsulate Implementation Details
  • Inherit When Possible
  • Hide Secrets (Information Hiding)

Information hiding is useful at all levels of design, from the use of named constants instead of literals to the creation of data types, to class design, routine design, and subsystem design.

A good class interface is like the tip of an iceberg, leaving most of the class unexposed

Ask yourself what needs to be hidden in this class?

Loose Coupling describes how tightly a class or routine is related to other classes or routines. The goal is to create classes and routines with small, direct, visible, and flexible relations to other classes and routines.

In Software, make the connections among modules as simple as possible.

Life is one big fat program which has a ton of options, but only one nonoptional parameter

The key note is that Classes and routines are first and foremost intellectual tools for reducing complexity. If they’re not making your job simpler, they’re not doing their jobs.

Design patterns

Patterns provide the cores of ready-made solutions that can be used to solve many of software’s most common problems.

  • Abstract Factory
    • Supports creation of sets of related objects by specifying the kind of set but not the kind of each specific
  • Adapter
    • Converts the interface of a class to a different interface
  • Bridge
    • Builds an interface and an implementation in such a way that either can vary without the other
  • Composite
    • Consists of an object that contains additional objects of its own type so that client code can interact with top-level object and not concern itself with all the detailed
  • Decorator
    • Attaches responsibilities to an object dynamically, without creating specific subclasses for each possible configuration of
  • Facade
    • Provides a consistent interface to code that wouldn’t otherwise offer consistent
  • Factory Method
    • Instantiates classes derived from a specific base class without needing to keep track of the individual derived classes anywhere but the Factory
  • Iterator
    • A server object that provides access to each element in a set sequentially
  • Observer
    • Keeps multiple objects in synch with each other by making a third the object responsible for notifying the set of objects about changes
  • Singleton
    • Provides global access to a class that has one and only one instance
  • Strategy
    • Defines a set of algorithms or behaviors that are dynamically interchangeable with each other
  • TemplateMethod
    • Defines the structure of an algorithm but leaves some of the detailed implementation to subclasses

Cohesion refers to how closely all the routines in a class or all the code in the routine support a central purpose

When in doubt use brute force. ~ Butler Lampson

Understand the problem – devise a plan – carry out a plan, look back to see how you did. ~ Polya George

Design practices

  • Iterate
  • Divide and Conquer
  • Top-down and bottom-up
  • Experimental prototyping
    • You have to be prepared to throw away the code (trick: name the classes -prototype-NameClass )

Put your code in a drawer. Then, come and take it out a week later, and you will criticize the fool who wrote it!

People who preach software design as a disciplined activity spend considerable energy making us all feel guilty. We can never be structured enough or object-oriented enough to achieve nirvana in this lifetime. We all truck around a kind of original sin from having learned Basic at an impressionable age. But my bet is that most of us are better designers than the purists will ever acknowledge. ~ P.J. Plauger

Key note for design is to iterate, iterate, and iterate again and after that, you will be happy with your design.

Conclusion

Hope you liked this post and that you’ve seen that this book really has a lot to offer, so I urge you to get your copy, read it and apply it!

Until next time, take care and keep on improving ?

My #notes from the #book Code Complete 2, Chapter 5 by ever so slightly magnificent Steve McConnell https://t.co/GPV0rq6Upd

— Nikola Brežnjak (@HitmanHR) August 13, 2017

Miscellaneou$

Become a speed demon

Here are my notes from the Udemy course Become a speed demon by Jonathan Levi. This may change by the time you read this post, but the course is now on a sale for $10, so you may wanna check it out if you’re into ‘this kind of things’.

Proper preparation is key to everything.

Specific
Measurable
Actionable
Realistic
Time related

The checklist manifesto book

The priority Star Exercise:

Parkinson’s Law – work expands to fill the time available for its completion

Efficient != Effective

15 minutes to get back in the optimal zone after distraction

MEDITATE!

Batching tasks – answer emails @ specific time

Buddhist wheel of life: career, money, health, friends and family, romance, personal growth, fun, and recreation, physical environment

Some cool tools/tips:

  • Pomodoro
  • Rescue Time
  • Scheduling meetings with an app
  • TextExpander
  • Dvorak keyboard
  • Typing numbers is faster if you actually speak them
  • Make use of Siri (or another equivalent on your phone)
  • QuickSilver app for Mac
  • Better Touch Tool
  • IFTTT
  • Sleep Cycle App
  • Bill Guard
  • Mint.com
  • Have someone do your laundry
  • TaskWonder, Workerly, Fiverr

Decision fatigue leads to ego depletion.

Too many options make us miserable.

Sorry I’m so direct, but I’m sure you’re very busy.

Maker vs. Manager time

Become a #speed demon https://t.co/cAfQ8MYpFm

— Nikola Brežnjak (@HitmanHR) August 8, 2017

Quick tips

How to hide the minimap in Visual Studio Code?

This is a quick tip on how to hide the minimap in Visual Studio Code.

In case you’re wondering why someone would like to do this? The answer is that if you have two files open side by side on a screen that’s not too big then any extra space on the screen will come handy.

Surprisingly, there’s no such option in any of the dropdown menus (like it is in Sublime Text 3 for example), so you’ll first have to go to:

Code -> Preferences -> Settings

Screen Shot 2017-07-23 at 11.48.33

Then, enter the following in your user settings object on the right:

"editor.minimap.enabled": false

minimapVisualStudioCode

You can search for any setting and see its default settings on the left-hand side. If you want to change it, just copy it in the object on the right-hand side, change the value, save, and you’re done. 

Btw, even though I’m a paying user of Sublime Text 3, I must admit I’m liking Visual Studio Code more every day. How’s the situation with you guys? Are you also a long-time ST3 user and have tried VSC? If so, I’d like to hear your thoughts about it…

How to hide the #minimap in Visual Studio #Code? https://t.co/81uHJAlpiT

— Nikola Brežnjak (@HitmanHR) August 6, 2017

Ionic3

How to create a calculator application with Ionic framework 3 by using Ionic Creator for UI

This is the second post in a series of posts which will teach you how to take advantage of your web development knowledge in building hybrid applications for iOS and Android. The first post in this series was all about How to get started with Ionic Framework 3 on Windows and Mac.

This second post explains:

  • How to create a calculator interface mockup
  • How to create a calculator interface prototype without coding by using Ionic Creator
  • How to start the Ionic 3 application based on the created interface
  • Which are the most important folders and files and what is the starting point of the Ionic 3 application
  • How to create the calculator logic

Finished project:

  • clone the code from Github
  • in the project directory execute ionic lab to run the project locally in your browser
  • you can check out the live example of this application or view this gif:

Introduction

Since there are not so many Calculator applications in the App Store, who knows, you just may create a bestseller in this category, if you add a needed tweak or two.

All jokes and hopes aside; this seemed to be decent, but still easy to accomplish task. Let’s start this chapter by creating the interface for our application.

Calculator interface mockup

Before starting any application, we should know what we want (well, at least in general). We should know what problem are we trying to solve with our application and how are we going to solve it. Also, we should have a decent idea of how we would want our application to look like.

The answers to the first two questions would be rather easy; the problem is that we can’t do calculations fast enough in our mind (well, except if you’re Arthur Benjamin) and we need a tool to help us with that. Surely, there are specific calculator devices, but it would be too cumbersome to carry one with us all the time.

Besides, since these days almost everyone has a smartphone, it turns out it would be an awesome idea to make an app for it. Because, as they say:

there’s an app for that

Where that is basically everything these days. If you find that there isn’t an app for some particular problem that you may have, that just may be your lucky break. Who knows, you just may end up having your 5 minutes of fame on the AppStore, until another clone of your app pushes you away.

Anyways, back to our calculator application; we don’t need any fancy options (at least not yet, in this 1.0 version), we’ll just stick with the basic mathematical operations like adding, subtracting, dividing and multiplying.

These basic operations will be our MVP (Minimum Viable Product), as the author Eric Ries explains in his awesome (and highly recommended) book Lean Startup. We can always add features later if it turns out that our idea was good. Or, we can pivot away from it, if it turns out it was not a next best thing after Flappy Bird. That way, we wouldn’t spend too much time and money building the app with a dozen features which, in the end, would not be used at all.

As for the user interface, you can use various tools that help with mocking up your application’s user interface (Balsamiq Mockups, Mockingbird, Mockup Builder). I tend to be old school about it, and I made a little hand drawing of how I imagined the app should look like, and this is what I came up with after few attempts:

Calculator interface prototype

Now that we know what our application needs to do and how it has to look like, let’s start by creating our interface.

We could create our interface by manually coding it in HTML/CSS, but we’re going to show a different approach here – the one which uses Ionic Creator, which is an awesome web application (soon to be a desktop app as well) that lets you drag&drop components that make up the user interface. As such, this is a great tool which helps in quick user interface prototyping.

The best thing is that you can then just download the created HTML/CSS (just recently they’ve added Ionic 3 support) and use it directly in your Ionic application. Of course, some additional changes will be needed later in the HTML and CSS code, but for creating a quick prototype, this will be more than enough.

Worth noting is that there are currently on the market lots of other tools for interface prototyping (InVision, Flinto, Figma 2.0). However, these tools don’t (at least not yet) have a “one-click download and ready for Ionic” option like Ionic Creator does.

Creating calculator interface with Ionic Creator

To use Ionic Creator you have to signup/login on their website. They are currently offering a 14-day trial (no credit card needed to sign up) of Creator Pro which is their best plan and has the following features:

On the initial screen, click the New Project button and fill out project’s name, type and Ionic version:

Please note that Ionic 3 code export is in Alpha mode currently – this will change in the coming months

The main screen of the Ionic Creator application looks like this:

In the upper left-hand side you’ll see the Pages panel, and inside it, you’ll see the Page item. Click on Page, and on the right-hand side change the Title to Calculator. Next, disable the Padding option by switching off the Padding checkbox under the Miscellaneous section on the right-hand side. The way this should look like now is shown on the image below:

First, we need some kind of a “display” which will show the numbers that we’re clicking. Ideally, we would use a <label> component, however, it’s not available in the Ionic Creator as of yet. So, for this, we will use the <input> element, and we can easily adjust this later when we download the generated HTML code.

Ionic Creator works in a drag&drop kind of way, which basically means that you can drag any component from the Components pane on the left-hand side and drop it on the Phone image in the center of the screen.

Since we concluded that we’d use the Input element, just drag&drop it to the Phone.

Select the Input component (by clicking on it in the Pages panel in the upper left corner mentioned before) and:

  • change Placeholder to 0 (zero digit)
  • change Name to display
  • remove the text under Title

The way this should look like now is shown on the image below:

Next, according to our mockup, we should add buttons that would represent the following:

  • digits from 0 to 9
  • adding (+)
  • substracting (–)
  • multiplying (x)
  • dividing (/)
  • modulo (%) – we are, after all, programmers, right? ?‍? ?

Also, we would need an equals button (=), a clear button (C) and a floating point (.) button.

In the first row we need to have three buttons, the ones representing the Clear operation (C), modulo operation (%) and divide operation (/). To accomplish this, we will use a Button component from the Components panel and drag&drop it just below the Input field on the screen. But, before you do that, you have to drag&drop the Container component as we will drop these operation buttons into it.

So, to sum up:
+ first, drag&drop the Container component, and then
+ drag&drop the Button component to the phone image inside the Container component

When done, change the Button’s Width property under the Style section on the right-hand side to Inline and color to Energized. Now, either repeat the process two more times or click on the duplicate icon which appears on the Button component once selected (just left of the x icon). Then change the Text of the buttons to C, % and / respectively. You should see something like this now in your Ionic Creator window:

Don’t worry that this now doesn’t look like in our design; we will deal with this at a later stage.

Those of you familiar with Ionic 1 (also covered in my previous book) know that we had the useful Button Bar component which doesn’t exist in Creator now, but we still have few options.

Now, repeat the process for the second row by first adding another Container component below the previous one and then adding four buttons: 7, 8, 9 and x into it. The additional change on the number buttons is that you need to set their color to Positive (TBH, ‘Positive` is the default color, so you basically won’t have to change anything).

Now you need to repeat the process by adding next three rows. The best thing you can do to speed up the process is to duplicate the whole row by clicking the duplicate icon:

and then change the button text to represent all the missing buttons per rows:

  • buttons representing 4, 5, 6 and a button representing subtraction (–)
  • buttons representing 1, 2, 3 and a button representing addition (+)

Number buttons should have a Positive style, and operation buttons should have an Energized style.

In the last row you should add three buttons (just delete one after you duplicate the whole row of four buttons):

  • one button representing 0, with the Positive style
  • one button representing floating point (.)
  • one button representing the Equals operation (=), with the Assertive style

Your interface should now look like this:

Don’t worry about the slight misalignment or padding; we’ll take care of this in the next chapter when we’ll be polishing our application and preparing it for the App/Play store.

So, this is it, we have our interface ready, and now we can export it by clicking on the Export icon in the header, as shown in the image below:

After this a popup, with the following content, appears:

Click the Download project ZIP button and save it to your computer.

Starting a project with Ionic CLI by using the template made in Ionic Creator

First, unzip the file that you’ve downloaded in the previous step. Then, start a new Ionic app by executing the following command in your Terminal:

ionic start Ionic3_2ndTutorial blank

Now go into the newly created Ionic3_2ndTutorial directory, and overwrite the src folder with the contents from your zip export. You will want to overwrite the app directory, pages directory, and index.html file.

Note: you’re free to name your project any way you want, I chose Ionic3_2ndTutorial in this example, and I used the ‘blank’ template.

Now, let’s see this in action; execute ionic lab and you should get an output like this:

[INFO] Starting app-scripts server: --lab --l --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address 0.0.0.0 -
       Ctrl+C to cancel
[09:39:31]  watch started ... 
[09:39:31]  build dev started ... 
[09:39:31]  clean started ... 
[09:39:31]  clean finished in less than 1 ms 
[09:39:31]  copy started ... 
[09:39:31]  transpile started ... 
[09:39:33]  transpile finished in 1.83 s 
[09:39:33]  preprocess started ... 
[09:39:33]  deeplinks started ... 
[09:39:33]  deeplinks finished in 6 ms 
[09:39:33]  preprocess finished in 7 ms 
[09:39:33]  webpack started ... 
[09:39:33]  copy finished in 1.98 s 
[09:39:38]  webpack finished in 5.41 s 
[09:39:38]  sass started ... 
[09:39:39]  sass finished in 1.02 s 
[09:39:39]  postprocess started ... 
[09:39:39]  postprocess finished in 9 ms 
[09:39:39]  lint started ... 
[09:39:39]  build dev finished in 8.32 s 
[09:39:39]  watch ready in 8.36 s 
[09:39:39]  dev server running: http://localhost:8100/ 

[INFO] Development server running
       Local: http://localhost:8100

[09:39:42]  lint finished in 2.32 s

In the first tutorial we used the ionic serve command which starts up a local web browser and shows how our application would look like. This one is similar but in a way better as it can nicely show us how our app would look like on different platforms:

You can still use the ionic serve command if you like. The live preview is great for rapid development since you get to see changes instantly without needing to reload your browser manually.

If you get an error similar to this:
Error: tsconfig: Cannot read file '/DEV/Ionic3_2ndTutorial/src/tsconfig.json': ENOENT: no such file or directory, open '/DEV/Ionic3_2ndTutorial/src/tsconfig.json'.
then you didn’t run the ionic lab command in the project directory and so you should first cd into that directory (as mentioned in the previous step) and then run the ionic lab command.

Now, let’s go and see what our generated folder structure looks like and what is each folder responsible for.

Ionic application folder structure

If you open up the project in your editor (I’m using Visual Studio Code), you will see something like:

Now we’re going to explain what each of these files and folders represents in Ionic framework 3.

hooks folder

hooks folder contains code for Cordova hooks, which are used to execute some code during the Cordova build process. For example, Ionic uses Cordova’s after_prepare hook to inject platform specific (iOS, Android, Windows Phone) CSS and HTML code.

node_modules folder

node_modules folder contains all the Node modules that Ionic CLI uses in the background like for example babel, browserify, lodash, uglify, webpack to name just a few. There are 550+ tools in that folder ?, and you shouldn’t worry about it at this point at all.

resources folder

resources folder contains two files (icon.png and splash.png) and two folders (android and ios) which contain all the needed icon and splash screen sizes. Ionic has a simple command which creates all the icon and splash screen sizes for you automatically. We will cover that in more detail in the next tutorial.

src folder

src folder is the most important since it contains all the files our application is made of, and we will be spending most of our development time in this folder. This folder contains few files and additional sub folders which we’ll address in more detail in the next section titled Refactoring our application.

www folder

www folder contains the optimized version of our application (minimized, compressed, etc.). In future tutorials, we’ll show how easy it is to just take the contents of this folder and put it on your web server, and you would have the application ready and running. If you take a look at the live example of this project, this is exactly what I did.

.editorconfig file

.editorconfig is a configuration file for Visual Studio Code.

config.xml file

config.xml is a configuration file for the Cordova project (as you may remember from the first tutorial, Ionic is built on top of Cordova). It contains some meta information about the app like permissions and a list of Cordova plugins which are used in the app. To learn more about available settings in the config.xml file, please refer to the official documentation.

ionic.config.json file

ionic.config.json is a configuration file for Ionic, used to store meta information about an Ionic project and the associated Ionic.io cloud account. We’re not going to use Ionic.io cloud account just yet, we’ll show how to use it in the next chapter.

The contents of my ionic.config.json file is as follows:

{
  "name": "Ionic3_2ndTutorial",
  "app_id": "",
  "type": "ionic-angular"
}

It defines the name of the app and its type, along with the app_id in case you’ve created the Cloud account for this project (if you’ve answered Yes to the question when starting the project).

package.json file

package.json is a file used by npm to store versions of the npm packages installed in the current project.

npm (Node.js Package Manager) is a CLI tool which comes with Node.js installation and it’s used for installing other tools like aforementioned Browserify, Babel, etc…

Contents of my package.json file, shown below, is useful as we can see which Cordova plugins and dependencies we have installed on the project, as well as some meta information like name, version and description:

{
  "name": "Ionic3_2ndTutorial",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.5.3",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.0.2",
    "@ionic/cli-plugin-ionic-angular": "1.3.2",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project"
}

package-lock.json file

package-lock.json file is automatically generated for any operation where npm modifies either the node_modules folder or package.json file. It describes the exact folder contents that was generated so that future installs can generate identical folder contents, regardless of intermediate dependency updates. This file is intended to be committed into source repositories so that your teammates (or continuous integration systems, if you have those set up) are guaranteed to install exactly the same dependencies.

.gitignore and README.md file

Both .gitignore and README.md are files related to GitHub.

I’m sure most of the readers know and use GitHub (and consequently Git), but just for brevity, let see how Wikipedia defines GitHub:

GitHub is a Web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features. Unlike Git, which is strictly a command-line tool, GitHub provides a Web-based graphical interface and desktop as well as mobile integration. It also provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.

So, Git on the other hand is (quoted from the official site):

a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

If you’re not using Git (and Github) in your workflow, I highly encourage you to do so, as it will prove really useful in the long run.

Now that we got the basics out of the way let’s take a look at what the files above represent.

.gitignore is a configuration file for GitHub. Contents of the .gitignore file, shown below, basically instructs Git which folders it shouldn’t track and upload to GitHub.

# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore

*~
*.sw[mnpcod]
*.log
*.tmp
*.tmp.*
log.txt
*.sublime-project
*.sublime-workspace
.vscode/
npm-debug.log*

.idea/
.sass-cache/
.tmp/
.versions/
coverage/
dist/
node_modules/
tmp/
temp/
hooks/
platforms/
plugins/
plugins/android.json
plugins/ios.json
www/
$RECYCLE.BIN/

.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate

README.md is a Markdown file used on GitHub to document the purpose and usage of your project. In general, IMHO, every project should have a decently written README.md file which explains the basic usage of the project along with instructions on how to run it, contribute to it, etc.

tsconfig.json file

tsconfig.json is TypeScript configuration file. We won’t go into the details here, but I encourage you to take a look at the official documentation.

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

tslint.json file

tslint.json is TypeScript Linter configuration file. Linter is a program which checks TypeScript code for readability, maintainability, and functionality errors. For more info, and to learn what the contents of the file shown below represents, please check the official docs.

{
  "rules": {
    "no-duplicate-variable": true,
    "no-unused-variable": [
      true
    ]
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ]
}

Refactoring our application

As said, we’ll be spending most of our development time in the src folder, and that’s why we mentioned it just briefly in the previous section. We’ll take a full deep dive into it here, by explaining each file (that we’ll change) in detail.

Finally, we’ll add the calculator logic so that our calculator will work as expected.

Generally, putting all the code in one file and mixing logic and presentation (JavaScript and HTML code) is simply a big NO-NO, and often referred to as spaghetti code. You can learn more about refactoring your code from the cult book Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, and others. If you’re searching for a bit lighter introduction to refactoring and good programing practices, in general, I can’t recommend the classic Code Complete 2 by Steve McConnell enough. I’ve read the book way back in 2011, and you can read my notes from the first part of the book here.

^ This was the comment from the first edition of this book (covering Ionic 1). I am happy to report that ever since Ionic has done an awesome job in separating the logic and presentation into components. Mainly this benefit comes from Angular (currently at version 4.x).

index.html file

The starting point of our Ionic application is index.html, whose contents is as follows:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <title>Ionic3Calculator</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">

  <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">

  <!-- cordova.js required for cordova apps -->
  <script src="cordova.js"></script>

  <!-- un-comment this code to enable service worker
  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.log('Error', err));
    }
  </script>-->

  <link href="build/main.css" rel="stylesheet">

</head>
<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The bundle js is generated during the build process -->
  <script src="build/main.js"></script>

</body>
</html>

I’m expecting that you have a decent understanding of HTML, so I won’t explain every HTML tag.

In the index.html file we’re loading in the CSS and JS files from the build folder. The most important tag is <ion-app></ion-app> since this is where we’ll be loading our application.

app folder

The app folder with the src folder is the starting point of every Ionic3 application.

app.components.ts file

Here I won’t go into too much detail (as this post is long enough on its own now ?) but I want to show you where your page is being loaded in. The contents of the file should be as follows:

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { CalculatorPage } from '../pages/calculator/calculator';

@Component({
    templateUrl: 'app.html'
})

export class MyApp {
    rootPage: any = CalculatorPage;

    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
        platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            statusBar.styleDefault();
            splashScreen.hide();
        });
    }
}

The important line here is rootPage: any = CalculatorPage; which sets the root page of your app to the CalculatorPage, which again is imported at the beginning of the file:

import { CalculatorPage } from '../pages/calculator/calculator';.

platform.ready event is triggered after the device (your mobile phone on which the application is started) is all set up and ready to use. This includes plugins which are used in this project. If you would try to check if some plugin is available outside of the ready function callback, you could get wrong results because it is possible that some plugin would not have been set up just yet. You can learn more about Ionic Platform utility methods here.

Important to note are the places in code where and how the same CalculatorPage is injected in the app.module.ts file and added in the @NgModule declarations and entryComponents.

In this app folder, in the file app.scss you could put some style rules that you want to apply globally for your application. We’ll cover styling in the next tutorial where we’ll polish our existing calculator application.

cordova.js, manifest.json and service-worker.json files

We won’t be dealing with these three files in this tutorial. We’ll leave them for another tutorial in which we’ll explain how to create a PWA (Progressive Web App) with Ionic and how to use native plugins (accessing Camera, etc.).

Calculator logic with controllers

Ionic Creator has nicely generated a calculator page for us in the pages folder:

As mentioned before, the organization like this is so much better from what we had before as now we have three files per each component:

  • HTML template file (calculator.html)
  • SASS file (calculator.scss)
  • TypeScript file (calculator.ts)

This way we have the presentation (HTML + CSS) and logic (TS) separated and this is something you should always strive for.

Ionic Creator generated the following code for our calculator.ts file:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
    selector: 'page-calculator',
    templateUrl: 'calculator.html'
})
export class CalculatorPage {
    constructor(public navCtrl: NavController) {

    }
}

This is a bare bones code template where we’re importing the Component and NavController components; then we’re defining our Component decorator selector and templateUrl. Finally, we’re exporting the CalculatorPage class and defining the constructor inside it.

The templateUrl defines the location of the HTML template, and the selector defines the HTML tag (<page-calculator></page-calculator>) that will be used in our template once the app is generated:

Here we’re going to add the small piece of code which will make our app justWork™. Just add this code in the CalculatorPage class:

result = '';

btnClicked(btn) {
    if (btn == 'C') {
        this.result = '';
    }
    else if (btn == '=') {
        this.result = eval(this.result);
    }
    else {
        this.result += btn;
    }
}

In this code, we’re defining a variable result, so that we can show it in our template file (calculator.html).

Next, we defined a new function called btnClicked which accepts one parameter named btn. Inside the function, we’re checking for the passed parameter, and we have three cases based on the value of the parameter that is passed:

  • if the parameter equals C then we’re clearing the result
  • if the parameter equals = then we’re calculating the equation and showing the result
  • in any other case we’re just appending the button’s value to the current equation

Please note that because of brevity we haven’t added any additional checks like if someone accidentally (or intentionally) clicks two times on a button which represents some operation. We will “fix” this in the next chapter when we’ll be polishing the application. Also, you may have read on the Internet that using eval is wrong or just bad. True, it can be bad if used to evaluate some other user input, but in this case, we’ll be fine.

Finishing the calculator template

The only thing which is left for us to do is to add the appropriate function calls on the buttons in the calculator.html template. All that we have to do is add the (click)="btnClicked() function call to each button, and pass in the appropriate parameter. The template that Ionic Creator created for us looks like this:

<ion-header>
    <ion-navbar>
        <ion-title>
            Calculator
        </ion-title>
    </ion-navbar>
</ion-header>

<ion-content id="page1">
    <form id="calculator-form1">
        <ion-item id="calculator-input1">
            <ion-label></ion-label>
            <ion-input type="text" placeholder="0" name="display"></ion-input>
        </ion-item>
    </form>

    <div id="calculator-container3">
        <button id="calculator-button1" ion-button color="energized"> C </button>
        <button id="calculator-button2" ion-button color="energized"> % </button>
        <button id="calculator-button3" ion-button color="energized"> / </button>
    </div>

    <div id="calculator-container6">
        <button id="calculator-button10" ion-button color="positive"> 7 </button>
        <button id="calculator-button11" ion-button color="positive"> 8 </button>
        <button id="calculator-button12" ion-button color="positive"> 9 </button>
        <button id="calculator-button13" ion-button color="energized"> x </button>
    </div>

    <div id="calculator-container7">
        <button id="calculator-button14" ion-button color="positive"> 4 </button>
        <button id="calculator-button15" ion-button color="positive"> 5 </button>
        <button id="calculator-button16" ion-button color="positive"> 6 </button>
        <button id="calculator-button17" ion-button color="energized"> - </button>
    </div>

    <div id="calculator-container8">
        <button id="calculator-button18" ion-button color="positive"> 1 </button>
        <button id="calculator-button19" ion-button color="positive"> 2 </button>
        <button id="calculator-button20" ion-button color="positive"> 3 </button>
        <button id="calculator-button21" ion-button color="energized"> + </button>
    </div>

    <div id="calculator-container9">
        <button id="calculator-button22" ion-button color="positive"> 0 </button>
        <button id="calculator-button23" ion-button color="positive"> , </button>
        <button id="calculator-button25" ion-button color="energized"> = </button>
    </div>
</ion-content>

I have to note that in the current version of Ionic Creator export they still have the old names for colors and we will have to change this. The old Ionic 1 style colors were this:

$light:                           #fff !default;
$stable:                          #f8f8f8 !default;
$positive:                        #387ef5 !default;
$calm:                            #11c1f3 !default;
$balanced:                        #33cd5f !default;
$energized:                       #ffc900 !default;
$assertive:                       #ef473a !default;
$royal:                           #886aea !default;
$dark:                            #444 !default;

The new color names are now these (defined in the src/theme/variables.scss file):

$colors: (
    primary:    #488aff,
    secondary:  #32db64,
    danger:     #f53d3d,
    light:      #f4f4f4,
    dark:       #222,
    energized: #ffc900;
);

In our template, where we have color="positive" we can just delete that as that is now the default color if no color is defined on the button.

So, we won’t change the existing names, as then we would break the code for where this particular variable name is used. We will just add our own class for energized so that the new colors array will look like this:

$colors: (
    primary:    #488aff,
    secondary:  #32db64,
    danger:     #f53d3d,
    light:      #f4f4f4,
    dark:       #222,
    energized: #ffc900
);

Additionally, somewhat a departure from the design, we will add the danger color to the buttons C and =.

This is how the template should look like now:

<ion-header>
    <ion-navbar>
        <ion-title>
            Calculator
        </ion-title>
    </ion-navbar>
</ion-header>

<ion-content id="page1">
    <form id="calculator-form1">
        <ion-item id="calculator-input1">
            <ion-label></ion-label>
            <ion-input type="text" placeholder="0" name="display" [(ngModel)]="result"></ion-input>
        </ion-item>
    </form>

    <div id="calculator-container3">
        <button id="calculator-button1" ion-button color="danger" (click)="btnClicked('C')"> C </button>
        <button id="calculator-button2" ion-button color="energized" (click)="btnClicked('%')"> % </button>
        <button id="calculator-button3" ion-button color="energized" (click)="btnClicked('/')"> / </button>
    </div>

    <div id="calculator-container6">
        <button id="calculator-button10" ion-button (click)="btnClicked('7')"> 7 </button>
        <button id="calculator-button11" ion-button (click)="btnClicked('8')"> 8 </button>
        <button id="calculator-button12" ion-button (click)="btnClicked('9')"> 9 </button>
        <button id="calculator-button13" ion-button color="energized" (click)="btnClicked('*')"> * </button>
    </div>

    <div id="calculator-container7">
        <button id="calculator-button14" ion-button (click)="btnClicked('4')"> 4 </button>
        <button id="calculator-button15" ion-button (click)="btnClicked('5')"> 5 </button>
        <button id="calculator-button16" ion-button (click)="btnClicked('6')"> 6 </button>
        <button id="calculator-button17" ion-button color="energized" (click)="btnClicked('-')"> - </button>
    </div>

    <div id="calculator-container8">
        <button id="calculator-button18" ion-button (click)="btnClicked('1')"> 1 </button>
        <button id="calculator-button19" ion-button (click)="btnClicked('2')"> 2 </button>
        <button id="calculator-button20" ion-button (click)="btnClicked('3')"> 3 </button>
        <button id="calculator-button21" ion-button color="energized" (click)="btnClicked('+')"> + </button>
    </div>

    <div id="calculator-container9">
        <button id="calculator-button22" ion-button (click)="btnClicked('0')"> 0 </button>
        <button id="calculator-button23" ion-button (click)="btnClicked('.')"> . </button>
        <button id="calculator-button25" ion-button color="danger" (click)="btnClicked('=')"> = </button>
    </div>
</ion-content>

As you can see from the code, we’re passing to the function an argument which represents the clicked button.

Also, worth noting is that we used the

[(ngModel)]="result"

on the input element, so that we can access it from the controller through the Angular two-way binding and that we can enter some formula in the input field ourselves as well.

We could have used just the one-way binding like this:

[ngModel]="result"

but if we manually entered something in the input field, it would not ‘propagate’ to our code.

Run the application

Now you can run the application by executing the command

ionic lab

and you should see your awesome calculator open up in your browser:

as noted before, don’t worry this doesn’t look ‘slick’ or that it doesn’t ‘pop’ (or some other nonsense word the ‘knowledgeable’ people use these days), we’ll take care of this in the following tutorial.

The best thing, it should ? also work as expected. So, if you try to enter something like 2+3-10*2 and tap on = you should get the expected -15 (yes, operator precedence is taking place correctly).

We also have the floating point arithmetic like 2.3+3.2 equals 5.5.

As mentioned at the beginning of this chapter, you can take a look at the source code on GitHub, or you can take a look at the live example of this application.

Conclusion

In this chapter, we covered how to create a calculator application step by step. We showed how to create a mockup of our idea; then we showed how to create an interface by using Ionic Creator, and finally how to implement calculator’s logic.

In the next chapter, we’re going to take a look at how to test our application on the real physical devices, and how to use Ionic View App to share our application with other users without going through the app store. Also, we’re going to take a look at how to implement Google Analytics and Google Admob ads, and how to prepare our application for the stores. Additionally, we’ll take a look at how to customize the icons and the application’s splash screen.

Until next time, keep on improving ?

How to create a #calculator application with @Ionicframework 3 by using #Ionic Creator for UI https://t.co/ElzEhU8Jrc

— Nikola Brežnjak (@HitmanHR) August 2, 2017

Programming

Code Complete 2 – Steve McConnell – Part 1: Laying the Foundation

I just love Steve McConnell’s classic book Code Complete 2, and I recommend it to everyone in the Software ‘world’ who’s willing to progress and sharpen his skills.

I read the book way back in 2011, took notes and wrote them down in my notebook, as I usually do:

In this notebook, I have several book notes, and the best of all of them landed on the inner pages of the covers:

Wishful thinking: one day this will be worth ???

Now, I figured I should get these good passages and quotes and my observations out to the blog for easier search in the future.

Too bad the actual books don’t come with a search functionality, right? ? Well, just get a Kindle, right? Honestly, I did and it seems like I still prefer ‘real’ books.

Anyways, in this post we’ll cover the whole Part 1: Laying the Foundation which consists of 4 chapters:

  • Welcome to Software Construction
  • Metaphors for a Richer Understanding of Software Development
  • Measure Twice, Cut Once: Upstream Prerequisites
  • Key Construction Decisions

The post which covers the chapter 5. Design in Construction is here.

So, let’s get to it, shall we?

Chapter 1: Welcome to Software Construction

Software construction is the central activity in software development. Construction is the only activity that’s guaranteed to happen on every project. The main activities in construction are

  • detailed design
  • coding and debugging
  • integration and
  • developer testing (unit testing and integration testing)

The quality of the construction substantially affects the quality of the software.

Chapter 2: Metaphors for a Richer Understanding of Software Development

An algorithm is a set of well-defined instructions for carrying out a particular task. On the other hand, a heuristic is a technique that helps you look for an answer. Its results are subject to change because a heuristic tells you only how to look, not what to find. Metaphors are heuristics, not algorithms. As such, they tend to be a little sloppy.

Treating software construction as similar to building construction suggests that careful preparation is needed and illuminates the difference between large and small projects.

From perspective of planning it’s not the same to build a doghouse or a skyscraper.

Also, a good metaphor for software construction is an oyster forming a pearl. The image is a good way to visualize incremental development or gradual change.

Thinking of software-development practices as tools in an intellectual toolbox suggests further that every programmer has many tools and that no single tool is right for every job. Choosing the right tool for each problem is one key to being an effective programmer.

Chapter 3: Measure Twice, Cut Once: Upstream Prerequisites

Be sure your preparation activities are reducing risks, not increasing them. If you want to develop high-quality software, attention to quality must be part of the software-development process from the beginning to the end. Attention to quality at the beginning has a greater influence on product quality than attention at the end. In general, the principle is to find an error as close as possible to the time at which it was introduced. The longer the defect stays in the software “food chain”, the more damage it causes further down the chain.

The overarching goal of preparing for construction is risk reduction.

Iterative approaches tend to reduce the impact of inadequate upstream work, but they don’t eliminate it. You might choose a more sequential (up-front) approach when:

  • requirements are fairly stable
  • little project risks
  • long-term predictability is important
  • The cost of changing requirements, design, and code downstream is likely to be high

You might choose a more iterative (as you go) approach when:

  • requirements are not well understood
  • the design is complex, challenging, or both
  • the development team is unfamiliar with the applications area
  • the project contains a lot of risks
  • long-term predictability is not important
  • the cost of changing requirements, design, and code downstream is likely to be low

Part of the programming job is to educate bosses and coworkers about the software-development process, including the importance of adequate preparation before programming begins.

Problem-Definition Prerequisite – the penalty for failing to define the problem is that you can waste a lot of time solving the wrong problem. This is a double-barreled penalty because you also don’t solve the right problem.

The 25% change in requirements results in 70-80% of reworking on the project.

Make sure everyone knows the cost of requirements change.

Requirements Prerequisite – requirements describe in detail what a software system is supposed to do, and they are the first step toward a solution. Paying attention to requirements helps to minimize changes to a system after development begins. If you find a coding error during coding, you change a few lines of code and work goes on. If you find a requirements error during coding, you have to alter the design to meet the changed requirement.

Stable requirements are the holy grail of the software development.

Architecture Prerequisite – Architecture is also known as system architecture, high-level design, and top-level design. The architecture should define the major building block in a program. Every feature listed in the requirement should be covered by at least one building block. Building block should have one area of responsibility, and the minimization of the information that blocks have about each other is needed. Architecture should specify major classes that are used.

It’s good to stick to the 80/20 rule, which specifies the 20% of the classes that make 80% of the system’s behavior.

Esential problem with large systems is maintaining their conceptual integrity.

Typical architectural components are:

  • program organization
  • specification of major classes
  • data design
  • business rules
  • user interface design
  • resource management
  • security
  • performance
  • scalability
  • interoperability
  • internationalization/localization (I18N – Internationalization and L10N – localization)
  • error processing.

The architecture should address all requirements without gold-plating (without containing elements that are not required).

I wonder when managers will start to understand that software development is more than just coding.

WISCA – Why isn’t Sam coding anything?
WIMP – Why isn’t Mary programming?

If you can’t explain something to a six-year-old, you really don’t understand it yourself.

The worst thing that can happen to you is to end up maintaining someone’s code who obviously never heard of classes, cause then you will feel like watching a foreign movie with no subtitles.

Only one subsystem/class should access database

The new design has to be easy to change without affecting business rules and program results.

The architecture should clearly describe a strategy for handling changes.

We’ve always done it that way – be wary of that statement! To this, I’d add “Do your best in trying to inform, but if management doesn’t budge, run away as fast as you can”

Bad requirements – if they are found out later, the fixing costs a lot more.

Chapter 4: Key Construction Decisions

Use a language that you’ve used before, and you will become more experienced with it and more productive

C#, C++, Java, Visual Basic – 5 to 15 times more productive than C, Assembly

Developers working in interpreted languages are more productive than the ones using compiled ones.

Most common languages:

  • Ada – named after Ada Lovelace, the first programmer; used in military, space, and avionic systems
  • Assembly language – assembler, low-level language, used for maximizing speed and code size.
  • C – 1970 Bell Labs
  • C++ – 1980 Bjarne Stroustrup
  • C# – 2001 Microsoft Anders Hejlsberg
  • Cobol – Common Business Oriented Language, developed in 1959 – 1961
  • Fortran – first-high level computer language
  • Java – developed by Sun Microsystems; runs on virtual machine
  • JavaScript – primarily used for client side programming (note by me from 2017: not anymore. Node.js made sure of that.)
  • Perl – string-handling language; often used for system administration tasks.
  • PHP – used to access server-side interactive functions and accessing database information. Note from me: everybody seems to hate this language nowadays ?
  • Python – Python is an interpreted, interactive, object-oriented language that runs in numerous environments
  • SQL – declarative language, meaning that it does not define a sequence of operations, but rather the result of some operations.
  • Visual Basic – high-level, object-oriented, visual programming version of Basic developed by Microsoft.

Programmers who program ‘in’ a language limit their thoughts to constructs that the language directly supports. If the language tools are primitive, the programmer’s thoughts will be primitive.

Programmers who program ‘into’ a language first decide what thoughts they want to express, and then they determine how to express those thoughts using the tools provided by their specific language.

Conclusion

Hope you liked this post and that you’ve seen that this book really has a lot to offer, so I urge you to get your copy, read it and apply it!

Until next time, take care and keep on improving ?

My #notes from all-time classic #book Code Complete 2 by Steve McConnell Part 1: Laying the Foundation https://t.co/8jpjxTgMql

— Nikola Brežnjak (@HitmanHR) August 1, 2017

Books

The Compound Effect – Darren Hardy

My favorite quotes from the book The Compound Effect: Jumpstart Your Income, Your Life, Your Success by Darren Hardy which I rated 4/5 on my Goodreads account:

When the reason is big enough, you’ll be willing to perform almost any ‘how’.

Whatever you vividly imagine, ardently desire, sincerely believe, and enthusiastically act upon… must inevitably come to pass! ~ P. Meyer

Never ask advise of someone with whom you wouldn’t wanna trade places.

You will never change your life until you change something you do daily. The secret of your success is found in your daily routine.

Don’t wish it were easier; wish you were better.

You alone are responsible for what you do, don’t do, or how you respond to what’s done to you.

Forget about willpower. It’s time for why-power. Your choices are only meaningful when you connect them to your desires and dreams. The wisest and most motivating choices are the ones aligned with that which you identify as your purpose, your core self, and your highest values. You’ve got to want something, and know why you want it, or you’ll end up giving up too easily.

It’s not the big things that add up in the end; it’s the hundreds, thousands, or millions of little things that separate the ordinary from the extraordinary.

The first step toward change is awareness. If you want to get from where you are to where you want to be, you have to start by becoming aware of the choices that lead you away from your desired destination.

Your biggest challenge isn’t that you’ve intentionally been making bad choices. Heck, that would be easy to fix. Your biggest challenge is that you’ve been sleepwalking through your choices.

The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge.

The real cost of a four-dollar-a-day coffee habit over 20 years is $51,833.79. That’s the power of the Compound Effect.

All winners are trackers.

Consistency is the key to achieving and maintaining momentum.

My favorite #quotes from the #book The Compound Effect by Darren Hardy https://t.co/nPZmnmjbMw

— Nikola Brežnjak (@HitmanHR) July 30, 2017

Books

Leading Snowflakes – Oren Ellenbogen

These are my notes from an awesome and more importantly practical book Leading Snowflakes by Oren Ellenbogen. I’ve reviewed this one with five stars on my Goodreads account.

Switch between Manager and Maker models

  • Never stop coding!
  • Understand the details of what you gave someone to do
  • Ask for feedback and advice

“It would be good for us to…” vs “I would like to…”
Be nice
Don’t micromanage

Code Review Your management decisions

  • WHEN/WHO/THE DILEMMA/THE DECISION MADE/RETROSPECTION/DID I SHARE THIS?
  • discuss these dilemmas with your boss and see how he would have handled it
  • discuss dilemmas with another engineering manager and review each other decisions
  • do a retrospection every day for ten mins
  • do a retrospection once a month for 1 hour

Confront and challenge your teammates

  • email summaries of your 1on1’s
  • care deeply about your team but don’t care about what they think of you
  • The Asshole Checklist: a) Did I show empathy (not sympathy) b) Did I clarify my expectations c) Did I practice what I just preached
  • share harsh feedback if needed no matter what
  • don’t go helping others on their tasks

Teach how to get things done

  • show how something is done
  • your job is to help someone else succeed
  • small increments (1-3hrs per task)
  • write docs after the feature is finished
  • see if you can have someone teach others

Delegate tasks without losing quality or visibility

  • make a list of things you’re doing today and see which ones you can start delegating
  • use the spreadsheet from the book
  • use the one-page template from the book

Build trust with other teams in the organization

  • in the priority meetings list three priorities that are most important for you in the next week, but acknowledge that you know what is expected of you
  • TEAM is a group of people that TRUST each other
  • There is no I in TEAM
  • Thank you email (or public praise) for a feature well done
  • Internal tech talks
  • Cross-team exchange program
  • Pizzability

Optimize for business learning

  • Acquisition
  • Activation
  • Retention
  • Referals
  • Revenue

Spend 80% on tweaking features and 20% on developing new features.

^ I would tweak this a bit: spend 80% on tweaking features that bring in the 80% of $$.

Use inbound recruiting to attract better talent

  • Answer questions on StackOverflow for 1hr/week
  • Guest blog posts or repost your posts on Medium
  • Have hackathons
  • Birthday pics to Instagram, Facebook, Blog. Also do a video maybe
  • Give talks
  • Have side projects

Build a scalable team

  • Vision
  • Core values
  • Self-balanced
  • Sense of accomplishment
  • Who is putting down fires? – get him to distribute knowledge and mentor others to get the job done
  • Who is an expertise bottleneck – same as above
  • Who is not building trust?
  • On your 1on1’s ask “What is the worst thing about working here?”

My #notes from #Leading Snowflakes – a great #book by @orenellenbogen https://t.co/43h3cFcWmy

— Nikola Brežnjak (@HitmanHR) July 25, 2017

Quick tips

How to Format Code on Every Save in Visual Studio Code?

This is a quick tip on how to format (prettify) the code every time you save a certain file in Visual Studio Code.

First, go to:

Code -> Preferences -> Settings

Screen Shot 2017-07-23 at 11.48.33

Second, enter the following in your user settings object on the right:

"editor.formatOnSave": true

Screen Shot 2017-07-23 at 11.50.39

You can search for any setting and see its default settings on the left-hand side. If you want to change it, just copy it in the object on the right-hand side, change the value, save, and you’re done. Now your HTML and JavaScript files will re-indent nicely on every save.

Btw, even though I’m a paying user of Sublime Text 3, I must admit I’m liking Visual Studio Code more every day. How’s the situation with you guys? Are you also a long-time ST3 user and have tried VSC? If so, I’d like to hear your thoughts about it…

How to #Format Code on Every Save in Visual Studio #Code? https://t.co/keI3ktj5Pg

— Nikola Brežnjak (@HitmanHR) July 23, 2017

Meetups

Introduction to Test Driven Development in PHP using PHPUnit – 11th MeCoDe meetup

Meetup notes

This Tuesday (18.07.2017) we had our 11th MeCoDe meetup, and this time the topic was Introduction to Test Driven Development in PHP using PHPUnit.

The presenter was Antonio Kovačević from the company Smartway, who explained:

  • What are Unit tests
  • Where should you use Unit tests
  • What is Test Driven Development
  • How to use tests as a basis for developing software

He also showed us first hand how to write a Unit test and run it.

Source code

In case you want to check out the code, you can do so via this Google Drive link.

Picture time

[ngg_images source=”galleries” container_ids=”30″ override_thumbnail_settings=”0″ thumbnail_width=”120″ thumbnail_height=”90″ thumbnail_crop=”1″ images_per_page=”20″ number_of_columns=”0″ ajax_pagination=”0″ show_all_in_lightbox=”0″ use_imagebrowser_effect=”0″ show_slideshow_link=”1″ slideshow_link_text=”[Show as slideshow]” order_by=”sortorder” order_direction=”ASC” returns=”included” maximum_entity_count=”500″ display_type=”photocrati-nextgen_basic_thumbnails”]

You don’t like PHP? ?

In case you’re interested in the topic but aren’t so quick to jump on PHP ?, you can check out a rather long post I wrote about the Introduction to TDD in Ionic framework which also covers JavaScript/Angular.

Call for speakers ?

As always, we welcome new speakers, even with n0 prior experience (you gotta start somewhere, right? :)) so in case you wanna share something with us, just shoot me an email…

Now go back to your code and write some tests! 😉

Introduction to Test Driven Development in PHP using #PHPUnit – 11th MeCoDe meetup https://t.co/wo9InPSjrQ

— Nikola Brežnjak (@HitmanHR) July 20, 2017

Books

The Complete Software Developer’s Career Guide

John Sonmez (Simple Programmer), an awesome guy that I’m following for some time now just published a new book called The Complete Software Developer’s Career Guide and you can get it here.

Currently the Kindle edition is on sale for less than a buck, so you may wanna jump on this opportunity!

He is the author of one of the best books for Software developers called Soft Skills: The Software Developer’s Life Manual. I wrote a detailed review about that book two years ago, and you can check it out here.

So, for this new book, here’s what he will teach you:

  • How to systematically find and fill the gaps in your technical knowledge so you can face any new challenge with confidence
  • Should you take contract work—or hold out for a salaried position? Which will earn you more, what the tradeoffs are, and how your personality should sway your choice
  • Should you learn JavaScript, C#, Python, C++? How to decide which programming language you should master first
  • Ever notice how every job ever posted requires “3-5 years of experience,” which you don’t have? Simple solution for this frustrating chicken-and-egg problem that allows you to build + legitimate job experience while you learn to code
  • Is earning a computer science degree a necessity—or a total waste of time? How to get a college degree that accelerates your career without burying you under a mountain of debt
  • Interviewer tells you, “Dress code is casual around here—the whole development team wears flipflops.” What should you wear?
  • Coding bootcamps—some are great, others are complete scams. How to tell the difference, so you don’t find yourself cheated out of $10,000
  • An inside look at the recruiting industry. What that “friendly” recruiter really wants from you, how they get paid, and how to avoid getting pigeonholed into a job you’ll hate
  • How do you deal with a boss who’s a micromanager. Plus how helping your manager with his goals can make you the MVP of your team
  • The must-know technical skills that every professional developer should have—but no one teaches you

Now, this indeed is copied ? from his book landing page, but I’m actually 100% certain all of it is true. How? Did I already read the WHOLE book!? Well, here’s the crazy part – during the last year or so, he was giving the chapters of his book for free on his website.

Here’s the review I left on Amazon about this book:

If you don’t like this book, I’m gonna buy it from you

I guarantee that if you follow John’s advice, if you trust the process, you’ll turn your software career around! Ever since I started following John via his blog and YouTube videos and applying what he teaches I need binoculars to look way back where I was. I can’t say a big enough thank you to John and this book is just a huge collection of everything you’ll ever need to know to succeed in this ever so slightly lucrative field of software development.

I personally believe that the concept of ‘trusting the process’ is the best skill to cultivate and nurture because it will catapult your success forward in ways you can’t imagine. He has some more videos about this topic, and you can watch them on his YouTube channel here. But, as many say:

It’s simple, but not easy

So keep that in mind and don’t back down when things get hard!

The Complete Software Developer's Career Guide is an awesome #book by the ever so slightly magnificent @jsonmez https://t.co/LI1JoF7yyU

— Nikola Brežnjak (@HitmanHR) July 19, 2017

Page 18 of 51« First...10«17181920»304050...Last »

Recent posts

  • Discipline is also a talent
  • Play for the fun of it
  • The importance of failing
  • A fresh start
  • Perseverance

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (35)
  • Daily Thoughts (77)
  • Go (3)
  • iOS (5)
  • JavaScript (127)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (2)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (77)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (40)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak