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
JavaScript, Stack Overflow

How to override a function when creating a new object in the prototypal inheritance?

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

I asked the following question which turned out to be quite a popular one:

From this blog post we have this example of a prototypal inheritance in JavaScript:

var human = {
    name: '',
    gender: '',
    planetOfBirth: 'Earth',
    sayGender: function () {
        alert(this.name + ' says my gender is ' + this.gender);
    },
    sayPlanet: function () {
        alert(this.name + ' was born on ' + this.planetOfBirth);
    }
};

var male = Object.create(human, {
    gender: {value: 'Male'}
});

var female = Object.create(human, {
    gender: {value: 'Female'}
});

var david = Object.create(male, {
    name: {value: 'David'},
    planetOfBirth: {value: 'Mars'}
});

var jane = Object.create(female, {
    name: {value: 'Jane'}
});

david.sayGender(); // David says my gender is Male
david.sayPlanet(); // David was born on Mars

jane.sayGender(); // Jane says my gender is Female
jane.sayPlanet(); // Jane was born on Earth

Now, what I’m wondering is how does one properly “override”, for example, the sayPlanet function?

I tried it like this:

jane.sayPlanet = function(){
    console.log("something different");
};

and this works.

However, I also tried it like this:

var jane = Object.create(female, {
    name: {value: 'Jane'},

    sayPlanet: function(){
        console.log("something different");
    }
});

but I get a type error.

My questions are:

  • how can I add the sayPlanet function inside the Object.create?
  • is this at all “a good way” or is there a better (best practice) way?

edit: I figured a way how I can add the sayPlanet inside the Object.create:

sayPlanet: {
    value: function(){
        console.log("something different");
    }
}

However, a second question remains. Also, I would appreciate if someone can explain it in a bit deeper level if this is “a good way” to use it like this.

edit #2: As Mahavir pointed below, this is an awful example, because as it turns out you can’t (please correct me if I’m wrong) change the name of jane once it has been Object.created.

edit #3: (man oh man, this is going to get me in a certain facility where people wear white coats). As @WhiteHat pointed below, indeed you can set a name property to be updatable like this:

var jane = Object.create(female, {
    name: {
        value: 'Jane',
        writable: true
    }
});

and then you can do jane.name="Jane v2.0";.

I’ll be honest here people – I do not have a clue as to which direction to take with seemingly so many options. And just today I read Eric Elliot https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3 and now I don’t know what to think anymore because he goes on to argue that people at the ES6 aren’t quite doing it right :O. Meh, I guess I’ll have to revisit the Crockfords book yet again, decide on a “one way” and see how far it takes me.

 

I got quite a few answers, and I also set up a bounty since my question at first didn’t get much attention. Finally the answer by user Julien Grégoire which I accepted was this one:

Using Object.create is certainly a valid approach, but the example itself seems to me a bit misleading regarding the inner workings of Object.create. The blog post does a really good job of summarizing the different ways to create objects in javascript, but I don’t think the example for Object.create gives a good idea of how it works, which is more similar to the new/constructorapproach than it may seem.

Object.create allows to create an object based on a prototype, but without a constructor. This means that the prototype chain of the created object isn’t dependent on a constructor, (which is why it may be simpler to follow, this prototype linked via the constructor is not very straightforward or easy to follow). But Object.create still creates a prototype chain, in the same way new does.

So in your example, when you define name in human for example here:

