Thursday, 28 April 2016

Iterator pattern

In object-oriented programming, the iterator pattern is a design pattern in which an iterator is used to traverse a container and access the container's elements. The iterator pattern decouples algorithms from containers; in some cases, algorithms are necessarily container-specific and thus cannot be decoupled.
For example, the hypothetical algorithm SearchForElement can be implemented generally using a specified type of iterator rather than implementing it as a container-specific algorithm. This allows SearchForElement to be used on any container that supports the required type of iterator.

Definition

The essence of the Iterator Factory method Pattern is to "Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.".

Language-specific implementation

Some languages standardize syntax. C++ and Python are notable examples.

C++

C++ implements iterators with the semantics of pointers in that language. In C++, a class can overload all of the pointer operations, so an iterator can be implemented that acts more or less like a pointer, complete with dereference, increment, and decrement. This has the advantage that C++ algorithms such asstd::sort can immediately be applied to plain old memory buffers, and that there is no new syntax to learn. However, it requires an "end" iterator to test for equality, rather than allowing an iterator to know that it has reached the end. In C++ language, we say that an iterator models the iterator concept.

C#

.NET Framework has special interfaces that support a simple iteration: System.Collections.IEnumerator over a non-generic collection andSystem.Collections.Generic.IEnumerator<T> over a generic collection.
C# statement foreach is designed to easily iterate through the collection that implements System.Collections.IEnumerator and/orSystem.Collections.Generic.IEnumerator<T> interface.
Example of using foreach statement:
var primes = new List<int>{ 2, 3, 5, 7, 11, 13, 17, 19};
long m = 1;
foreach (var p in primes)
    m *= p;

Java

Java has the Iterator interface.
As of Java 5, objects implementing the Iterable interface, which returns an Iterator from its only method, can be traversed using the enhanced for loop syntax.[2] The Collection interface from the Java collections framework extends Iterable.

Python

Python prescribes a syntax for iterators as part of the language itself, so that language keywords such as for work with what Python calls sequences. A sequence has an __iter__() method that returns an iterator object. The "iterator protocol" requires next() return the next element or raise a StopIteration exception upon reaching the end of the sequence. Iterators also provide an __iter__() method returning themselves so that they can also be iterated over e.g., using afor loop. Generators are available since 2.2.
In Python 3, next() was renamed __next__().

PHP

PHP supports the iterator pattern via the Iterator interface, as part of the standard distribution. Objects that implement the interface can be iterated over with theforeach language construct.
Example of patterns using PHP:
<?php

// BookIterator.php

namespace DesignPatterns;

class BookIterator implements \Iterator
{
    private $i_position = 0;
    private $booksCollection;

    public function __construct(BookCollection $booksCollection)
    {
        $this->booksCollection = $booksCollection;
    }

    public function current()
    {
        return $this->booksCollection->getTitle($this->i_position);
    }

    public function key()
    {
        return $this->i_position;
    }

    public function next()
    {
        $this->i_position++;
    }

    public function rewind()
    {
        $this->i_position = 0;
    }

    public function valid()
    {
        return !is_null($this->booksCollection->getTitle($this->i_position));
    }
}
<?php

// BookCollection.php

namespace DesignPatterns;

class BookCollection implements \IteratorAggregate
{
    private $a_titles = array();

    public function getIterator()
    {
        return new BookIterator($this);
    }

    public function addTitle($string)
    {
        $this->a_titles[] = $string;
    }

    public function getTitle($key)
    {
        if (isset($this->a_titles[$key])) {
            return $this->a_titles[$key];
        }
        return null;
    }

    public function is_empty()
    {
        return empty($a_titles);
    }
}
<?php

// index.php

require 'vendor/autoload.php';
use DesignPatterns\BookCollection;

$booksCollection = new BookCollection();
$booksCollection->addTitle('Design Patterns');
$booksCollection->addTitle('PHP7 is the best');
$booksCollection->addTitle('Laravel Rules');
$booksCollection->addTitle('DHH Rules');

foreach($booksCollection as $book){
    var_dump($book);
}

OUTPUT

string(15) "Design Patterns"
string(16) "PHP7 is the best"
string(13) "Laravel Rules"
string(9) "DHH Rules"

