Tuesday, December 8, 2015

Re-looking at Design Patterns

     A design pattern identifies a common software development problem and provides a strategy
for dealing with it. It is just like a cooking recipe, Following a cooking recipe thoroughly does not serve food , you have to decide on quantities, number of people to serve and many other factors. Similarly, a design pattern does not provide ready made solution, you need to customize according to your own project specific requirements
     Design patterns are insurance policies for software development. Insurance policies work by trading a little cost now to avoid the possibility of a lot of cost later. The premium you pay to insure a car against theft, for example, costs a few percent of the value of the car, but when the car is stolen,  your overall costs are minimized. You still have to go through the inconvenience of having your car stolen, but at least you don’t have to bear the financial loss as well.
      In software development, design patterns are insurance against the time taken to solve problems. The premium is the time it takes to add extra flexibility to your code now, and the payout is avoiding a painful and protracted rewrite to change the way the application works later. Like real insurance policies, you may not benefit from paying the premium because the problem you anticipate might never happen, but software development rarely goes smoothly and problems often arise, so that additional flexibility is usually a good investment.

Courtesy :Adam Freeman (Pro Design Patterns in Swift) 

Monday, November 30, 2015

Few great points from the book "the principles of object oriented javascript by nicholas c zakas"

 I have summary of few great points from the book "the principles of object oriented javascript by nicholas c zakas" as below.
  • Primitive values are stored directly on the variable object, while reference values are placed as a pointer in the variable object, which serves as a reference to a location in memory where the object is stored
  • JavaScript is a garbage-collected language, so you don’t really need to worry about memory allocations when you use reference types. However, it’s best to dereference objects that you no longer need so that the garbage collector can free up that memory. The best way to do this is to set the object variable to null.
  • To identify reference types more easily, you can use JavaScript’s instance of operator
  • The arguments object is not an instance of Array and therefore doesn’t have the same methods as an array; Array.isArray(arguments) always returns false.
  • The number of arguments a function expects is stored on the function’s length property. Remember, a function is actually just an object, so it can have properties
  • In practice, checking the named parameter against undefined is more common than relying on arguments.length 
  • Because all instances of a particular type reference a shared prototype, you can augment all of those objects together at any time. Remember, the [[Prototype]] property just contains a pointer to the prototype, and any changes to the prototype are immediately available on any instance referencing it. That means you can literally add new members to a prototype at any point and have those changes reflected on existing instances 
Nichalas has great ability to explain complex concepts in simple ways and this book is easily rated one of great books on JavaScript along with The Good Parts 

Monday, November 9, 2015

Good parts of the book "JavaScript: The Good Parts"

Below is a summary of this excellent book "JavaScript: The Good Parts" by Douglas Crockford .
  • Logical Condition : the falsy values are false ,null ,undefined ,empty string , the number 0 and number NaN and other values true,the string 'false' and all objects are all truthy
  • Use the operator || can be used to fill in default values
  • One way to minimize the use of global variables is to create a single global variablefor your application: var MYAPP = {};
  • The functions are objects, they can be used like any other value. Functions can be stored in variables, objects, and arrays. Functions can be passed as arguments to functions, and functions can be returned from functions. Also, since functions are objects, functions can have methods.
  • There is no type checking on the argument values: any type of value can be passed to any parameter
  • A function always returns a value. If the return value is not specified, then undefined is returned. If the function was invoked with the new prefix and the return value is not an object,then this (the new object) is returned instead.
  • JavaScript does have function scope. That means that the parameters and variables defined in a function are not visible outside of the function, and that a variable defined anywhere within a function is visible everywhere within the function.
  • In many modern languages, it is recommended that variables be declared as late as possible, at the first point of use. That turns out to be bad advice for JavaScript because it lacks block scope. So instead, it is best to declare all of the variables used in a function at the top of the function body.
  • Functions as first class objects :Functions in Simplified JavaScript are lambdas with lexical scoping 
  • Dynamic objects with prototypal inheritance :Objects are class-free. We can add a new member to any object by ordinary assignment. An object can inherit members from another object.
  • Object literals and array literals This is a very convenient notation for creating new objects and arrays.
  • It is adviced to never use the evil twins. Instead, always use === and !==. All of the comparisons just shown produce false with the === operator.
  • The with statement should be avoided
  • Don’t use new Boolean or new Number or new String. Also avoid new Object and new Array. Use {} and [] instead.
  • Its better not to use new at all
  • Avoid Void 

Monday, November 2, 2015

How to use Pomodoro Technique at work/home

According to wiki,the following are  the steps to use pomodoro technique
  1. Decide on the task to be done
  2. Set the pomodoro timer to n minutes (traditionally 25)
  3. Work on the task until the timer rings; record with an x
  4. Take a short break (3–5 minutes)
  5. After four pomodoros, take a longer break (15–30 minutes)
Note :
       Before Starting pomodors for a day
  1. Estimate number of pomodors a task takes to finish
  2. Estimate number of tasks that can be finished in a day
  3. Estimate number of pomodors that is possible in a day
       During pomodoros
  1. Make note of internal( from you) and external (from others) interruptions in a notepad
  2. Attend/ Resolve these interruption after your pomodoro in the day 
  3. go out of your place during break 

Monday, October 19, 2015

How patterns/principles relates to AngularJS

     When i was unlearning and relearning AngularJS  few days back, Some already known patterns/ principles were all reflecting in my mind ( This is a kind of things that happens when you learn a technology.) Below is a list of those things in AngularJS

AngularJS Features
Patterns/principles related
Directives
Separation of Concerns
Declaring  dependencies at module creations/ member creation of module
Dependency injection
Services( service ,factory ,provider ,filter ) in AngularJS
single responsibility principle
Angular Objects like $window, $document, $http, $resource
Object Adapter Pattern
Promises object
Event/publisher patterns

Monday, October 5, 2015

Non Technical Books for Programmers

        "In technical lines as engineering, about 15 percent of one's financial success is due to one’s technical knowledge and about 85 percent is due to skill in human engineering-to personality and the ability to lead people." -Dale Carnegie
          I agree completely with Dale about above statements (Although, 15 % of technical knowledge is critical) Hence, I am providing a list of not technical books for programmers.
  1. How to Win Friends and Influence People
  2. Soft Skills: The Software Developer's Life Manual
  3. The 7 Habits of Highly Effective People
  4. The Passionate Programmer: Creating a Remarkable Career in Software Development
Note : For a complete list of technical and non-technical books for programmers, you can visit my goodreads books shelf here 

Sunday, September 27, 2015

Some Thoughts on code tunings


  • Performance is loosely related to code speed
  • Efficient code is not necessarily "better" code
  • Reducing the lines of code is not necessarily related to performance
  • Sometimes, performance depends on environment
  • Sometimes, a hardware upgrade is a way to increase performance
  • Avoid pre-optimization of code
  • Readable,clean code and a correct program is more important than faster programs
Steps to improve performance of a program
1. Develop the software using well-designed code that’s easy to understand and modify.
2. If performance is poor,
        a. Save a working version of the code so that you can get back to the “last known good state.”
        b. Measure the system to find hot spots.
        c. Determine whether the weak performance comes from inadequate design, data types, or          algorithms and whether code tuning is appropriate. If code tuning isn’t appropriate, go back to
 step 1.
        d. Tune the bottleneck identified in step (c).
        e. Measure each improvement one at a time.
        f. If an improvement doesn’t improve the code, revert to the code saved in step (a). (Typically, more than half the attempted tunings will produce only a negligible improvement in performance or degrade performance.)
 3. Repeat from step 2.

Courtesy : steve