var human = {
    name: '',

And then when you create jane:

var jane = Object.create(female, {
    name: {value: 'Jane'}

You’re not really assigning a value to the name property you defined in human. You’re in fact adding a property to jane. But human.name still is a property in prototype chain of jane. It works because javascript will follow the prototype chain to find the first matching property, but human.name is still somehow linked to jane.

See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain

Same thing happens if you use a constructor:

var Person = function(gender, name) {
     this.name = name;
}

var newPerson = new Person();

And same goes for sayPlanet function.

It’s a valid approach, but can lead to strange behaviors. For example, you could decide to modifiy sayPlanet for all humans by assigning it this way:

human.sayPlanet = function(){console.log('new sayPlanet')}

This would then work for all humans, except the ones for which you have given a sayPlanetproperty of their own. Which in your case may be the expected result. But still, you have to see if sayPlanet really should be a property of human.

With gender, it’s applied in human, and in male and female. So changing human.gender wouldn’t work on any one. But it’s still a property of human, which is a bit confusing when you want to work with these objects. You basically have a property that is defined, that is writable, but that when changed has no effect at all. It’s mainly an indication as to which property you need to add to your humans instances or somewhere in the prototype chain. Again, it seems to be used a lot, but when explained with this kind of examples, it somehow gives the impression that Object.create just combines properties, but it’s not what it does.

In the end, you need to chose if you want to work with prototypes or not. If not, then Functional inheritance is probably the best way. Then each object is different and has its own set of properties, that you can initialize, and you don’t have to worry about prototypes.

If you want to use prototypes, then you can use new/constructor or Object.create approach. But Object.create will create a prototype chain the same way new does, it just gets rid of the constructors.

A small example of how Object.create and new share some behaviors:

var human = {
    name: '',
    gender: '',
    planetOfBirth: 'Earth',
    sayGender: function () {
        console.log(this.name + ' says my gender is ' + this.gender);
    },
    sayPlanet: function () {
        console.log(this.name + ' was born on ' + this.planetOfBirth);
    }
};

var male = Object.create(human, {
    gender: {value: 'Male'}
});

var female = Object.create(human, {
    gender: {value: 'Female'}
});


var david = Object.create(male, {
    name: {value: 'David'},
    planetOfBirth: {value: 'Mars', configurable: true}
});

var jane = Object.create(female, {
    name: {value: 'Jane'},
    sayPlanet: {value: function(){
        console.log("something different");
        }, writable: true, enumerable: true, configurable: true
    }
});

var Male = function(name){ // in this case the real constructor is female or male. Name is the only property that 'needs' to be initialized
    this.name = name;
    this.planetOfBirth = 'Jupiter';
}

Male.prototype = Object.create(male);

var john = new Male('John')

david.sayGender(); // David says my gender is Male
david.sayPlanet(); // David was born on Mars

jane.sayGender(); // Jane says my gender is Female
jane.sayPlanet(); // Jane was born on Earth

john.sayGender(); // John says my gender is Female
john.sayPlanet(); // John was born on Earth


delete david.planetOfBirth; //just to show how human properties will still be in the chain even if you delete them
delete john.name; // It's true also if you use new. 
delete jane.sayPlanet;

console.log('\n','----after deleting properties----');

david.sayPlanet();
jane.sayPlanet();
john.sayGender();

human.planetOfBirth = 'Venus'; // This will apply to all humans, even the ones already created
                             
console.log('\n','----after assigning planetOfBirth on human----');

david.sayPlanet();
jane.sayPlanet();
john.sayPlanet(); // John still has planetOfBirth as its own property, since it wasn't deleted

delete john.planetOfBirth;

console.log('\n','----after deleting john planetOfBirth----');

john.sayPlanet();  // But it's still there

And in fact (just to be more confusing), some people combine Object.create with new/constructoror with Functional inheritance. Something like this for example:

https://john-dugan.com/object-oriented-javascript-pattern-comparison/#oloo-pattern

Applied to your example it would give something like this:

var human = {
    planetOfBirth: 'Earth',
    sayGender: function () {
        console.log(this.name + ' says my gender is ' + this.gender);
    },
    sayPlanet: function () {
              console.log(this.name + ' was born on ' + this.planetOfBirth); 
    },
    init: function(name){
        this.name = name;
    }
};

var male = Object.create(human, {
    gender: {value: 'Male'} // This is part of male/female prototype and can't be written, which seems logical
   });

var female = Object.create(human, {
    gender: {value: 'Female'}
});


var david = Object.create(male).init('David');
david.planetOfBirth = 'Mars';

var jane =  Object.create(female).init('Jane')
jane.sayPlanet = function(){console.log('something different')};

var john =  Object.create(male).init('John');
john.planetOfBirth = 'Jupiter';




david.sayGender(); // David says my gender is Male
david.sayPlanet(); // David was born on Mars

jane.sayGender(); // Jane says my gender is Female
jane.sayPlanet(); // Jane was born on Earth

john.sayGender(); // John says my gender is Female
john.sayPlanet(); // John was born on Earth


delete david.planetOfBirth; // Overridden properties will still exists after delete, but not the others.
delete john.name;
delete jane.sayPlanet;

console.log('\n','----after deleting properties----');

david.sayPlanet(); 
jane.sayPlanet(); 
john.sayPlanet(); 

human.planetOfBirth = 'Venus'; // This will apply to all humans, even the ones already created. 
                               // But not for humans woth overridden planetOfBirth.

console.log('\n','----after assigning planetOfBirth on human----');

david.sayPlanet();
jane.sayPlanet();
john.sayPlanet(); // John's name is now undefinded

delete john.planetOfBirth;

console.log('\n','----after deleting john planetOfBirth----');

john.sayPlanet();  //

Not necessarily better, but it works as well, and in my opinion has certain advantages.

In any case, as others said, there doesn’t seem to be a standard or default way to do this.

Also, another great answer was by a user Nice-Guy:

The best practice as I’ve learned is to define write permissions at the Object prototype level. I learned this technique from reading Addy Osmani’s JavaScript Design Patterns, it’s very reputable and open source online: http://addyosmani.com/resources/essentialjsdesignpatterns/book/

Please check out the sayPlanet property in the example below. Keep in mind, you do not need to set all the other properties’ “writeable” to false, I only did it in my example code to illustrate the point. This approach affords more flexibility and reusability than the other, still valid, approaches. Here, you may notice that this is the Object.defineProperties syntax within the prototype.

var human = {
  name: {
    value: '',
    writable: false //only to illustrate default behavior not needed
  },
  gender: {
    value: '',
    writable: false //only to illustrate default behavior not needed
  },
  planetOfBirth: {
    value: "Earth",
    configurable: false //only to illustrate default behavior not needed
  }

};

//here we define function properties at prototype level

Object.defineProperty(human, 'sayGender', {
  value: function() {
    alert(this.name + ' says my gender is ' + this.gender);
  },
  writable: false
});

Object.defineProperty(human, 'sayPlanet', {
  value: function() {
    alert(this.name + ' was born on ' + this.planetOfBirth);
  },
  writable: true
});

//end definition of function properties

var male = Object.create(human, {
  gender: {
    value: 'Male'
  }
});

var female = Object.create(human, {
  gender: {
    value: 'Female'
  }
});

var david = Object.create(male, {
  name: {
    value: 'David'
  },
  planetOfBirth: {
    value: 'Mars'
  }
});

var jane = Object.create(female, {
  name: {
    value: 'Jane'
  }
});

//define the writable sayPlanet function for Jane
jane.sayPlanet = function() {
  alert("something different");
};

//test cases

//call say gender before attempting to ovverride
david.sayGender(); // David says my gender is Male

//attempt to override the sayGender function for david 
david.sayGender = function() {
  alert("I overrode me!")
};
//I tried and failed to change an unwritable fucntion
david.sayGender(); //David maintains that my gender is Male

david.sayPlanet(); // David was born on Mars

jane.sayGender(); // Jane says my gender is Female
jane.sayPlanet(); // something different

https://twitter.com/HitmanHR/status/653822447385505792

Books

It’s Not How Good You Are, It’s How Good You Want to Be – Paul Arden

My notes from a book It’s Not How Good You Are, It’s How Good You Want to Be: The world’s best selling book by Paul Arden, which I rated 4/5 on my Shelfari account.

This was a very short book from which, I guess, the Creatives will get the most out of. Us, more Engineeringly minded types, may just stand and look in wow 🙂

Anyways, a good book, and here are my notes from it, with few of the bookshots.

All creative people need something to rebel against , it’s what gives their lives excitement, and it’s creative people who make the clients’ lives exciting.

Give away everything you know, and more will come back to you.

People who are conventionally clever get jobs on their qualifications (the past) not on their desire to succeed (the future).

There is nothing that is a more certain sign of insanity than to do the same thing over and over again and expect the results to be different. ~ Einstein

True, people do look for something new, but sometimes it’s something new to copy. To be original, seek your inspiration from unexpected sources.

Talent helps, but it won’t take you as far as ambition.

It’s not what you know – it’s who you know.

Blame no one but yourself. If you accept responsibility, you are in position to do something about it.

How you percieve yourelf is how others will see you.

When we attend a lecture, we generally go to see the speaker not to hear what they have to say.

If you show a client a highly polished computer layout, he will probably reject it because he doesn’t feel involved.

The way to get unblocked is to lose our inhibition and stop worrying about being right.

Decide you are going to make the company great; at least decide you are going to make a difference.

Relize that companies’ reputations are also built on one or two people. Aim to be that person or one of them.

If you can’t solve a problem, it’s because you’re playing by the rules.

Lines (slogans) win business. If you can find a way of summing up what the client wants to feel about his company but cannot express himself, you’ve got him.

d13f22125918714f48527b7c632ec9e28e2417a273e425910893d8b48320299c

I haven’t failed. I’ve had 10000 ideas that didn’t work. ~ Benjamin Franklin

Of the 200 light bulbs that didn’t work, every failure told me something that I was able to incorporate into the next attempt.

If we don’t get lost, we’ll never find a new route.

All of them understand that failures and false starts are a precondition of success.

db0eeacabcfbb25c6429b30d6087647e32ae439cd89409fc412717a41dce50fd

Experience is opposite of being creative.

Give me the same as we had for the last 20 years but not quite. Only one client in 10k will actually mean ‘give me something I haven’t seen before’.

It’s better to fail in originality, than to succeed in imitation. ~ Herman Melville

Success is going from failure to failure with no loss of enthusiasm. ~Winston Churchill

The first thing to decide before you walk into any negotiation is what to do if the other fellow says no. ~ Ernest Bevin

There are no short cuts to any place worth going. Beverly Sills

Those who lack courage will always find a philosopy to justify it. ~Albert Camus

Some people take no mental exercise apart from jumping to conclusions. ~Harold Acton

What the mind can conceive, the mind can achieve. ~Clement Stone

Of everything seems under control you’re no going fast enough. ~ Mario Andretti

Going to church doesn’t make you a Christian anymore than going to a garage makes you a mechanic. ~Laurence Peter

A Technique for Getting Ideas by James Wood Young

It's Not How Good You Are, It's How Good You Want to Be – Paul Arden http://t.co/ELesySAtxI #books

— Nikola Brežnjak (@HitmanHR) October 5, 2015

 

Ionic, Stack Overflow

How to use ECMAScript 6 features in Ionic framework?

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m in the top 5 All time answerers.

I answered this question by user user5148540:

I recently used the new Set data structure specification instead of an array where I didn’t wanted any repeated values to be stored and it is working without problems, but I’m wondering I want to implement some of the new features such as let, class and const.

I’m using also the crosswalk plugin in case this is relevant.

Can anyone tell me if I should avoid ES6 for the moment or if its okay to be used?

My answer was:

I actually googled about this myself earlier today and I found this tutorial:http://labs.encoded.io/2015/06/22/use-es6-with-ionic/

StackOverflow encourages to not just use links as answers, so I’m just going to give my TL;DR, since this is not my own site and I don’t want to be held accountable for c/p.

Ionic uses Gulp, so install gulp-babel and gulp-plumber.

npm install --save-dev gulp-babel gulp-plumber

Add babel to gulpfile.js like so:

//...
var babel = require("gulp-babel");
var plumber = require("gulp-plumber");

var paths = {
  es6: ['./src/es6/*.js'],
  sass: ['./scss/**/*.scss']
};

gulp.task('default', ['babel', 'sass']);

gulp.task("babel", function () {
  return gulp.src(paths.es6)
    .pipe(plumber())
    .pipe(babel())
    .pipe(gulp.dest("www/js"));
});

//...

gulp.task('watch', function() {
  gulp.watch(paths.es6, ['babel']);
  gulp.watch(paths.sass, ['sass']);
});
//...

Edit ionic.project:

"gulpStartupTasks": [
    "babel",
    "sass",
    "watch"
 ],

For any more details consult the original link – and with this I also say thanks to the author of that blog post as it helped me too.

How to use #ECMAScript 6 features in #Ionic framework?http://t.co/kyur9xI2Dy pic.twitter.com/e2JCzStBKF

— Nikola Brežnjak (@HitmanHR) September 29, 2015

NodeJS

List globally installed Node.js packages on your machine

To list globally installed Node.js packages on your machine you can run the following command:

ls `npm root -g`

and it will just list globally installed packages, like for example:

drwxr-xr-x   19 nikola  staff   646 May  3 21:07 bower
drwxr-xr-x   29 nikola  staff   986 May 20 20:59 casperjs
drwxr-xr-x    9 nikola  staff   306 Feb 27  2015 compass
drwxr-xr-x   16 nikola  staff   544 Feb  6  2015 cordova
drwxr-xr-x    9 nikola  staff   306 May  1 16:50 express
drwxr-xr-x    8 nikola  staff   272 May  1 16:48 express-generator
drwxr-xr-x   12 nikola  staff   408 Dec 15  2014 forever
drwxr-xr-x   23 nikola  staff   782 Feb 27  2015 generator-angular
drwxr-xr-x    6 nikola  staff   204 Feb 27  2015 generator-gulp-angular

If, however, you use the following command:

npm list --global

it will give you the full list of other dependencies in a tree list, like for example:

├─┬ [email protected]
│ └─┬ [email protected]
│   ├─┬ [email protected]
│   │ └── [email protected]
│   ├── [email protected]
│   ├─┬ [email protected]
│   │ └─┬ [email protected]
│   │   ├── [email protected]
│   │   └── [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]

List #globally installed #Node.js #packages on your machine http://t.co/vdUvLbUZe6

— Nikola Brežnjak (@HitmanHR) September 27, 2015

Books

The Chimp Paradox by Dr. Steve Peters

My notes from a book The Chimp Paradox by Steve Peters subtitled “The Mind Management Program to Help You Achieve Success, Confidence, and Happiness”, which I rated 4/5 on my Shelfari account.

Psychologically mind is made up of three separate brains: Human – you. Chimp – emotional thinking machine. Computer – storage area and automatic functioning machine.

Happiness can be found in many ways. It’s the way you deal with things, not what happens, that gives you peace of mind. Every day is precious.

Person that you want to be is the person that you really are.

Never assume that because you’ve told someone something that they’ve heard it or understood it.

When you find yourself stressed, deliberately slow down your thinking.

At night you are in the chimp mode with emotional and irrational thinking.

If you measure success in life my effort and doing your best then it’s always in your hands succeed and to be proud of yourself.

When you decide to do something it’s commitment, not motivation that matters.

If you were given the million dollars to do the task before the end of the day, could you do it?

People usually love ownership and will take things more seriously when given it.

Commit the small change and do it consistently.

Don’t battle – instead live such lifestyle. For example, don’t battle your sugar eating habbit, instead don’t do it because you “just don’t”, because it’s the way you live.

The #Chimp #Paradox by Dr. Steve Peters http://t.co/NGUvEalJRB

— Nikola Brežnjak (@HitmanHR) September 27, 2015

Ionic, Stack Overflow

Subversion ignored files for Ionic Framework

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m in the top 5 All time answerers.

I answered this question by user Florent Guenebeaud:

I would like to use Subversion with my Ionic project. What are files to be ignored in the Subversion?

My answer was:

This is the one I use with Git for Ionic (my .gitignore file):

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

node_modules/
platforms/
plugins/

Basically the same would apply for SVN.

Btw, if you’re looking for a decent Subversion guide, I made a presentation back in the days I was at my University: http://nikola-breznjak.com/portfolio/Subversion_en.pdf

Miscellaneou$

The winner of my Grammarly prize draw

A month ago I started a Grammarly prize draw. I added all of the emails in the random.org and here are the top 5:

Screen Shot 2015-09-20 at 21.25.37

I’ve listed 5 in case someone will maybe not want it or would like to give it to someone else or would not get back to me in a decent period of time (I also sent a newsletter about this). I’m expecting the winner to contact me via my email address and also to comment below in this post.

Thanks all for participating, I’m hoping that I’ll have a next one soon, and this time I was thinking it would be great if the prize would be a Sublime Text 3 license – what do you think?

Books, Programming

The passionate programmer by Chad Fowler

I rated the book The passionate programmer by Chad Fowler as favorite on my Shelfari account and shortly reviewed it as:

Trully a classic in our field!

Those of you who have been following my Books category know that I like to mark the passages that I find valuable from books that I read (and somewhere also add my own piece of wisdom 1415131129_smiley-evil), like for example:

ppHardWork

All in all, below are my notes from this book (yes, I know – there are quite a lot of them), and I’m sure a lot of them will resonate with you and I’m sure you’ll want to get a physical copy for yourself  too (if for nothing else, then for doodling on it ;)). Best of all, the book is currently 43% off on Amazon for only $13.58.

I believe that everyone has remarkable in them but that it takes finding something they truly care about to draw it out. You can’t be remarkable if you don’t love your environment, your tools, and your domain.

To become remarkable, you have to believe that you’re making a significant dent in the universe.

Most people spend far more of their waking adulthood working than doing anything else.

If your life is primarily consumed by your work, then loving your work is one of the most important keys to loving your life. Challeng-ing, motivating, rewarding work is more likely to make you want to get up in the morning than dull, average tasks. Doing your job well means that the activity you do for 50 percent of your available time is something you’re good at. Conversely, if you don’t do your job well, a large amount of your time will be spent feeling inadequate or guilty over not performing at your best.

You don’t win a race by trying not to lose.

Kent Beck Extreme programming explained

A person who wants to become great is far more likely to become great than someone who just wants to do their job.

Most people follow everyone else’s plan but their own. To start differentiating yourself, all you have to do is stop and take a good look at your career. You need to be following your plan for you – not theirs.

Businesses don’t exist so we can have a place to go every day. The purpose of a business is to make money.

In The Pragmatic Programmer: From Journeyman to Master, Dave Thomas and Andy Hunt talk about programming by coincidence. Most programmers can relate to the idea: you start working on something, add a little code here, and add a little more there. Maybe you start with an example program that you copy and paste from a website. It seems to work, so you change it a little to be more like the program you really need. You don’t really understand what you’re doing, but you keep nudging the program around until it almost completely meets your needs. The trouble is, you don’t understand how it works, and like a house of cards, each new feature you add increases the likelihood your program will fall apart.

Which technologies should we invest in? Which domain should we develop expertise in? Should we go broad or deep with our knowledge? These are questions we really should be asking ourselves.

Imagine you’ve started a company and you’re developing what is destined to be the company’s flagship product. Without a “hit” with this product, your company is going to go bankrupt. How much attention do you pay to who your target customers are? Before actually manufacturing the product, how much thought do you put into what the product actually is? None of us would let decisions like these be made for us. We’d be completely attentive to every detail of the decision-making process.

So, why is it that most of us don’t pay this kind of attention to the choices we make in our careers? If you think of your career as a business (which it is), your “product” is made up of the services you have to offer. Is demand for your services going to grow or decline over the coming years?

15 years ago COBOL would be a low-rise choice. Low risk low reward. At the time if you invested in Java it would be high risk high reward. BeOS was high risk no reward at the time.

Picking a stable technology that has already wedged itself into the production systems of businesses worldwide is a safer, but potentially less rewarding, choice then picking a flashy new technology that nobody has deployed yet.

Make a list of early, middle, and late adoption technologies based on today’s market. Map them out on paper from left to right; the left is bleeding edge, and the right is filled by technologies that are in their sunsets. Push yourself to find as many technologies in each part of the spectrum as possible. Be as granular as possible about where in the curve they fall in relation to one another. When you have as many technologies mapped out as you can think of, mark the ones that you consider yourself strong in. Then, perhaps, in a different color, mark the ones that you have some experiehce with but aren’t authoritative on. Where are most of your marks on the adoption curve? Do they clump? Are they spread evenly across? Are there any technologies around the far edges that you have some special interest in?

As a .NET programmer, you may find yourself competing with tens of thousands of more people in the job market than you would if you were, for example, a Python programmer. This would result in the average cost of a .NET programmer decreasing significantly, possibly driving demand higher (in other words, creating more .NET jobs). So, you’d be likely to find jobs available, but the jobs wouldn’t pay all that well. If the Python job market were to support noticeably higher prices per programmer, additional people might be attracted to supply their services at this higher price range, resulting in competition that would drive the price back down.

India caters to the already balanced IT services markets. You don’t find mainstream Indian offshoring companies jumping on unconventional technologies. They aren’t first-movers. They generally don’t take chances.

You can’t compete on price, but you can compete on ability.

Research current technical skill demand. Use job posting and career websites to find out which skills are in high demand and in low demand. Find the websites of some offshore outsourcing companies (or talk to employees of those companies if you work with them). Compare the skills available via these companies with the high—demand list you compiled. Make note of which skills appear to be in high demand domestically with little penetration offshore. Do a similar comparison between bleading—edge technologies and the skills available via offshore outsourcing firms. Keep your eyes on both sets of technical skills that are underserved by the offshore companies. How long does it take for them to fill the holes (if ever)? This time gap is the window during which a market imbalance exists.

If you want to stay relevant,you’re going to have to dive into the domain of business you’re in.

Look for industry websites that you can monitor on a regular basis. In both the websites and the magazines, pay special attention to what the big news items and the feature articles are about. What is your industry struggling with? What’s the hot new issue right now? Whatever it is, bring it up with your business clients. Ask them to explain it and to give you their opinions. Think about how these current trends affect your company, your division, your team, and eventually your work.

Be the worst guy in every band you’re in. Being the worst guy in the band means always playing with people who are better than you.

So I learned from this that people can significantly improve its regress in skill, purely based on who they are performing with.

Pick an open source project that you admire and whose developers appear to be at that “next level” you’re looking to reach.

At the time I’d writing, the most popular language is Java, followed by C.

My explanation is that either good people seek out diversity, because they love to learn new things, or being forced into alien experiences and environments created more mature, well-rounded software developers.

For me, as a hiring manager, the first reason is that it shows that you’re interested. If I know you learned something for the sake for the sake of self-development and (better) pure fun, I know you are excited and motivated about your profession.

Learn a new language that makes you think in a new way.

Thinking about not losing is not the way to win! Winners take risks. They think about where do you want to go – not where the rest of the pack is.

But if your job isn’t fun, as we’ve come to realize, you don’t do a fantastic job at it.

More of us understand action leads to excellence. And without fun, there’s unlikely to be any passion in a software job.

Staying in the single company, working your way up the ranks, easily would think environment in which to grow as a developer. Gone are the days of the life for who would join a big company and settle in for a full career. This sort of behavior used to be assigned of the dictation. No it’s a liability. If you work in only one place and seen one set of systems, many [smart] managers would see that as a strike against you when making hiring decisions. I personally rather hire someone who has seen the variety of successes and failures in different environments than someone who has known only one way of doing things.

Programmer geeks can’t lead, and leaders can’t hack. It’s rare to find someone who’s even decent both.

Unfortunately, the software industry has turned out a whole lot of these shallow specialists who use the term specialist as an excuse for knowing only one thing.

This guy wanted to build his career around a specific technology created by a specific company of which he was not an employee. What if the company goes out of business? What if it let its now-sexy technology become obsolete? Why would you want to trust a technology company with your career?

The professional services barrier is the artificial barrier that a company erects between you and the solution to a problem you may have so that it can profit from selling you support services. Sometimes this barrier is intentionally erected, and sometimes it’s erected as a side effect of the attempt the company makes to protect its intellectual property (by not sharing its source code).

Try the small project, twice. Try it once in your home-based technology and then once, as idiomatically as possible, in the competing technology.

You have to be passionate about your work if you want to be great at your work. If you don’t care, it will show.

It turns out that, coupled with my natural talent, a few hours of investment have made these ”always wanted to be able to do it” abilities attainable. And as I’ve started to put in the investment, it builds on itself. One technique leads to the next, and one barrie-breaking practice session motivates the next. The structured me who invests in his abilities (even as a hobby) completely wipes the floor with the me who bets it all on natural talent and ability.

Lao Tzu said, ”Give a man a fish; feed him for a day. Teach a man to fish; feed him for a lifetime.” That’s all well and good. But Lao Tzu left out the part where the man doesn’t want to learn how to fish and he asks you for another fish tomorrow. Education requires both a teacher and a student.

Don’t ask to be taught, learn for yourself!

You can creatively help a business until you know how it works.

Depending on others is often seen as a sign of weakness.

It’s better to be moving in one direction than to be sitting still.

Important thing is that he narrowed down the long list of skills I could be learning to the short list of skills I learned.

If you want to really learn something, try teaching it to someone.

You don’t have to set up a formal mentoring relationship to get these benefits. Just start helping people, and the rest will come naturally.

If you always sound good during practice sessions, it means you’re not stretching your limits.

Important thing is to find your practice needs and to make sure you’re not practicing during your performances [on the job]. You have to make time for practice. It’s your responsibility.

codekata.com

Even with the abundance of prescriptive methodologies to choose from, it’s not likely you will ever work for a company that fully implement any of them. That’s OK. The best process to follow is the one that makes your team most productive and results in the best products.

Studying the work of masters is in the central part of becoming a master.

If you can hear the music or see the piece of art, you can learn from it. Thankfully, as a soft for developers we have access to practically infinite array of existing software in the form of open source software.

Sir Isaac Newton said, “If I have seen further, it’s by standing on the shoulders of giants.”

The standard IT management answer is that you add programmers to go faster. It’s wrong, but that’s what people believe.

Unless you’re really lucky, you’re probably not getting paid to be smart.

We are being paid to create value.

To be successful, wrong ability will get you only so far. The final stretch is populated by closures – people who finish things. This means getting up out of our reading chairs and getting things done.

Work expands so to fill time available for its competition.

Sense of urgency, even if manufactured, is enough to easily double or triple your productivity.

Always be the one to ask, “But, what can we do right now?”

It seems backward, but keeping your mind focused on the present will get you further toward your goals than keeping your mind focused on the goal itself.

Why is that, without facing great pressure, we are often able to work ourselves into this kind of altruistic, ultra productive frenzy.

How much more fun with your job be if you could treat the most interesting and annoying tasks with the same feverish desire to do them right?

It’s easy to get into the mode of just wanting more. It unfortunately seems to be a basic human tendency, in fact. You get the salary increase, and it feels good for a little while, but then you’re thinking about the next one.

Ask, “Was I worth it today?”

A dollar today is worth more than a dollar next year, because a dollar today can be used to generate more dollars.

You should never get too comfortable.

The less replaceable you think you are, the more replaceable you are.

Everyone likes creating. That’s when we feel we are given the opportunity to really put our stamp on a piece of work. To feel like we own it.

If l give you $1,000 and ask you to go get me a cup of coffee, I’m going to be very unhappy if you return with 1,000 less dollars and no cup of coffee. I’m even going to be unhappy if you bring me plenty of really nice coffee but it takes you two hours. If I give you $0 and ask you to go get me a cup of coffee, I’ll be extremely appreciative if you actually return with the coffee, and I’ll be understanding if you don’t. Project work is like the first scenario. Maintenance is like the second.

Martin renamed 40 hour work week to 8 hour burn.

When it comes to work less really can be more. The primary reason cited by the extreme programmers is that when we are tired we can’t think as effectively as when we are rested. When we are burned out, we aren’t as creative, and the quality of our work reduce his dramatically. We start making stupid mistakes that end up costing us time and money.

Projects are marathons not sprints.

Though your short-term productivity will significantly increase as you start putting in the hours, in the long term you’re going to crash so hard that the recovery time will be larger than the productivity gains you enjoy during your 80 hour weeks.

Apparently, when money was scarce, I found ways to be more efficient with my cash. And, the end result was essentially the same.

Bob Martin’s eight hour burn places the constraint on you and gives you a strategy for dealing with that constraint. You get to work and think, I’ve only got eight hours!

As thought workers, even if we’re not in front of a computer or in the office, we can be working. You might be working while you’re driving to dinner with your spouse or while you’re watching a movie. Your work is always around nagging you.

Make sure you sleep well tonight. Tomorrow, eat breakfast and then start work at an exact time [preferably a little earlier than usual]. Work on it for four hours. Take an hour lunch. Then work for four more hours so intensely that you’re absolutely exhausted and can’t do anymore work. Go home, relax, and have fun.

A problem needs resolution. Lingering on who’s fault it is only prolongs the issue.

The quickest path to missing your commitment is to make commitments that you know you can’t meet. I know that sounds patently obvious, but we do it every day. We are put on the spot and we don’t want to disappoint our leaders, so we agreed to impossible work being done in impossible timelines.

Heroes never panic.

We panic because we lose perspective. When something is going wrong, it’s hard not to focus all attention on the problem. To some extent, that’s a good way to solve problems. Unfortunately, it also makes the problem, no matter how small, see more important than it is. And with the problem inflated and stress level running high, our brains turn themselves off.

So, here’s how I’m learning to not panic. When something bad happens and I start to feel that sinking, stressed-out feeling that leads to panic, I compare myself to the frustrated computer-illiterate, and I laugh at myself. I analyze the situation from the third—person perspective, as if I’m helping that frustrated family member with their word processing disaster. Seemingly hard problems are suddenly easier. Seemingly bad situations are suddenly not so bad. And, I often find that the solution simple and staring me in the face in the same way that an error dialog often tells you exactly what to do next. If you’d just have the presence of mind to read the error message, the problem might be solved.

Like families, successful projects are alike, but they become successful project fails in its own way.

In short, you may have the best product in history, but if you don’t do some kind of advertising, nobody’s going to buy it.

These managers and customers we are talking about have a dirty little secret: they are afraid of you. And for a good reason. You’re smart. We speak a cryptic language they don’t understand. You make them feel stupid with your sometimes sarcastic comments [which you might not have even intended to be sarcastic]. And, your work often is the last and most important toll gate between the projects conception and it’s birth.

Wouldn’t you want to hire the person who wrote the book and technology or methodology you’re attempting to deploy?

You will never feel 100% ready, so might as well start now.

Anyone can use Rails. Few can say Rails contributor.

Don’t just mastered the subject – write the book on it. Write code generators that take what used to be a one week process took a five minute process. Instead of being respected among your coworkers, become your cities most recognizable authority on whatever technologies you’re focusing on by doing seminars and workshops. Do something previously unthinkable on your next project.

Carve out weekly time to investigate the bleeding edge. Make room for at least two hours each week in order to research and get the colleges and to start develop skills in them.

The next time you have to wash the dishes, don’t wash them to get them done. Try to enjoy the experience of washing the dishes. Don’t focus on finishing them. Focus on the act of washing them itself.

Watch the alpha geeks.

If you’re constantly exposed to something, it’s hard to see it changing unless change happens rapidly.

Developer, review thyself.

Start keeping a journal. It could be a blog or a personal diary. Write about what you’re working on, what you’re learning, and your opinions about the industry. After you’ve been keeping the journal for sometime, reread old entries. Do you still agree? Do they sound knees? How much have you changed?

Make your improvements small and incremental but daily.

I highly recommend that you check out the book Soft Skills by John Sonmez if you liked this post, as you’ll find even more great content about how to become the best software developer version of yourself.

Quick tips

How to open current folder in Explorer from Command prompt on Windows

To open current folder in Explorer from Command prompt on Windows use the following command:

explorer .

The dot (.) represents the current directory.

This is usually useful for when you’re using Command prompt (or any other you prefer, like Console2 for example) to navigate through your folders but then you need to open the current one for some reason in the Explorer.

You also may want to check out How to open current folder in Finder from Terminal on Mac OS X.

Ionic, Stack Overflow

Android/iOS app with Django as backend

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m in the top 5 All time answerers.

I answered this question by user cold_coder:

I have a website project built in Django and want to build a mobile app for it. I did a lot of research but was confused between native and hybrid app. My project is basically a Quora clone and just a college project. I also saw PhoneGap, Ionic and Sencha but I am really confused about how they all fit. Do I have to use Ionic with PhoneGap or Apache Cordova or just Ionic? What is the structure and where should I start?

My answer was:

TL;DR: Start with Ionic. Ionic uses Cordova “under the hood”. No need for PhoneGap or Sencha, so don’t be confused by that.

Disclaimer: This will sound like advertisement, so I have to say I’m in no way affiliated with Ionic, I just happen to like it so much that I’m sharing the love for it.

Let’s take this one step by step:

What is Ionic?

Ionic is a framework for building hybrid mobile apps, and it’s built on an ecosystem that includes Angular as the web application framework and uses Cordova for the building and packaging of the native app. Ionic creates a native mobile app that can be installed via the app stores, and contains what is called a WebView (essentially an isolated browser window) with a JavaScript API inside which the web application will run.

What is hybrid mobile app?

If you’re a web developer, you have a decent knowledge of HTML, CSS and JavaScript. Also, you’re most likely using one of the ever so slightly popular frameworks these days like AngularJS. Up until fairly recently if you wanted to make an app for (currently) two most popular mobile operating systems iOS and Android your only bet was to make the so-called native applications using the SDKs of the intended platform itself. This, of course, meant that you needed to make two versions of your application – both for iOS and Android. If you are a solo developer chances that you’re proficient in both are not so high.

Nowadays, luckily, with the Ionic Framework you can create one application by using the skills you already have as a web developer and then deploy this one codebase as an app to both iOS and Android stores. How cool is that, right? So, hybrid because it’s a “simple” web app wrapped inside the native app with a so-called WebView.

Why is Ionic cool?

Ionic is awesome because it’s not “just” a framework. Instead, it has a whole ecosystem built around it. For example, Ionic allows you to:

  • generate icons and splash screens for all devices and device sizes with a single command: ionic resources. This alone saves you at least a day of image preparing for various sizes.
  • instantly update your apps with code changes, even when running directly on your device with ionic run --livereload
  • build and test iOS and Android versions side-by-side and see changes instantly with ionic serve --lab
  • share your Ionic apps with clients, customers, and testers all around the world without ever going through the App Store with ionic share
  • easily accessing the full native functionality of the device using ngCordova (here you get to use any Cordova plugin – so Ionic is indeed much more than Cordova per se)
  • Also, they’re (Ionic team) building a full-stack backend services and tools for your Ionic app likeDeploy (for deploying a new version without going through Apple review process!), Analytics,Push notifications.
  • Ionic CLI (command line interface) uses Cordova in the backend and allows you to build (directly using Ionic CLI) apps for iOS and Android (you by doing ionic build ios or ionic build android and woila)
  • Ionic uses Angular as a frontend framework so if you’re familiar with it it will come as a bonus. They’re working closely with the Angular 2.0 team too.

How to start your project?

If you take a look at my answer to this question you’ll see that if you already have an API defined in your Django backend, then you can start using it quite quickly by leveraging the existing API and consuming it with Angular $resource.

Hope this helps and that you find using Ionic a pleasure.

Page 30 of 51« First...1020«29303132»4050...Last »

Recent posts

  • When espanso Breaks on Long Replacement Strings (and How to Fix It)
  • 2024 Top Author on dev.to
  • Hara hachi bun me
  • Discipline is also a talent
  • Play for the fun of it

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (36)
  • Daily Thoughts (78)
  • Go (3)
  • iOS (5)
  • JavaScript (128)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (3)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (78)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (41)
  • 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