JavaScript

JavaScript, as part of ECMAScript 6, supports the iterator pattern with any object that provides a next() method, which returns an object with two specific properties: done and value. Here's an example that shows a reverse array iterator:
function reverseArrayIterator(array) {
    var index = array.length - 1;    
    return {
       next: () => 
          index >= 0 ? 
           {value: array[index--], done: false} : 
           {done: true}       
    }
}

const it = reverseArrayIterator(['three', 'two', 'one']);
console.log(it.next().value);  //-> 'one'
console.log(it.next().value);  //-> 'two'
console.log(it.next().value);  //-> 'three'
console.log(`Are you done? ${it.next().done}`);  //-> true
Most of the time, though, what you want is to provide Iterator semantics on objects so that they can be iterated automatically via for...of loops. Some of JavaScript's built-in types such as ArrayMap, or Set already define their own iteration behavior. You can achieve the same effect by defining an object's meta@@iterator method, also referred to by Symbol.iterator. This creates an Iterable object.
Here's an example of a range function that generates a list of values starting from start to end, exclusive. Notice how I can use a regular for loop to generate these numbers:
function range(start, end) {
  return {
    [Symbol.iterator]() { //#A
      return this;
    },
    next() {
      if(start < end) {
        return { value: start++, done:false }; //#B
      }
      return { done: true, value:end }; //#B
    }
  }
}

for(number of range(1, 5)) {
   console.log(number);   //-> 1, 2, 3, 4
}
I can also manipulate the iteration mechanism of built-in types, like strings.
let iter = ['I', 't', 'e', 'r', 'a', 't', 'o', 'r'][Symbol.iterator]();
iter.next().value; //-> I
iter.next().value; //-> t

10 fastest-growing tech skills

It’s a great time to add new IT skills to your arsenal. To help you focus your attention in the right places, here are 10 in-demand tech skills that IT pros should master, according to research from Dice.com.
Fastest-growing tech skills
Technology is constantly evolving, and IT pros need to keep up with changing skills demands to remain relevant. A recent report from Dice.com tracked a year's worth of job postings on the site, from April 1, 2015 to April 1, 2016, to determine growth in demand for certain skills year-over-year. Skills must appear in at least 1,000 job postings in order to be considered statistically relevant.
Based on that data, here are the top 10 fastest-growing technology skills IT pros should consider adding to their repetoire, and examples of the types of roles available for professionals with those skills.
1. Spark
Following the success of its open-source framework, Hadoop, Apache developed this open-source processing engine aimed at helping companies process large data sets. With more companies building out their tech infrastructures, Spark professionals with strong coding and programming skills are top hiring priorities, says Bob Melk, president of Dice. In addition to competitive compensation packages, hiring managers on Dice are offering professional development and leadership opportunities to entice candidates with Spark expertise to join their team, Melk says.
Example career opportunities:
Data Engineer
Spark Architect
2. Azure
Microsoft Azure is a cloud computing platform designed to improve productivity for tech professionals. Azure is a crucial skill to have, as it can help streamline and simplify mobile app development or analytics, says Melk. Professionals with experience in Microsoft Azure and Amazon Web Services (AWS) are particularly marketable, with hiring managers on Dice often looking for candidates who possess both of those skillsets, he says.
Example career opportunities:
UI Developer
Senior Engineer, Cloud Infrastructure
3. Salesforce
Salesforce is far from new in the technology world, but it is new to Dice's fastest-growing skills list. Salesforce continues to be a dominant player, offering innovative customer service services for sales teams looking to drive leads and foster stronger client relationships. Interest in Salesforce professionals is widespread, with universities, management consulting firms and insurance companies all looking for professionals with this skillset on Dice, says Melk.
Example career opportunities:
Salesforce Administrator, Databases and Initiatives
Senior Salesforce.com Developer
4. Big Data
Big data is an all-encompassing term for any collection of data sets so large and complex that it becomes difficult to process them using traditional data processing applications. Companies today that are looking for a competitive edge to leverage big data to gain insight into customer behavior or patterns in users, making this a highly in-demand skill, says Melk.
Example career opportunities:
Big Data Developer
Big Data Architect
5. JIRA
JIRA is a bug, issue-tracking, and project management system developed by Atlassian and commonly used in software development. JIRA has garnered popularity in the tech world, with more and more hiring managers on Dice citing JIRA as a mandatory prerequisite rather than just a "nice-to-have" skill for a position in software development, Melk says.
Example job opportunities:
Portal Support Engineer
Developer, Software
6. Electrical Engineer
Though it's the only engineering position on the list, it's no surprise electrical engineers are in huge demand, says Melk. The role deals with the design, programming, application, manufacturing and operation of electronic or computer systems, and play a huge role in the design and development of Internet-of-Things (IoT) technology; though these professionals can work for a wide variety of employers from government contractors to large tech firms and startups, Melk says.
Example career opportunities:
ALCS Senior Electrical Engineer
Electrical Engineer
7. Cloud
As more companies adopt cloud technology as a solution for storage and data access, as well as cloud-based applications and technology providers, cloud skillsets are in high demand, Melk says. Cloud-based applications are popping up across a variety of industries and the technology is as ubiquitous today as mobile or big data. For that reason, companies are more than willing to open up their wallets for candidates with cloud expertise, Melk says.
Example career opportunities:
Cloud Support Engineer 
Cloud Specialist
8. Hive
Apache Hive is a data warehouse system that analyzes large Hadoop data sets. Hive's popularity is growing in tandem with other big data skills, like Spark and more general big data and data analytics skills, says Melk. While still new to the market, this big data tool is continuing to garner recognition, with companies like Apple and Amazon looking for professionals with a working knowledge of Hive.
Example career opportunities:
Senior software engineer - Big Data
Senior software engineer
9. Cassandra
Cassandra is another big data/Apache skill that's also used to help store, process and access large sets of data. Essential to a company's success, professionals with Cassandra experience are well-compensated. In fact, Dice's 2015-2016 annual salary survey found professionals with Cassandra experience to be the second-highest earners on the list, Melk says.
Example career opportunities:
Software Engineer Cloud
Sr. Administrator, Database Cassandra
10. Juniper
In today's market, most companies rely on specific networking products and services to drive their success, including vendors such as Juniper Networks, which provides provides companies with network-based identity and policy control products and firewalls. Melk says Dice often sees hiring managers in the market for candidates with vendor-specific network administration or security or support roles, especially around Juniper Networks technology.
Example career opportunities:
Senior Manager, Information Security Ops
Network Deployment Planning Engineer

Source : 
http://www.techgig.com/tech-news/

Sunday, 10 April 2016

Do you Know that while purchasing a Memory Card you must know its Class KICA NEWS to USE

The high capacity microSD, aka microSDHC, are those microSD cards with capacities in excess of 2 gigabytes that adhere to the SD Association's standard for high capacity cards. What does the Class Rating mean? What does that "C" with a 4, 6, 10 or 2 inside it signify? 
The class refers to the data transmission speed (DTS) of the card, its ability to accept and send information from the device in which it is installed. If you know how quickly a device can read and write to the card you can more closely match the card to it. There is no sense in putting a Class 6 card in a device that writes so slowly that a Class 2 card is sitting there twiddling its virtual thumbs waiting for bits.

As a rule of thumb the class of a card is the sustained data transfer speed (DTS) in Megabytes per second (MBS)
CLASS 2 = 2 Megabytes per Second
CLASS 4 = 4 Megabytes per Second
CLASS 6 = 6 Megabytes per Second
CLASS 10 = 10 Megabytes per Second


A good rule of thumb is to install the matching or next fastest class card in your device to get the maximum performance at the least cost.

If you have a device that is capable of fully utilising a CLASS 6 card and you saddle up a CLASS 2 you will impair its functionality. In a camera that will slow down how quickly you can take the next photo. In a device that is capable of transferring 1.5MBS if you install a CLASS 6 card you are wasting your hard earned money. Prices for a CLASS 2 and a CLASS 6 device can be as much as 100% premium for the CLASS 6 over the CLASS 2 for the same amount of storage.
Class ratings also apply to the full sized SD cards.