Showing posts with label Engineering. Show all posts
Showing posts with label Engineering. Show all posts

Sunday, January 13, 2019

How Drones Can Improve Deliveries - Alexa Marino

Drone, Rc, Blade 180 Qx Hd, Quadrocopter, Toys, Rotors
[image: https://pixabay.com/en/drone-rc-blade-180-qx-hd-674238/]


How Drones Can Improve Deliveries


Drones are becoming very popular very quickly. In the United States alone, the drone market grew from
$40 million in 2012 to greater than a billion dollars in 2017. This trend will likely continue as the devices
become more affordable.


Consumers are eager to adopt this technology. Thus, businesses should start considering how drones can
be used to offer superior customer experiences. If you’ve worked with an iPhone app development agency
or an Android agency to develop an on-demand app, you may benefit similarly from investing in drone
delivery services.


Improving delivery services is one potential application worth investigating. Major businesses such as
Walmart and Amazon have already begun to research how they may use drones in this capacity.
Smaller brands such as Pieology Pizzeria are also beginning to use drones to deliver food to customers.
Others may do the same sooner rather than later.


Pros of Drone Delivery


  • Reducing delivery times and fuel costs.
  • Making a good impression on customers with efficient, innovative service.
  • Small drones that use less energy will help businesses reduce their impact on the environment.
  • This helps businesses cultivate socially-conscious brands, which is important to young consumers.


Cons of Drone Delivery


  • The technical feasibility of drone delivery may prevent smaller businesses from experimenting with
  • the technology immediately.
  • Companies must ensure employees who operate drones thoroughly understand and adhere to all
  • applicable regulations.
  • Business owners who don’t fully understand the technical capabilities of various drone models may
  • overload them with heavy packages that reduce delivery efficiency and boost maintenance costs.
  • Delivery drivers may struggle to compete with drones.


How Drones Will Impact Delivery Methods


It’s obvious that drones will change the way businesses deliver goods in general. The following are some
of the more noteworthy shifts worth paying attention to:


  • Increased Focus on Security: The software drones rely on to operate must be secure. Developers
  • and business owners will prioritize this.
  • In-Store Experiences Emphasized: The novelty of drone delivery may have an impact on the
  • popularity of brick-and-mortar stores. They’ll have to develop unique customer experiences to
  • attract guests and compete.
  • Focus on Order Fulfillment: Drone delivery is so appealing because it’s efficient.
  • Thus, businesses will place increased pressure on order fulfillment warehouses to work fast and
  • keep up with customer demand.
  • Employees Prioritize Specialization: Increased automation resulting from the popularity of drone
  • delivery will result in employees focusing more on developing specialized skills.

Don’t make the mistake of dismissing drones as a passing fad. It’s clear consumers are interested in the
potential of this technology. Businesses that deliver goods to customers should start investigating how
they can apply it now. Doing so is key to standing out among the competition.


Monday, July 23, 2018

Next Decade @Technology Wonder! - Kapil Sharma

As we are reaching the year 2020 in the next one and a half year. What's the most anticipated technologies, we as humans are going to view, consume and explore in the upcoming decade.
Here are some pointers which may be the next game changer in the next decade.
  1. New layer of the financial system or financial stack.
  2. Mass rapid transport system.
  3. Customized health care medicine system.
  4. AR/VR/MX virtual reality systems.
  5. Machine or Humanoid assistants.
  6. Space explorations to the nearby planets.
  7. 5G/6G/7G+ Internet Communication System/ Protocols.
A. New layer of the financial system or financial stack: Digital currency with block-chain lager system in place to track immutable financial transactions/ records. Highly secure and lighting fast system on 5/6/7G+ internet communication systems. With zero error probability. Clean transactions within building tax systems. So, that no tax clues remain on the fly the taxes are compute with the use of cloud computed capacity and on time delivery of records. It's a big game changer for a nation or global audience, to consume this new financial stack or layer and drive huge profits without delays.
B. Mass rapid transport system: This is most sorted requirement of the human growing population throughout the world. Friction-less rail system (Levitation Rail System) or Hyperloop system. (@Elon Musk) Both the system works on the magnetic propulsion mechanism. First one work without vacuum and the last one required vacuum to run most faster than the first one, but the carrying capacity is less than the first one. Both systems require electric energy, so bye-bye diesel or coal. These system have the capacity to change the transport world as the travel time become less that mean more time do new/ other things.
C. Customized health care medicine system: Here comes the new breed of highly customized medical treatment for individuals. As per body and blood type, target based treatment is the new key. Rather than make a generic medicine for all, now custom molecular level disease targets medicine to cure diseases at faster and safer rate.
D. AR/VR/MX virtual reality systems: In multimedia domain, the wearable technology, may go to replace the TV, Theaters, Tablets, Gaming Consoles or maybe your most prized possession the "smart phone". I think these wearable's in the upcoming next decade may cost less than 250$ per piece and this leads to their sales in volumes and consumption rate from 40-60% per annual may increase. This is going to change the reading, viewing and consumption of the entertainment artifacts. Consumers may be these wearable's in learning and experience new things without moving from their current location to new ones. They can join live events a real time.
E. Machine or Humanoid assistants: As many developed countries the average human population age graph is in downwards. And this the place where the machine evolves and start working as a human assistant, or may replace human work force. This may lead to the presence of the humanoid/ robots in the security or hazardous environment landscape areas. Prefixed with experience data-set and integrated with real time data-set, machine in real time compute and consume information data-set and leads to the real time action based on machine actions protocols/ laws. They (robots) may become old age person help assistants or play many roles as per human needs and urgent requirements.
F. Space explorations to the nearby planets: Humans in the next decade may start exploring the nearby planets and stars for human habitations and for energy demands. Helium or other form of energy forms may lead to this sector growth in near future. Space X, Blue Origin, ISRO, NASA and Virgin Galactic are many leading space exploration companies leading this space race. Space tourism is the next big thing in the upcoming decade.
G. 5G/6G/7G+ Internet Communication System/ Protocols: As the next upcoming decade is coming up, so as the era of faster and secure communication also arises. More robust and faster with less cost and delay is the next most awaited communication technology sorted by the consumers throughout the globe. GB's plus data bits/byes transfer rate make or break company/ country success plan in most of active sectors. Easy to use, easy to build with less cost and inoperable entities are key success factors for new the information exchange domain.
These are some major technologies which may fuel the global business, research engine and social engine in the upcoming decade.
Till then keep learning, sharing and be open to embrace the new sizzling global change. :)


Monday, May 02, 2016

Writing Testable Code in JavaScript: A Brief Overview - Kapil Sharma

Whether we’re using Node paired with a test framework like Mocha or Jasmine, or spinning up DOM-dependent tests in a headless browser like PhantomJS, our options for unit testing JavaScript are better now than ever.
However, this doesn’t mean the code we’re testing is as easy on us as our tools are! Organizing and writing code that is easily testable takes some effort and planning, but there are a few patterns, inspired by functional programming concepts, that we can use to avoid getting into a tough spot when it comes time to test our code. In this article, we will go through some useful tips and patterns for writing testable code in JavaScript.

Keep Business Logic and Display Logic Separate

One of the primary jobs of a JavaScript-based browser application is listening to DOM events triggered by the end user, and then responding to them by running some business logic and displaying the results on the page. It’s tempting to write an anonymous function that does the bulk of the work right where you’re setting up your DOM event listeners. The problem this creates is that you now have to simulate DOM events to test your anonymous function. This can create overhead both in lines of code and the time it takes for tests to run.
Writing Testable Code in JavaScript: A Brief Overview
Instead, write a named function and pass it to the event handler. That way you can write tests for named functions directly and without jumping through hoops to trigger a fake DOM event.
This applies to more than the DOM though. Many APIs, both in the browser and in Node, are designed around firing and listening to events or waiting for other types of asynchronous work to complete. A rule of thumb is that if you are writing a lot of anonymous callback functions, your code may not be easy to test.
// hard to test
$('button').on('click', () => {
    $.getJSON('/path/to/data')
        .then(data => {
            $('#my-list').html('results: ' + data.join(', '));
        });
});

// testable; we can directly run fetchThings to see if it
// makes an AJAX request without having to trigger DOM
// events, and we can run showThings directly to see that it
// displays data in the DOM without doing an AJAX request
$('button').on('click', () => fetchThings(showThings));

function fetchThings(callback) {
    $.getJSON('/path/to/data').then(callback);
}

function showThings(data) {
    $('#my-list').html('results: ' + data.join(', '));
}

Use Callbacks or Promises with Asynchronous Code

In the code example above, our refactored fetchThings function runs an AJAX request, which does most of its work asynchronously. This means we can’t run the function and test that it did everything we expected, because we won’t know when it’s finished running.
The most common way to solve this problem is to pass a callback function as a parameter to the function that runs asynchronously. In your unit tests you can run your assertions in the callback you pass.
Another common and increasingly popular way to organize asynchronous code is with the Promise API. Fortunately, $.ajax and most other of jQuery’s asynchronous functions return a Promise object already, so a lot of common use cases are already covered.
// hard to test; we don't know how long the AJAX request will run
function fetchData() {
    $.ajax({ url: '/path/to/data' });
}

// testable; we can pass a callback and run assertions inside it
function fetchDataWithCallback(callback) {
    $.ajax({
        url: '/path/to/data',
        success: callback,
    });
}

// also testable; we can run assertions when the returned Promise resolves
function fetchDataWithPromise() {
    return $.ajax({ url: '/path/to/data' });
}

Avoid Side Effects

Write functions that take arguments and return a value based solely on those arguments, just like punching numbers into a math equation to get a result. If your function depends on some external state (the properties of a class instance or the contents of a file, for example), and you have to set up that state before testing your function, you have to do more setup in your tests. You’ll have to trust that any other code being run isn’t altering that same state.
In the same vein, avoid writing functions that alter external state (like writing to a file or saving values to a database) while it runs. This prevents side effects that could affect your ability to test other code with confidence. In general, it’s best to keep side effects as close to the edges of your code as possible, with as little “surface area” as possible. In case of classes and object instances, a class method’s side effects should be limited to the state of the class instance being tested.
// hard to test; we have to set up a globalListOfCars object and set up a
// DOM with a #list-of-models node to test this code
function processCarData() {
    const models = globalListOfCars.map(car => car.model);
    $('#list-of-models').html(models.join(', '));
}

// easy to test; we can pass an argument and test its return value, without
// setting any global values on the window or checking the DOM the result
function buildModelsString(cars) {
    const models = cars.map(car => car.model);
    return models.join(',');
}

Use Dependency Injection

One common pattern for reducing a function’s use of external state is dependency injection - passing all of a function’s external needs as function parameters.
// depends on an external state database connector instance; hard to test
function updateRow(rowId, data) {
    myGlobalDatabaseConnector.update(rowId, data);
}

// takes a database connector instance in as an argument; easy to test!
function updateRow(rowId, data, databaseConnector) {
    databaseConnector.update(rowId, data);
}
One of the main benefits of using dependency injection is that you can pass in mock objects from your unit tests that don’t cause real side effects (in this case, updating database rows) and you can just assert that your mock object was acted on in the expected way.
Give Each Function a Single Purpose
Break long functions that do several things into a collection of short, single-purpose functions. This makes it far easier to test that each function does its part correctly, rather than hoping that a large one is doing everything correctly before returning a value.
In functional programming, the act of stringing several single-purpose functions together is called composition. Underscore.js even has a function _.compose, that takes a list of functions and chains them together, taking the return value of each step and passing it to the next function in line.
// hard to test
function createGreeting(name, location, age) {
    let greeting;
    if (location === 'Mexico') {
        greeting = '!Hola';
    } else {
        greeting = 'Hello';
    }

    greeting += ' ' + name.toUpperCase() + '! ';

    greeting += 'You are ' + age + ' years old.';

    return greeting;
}

// easy to test
function getBeginning(location) {
    if (location === 'Mexico') {
        return '¡Hola';
    } else {
        return 'Hello';
    }
}

function getMiddle(name) {
    return ' ' + name.toUpperCase() + '! ';
}

function getEnd(age) {
    return 'You are ' + age + ' years old.';
}

function createGreeting(name, location, age) {
    return getBeginning(location) + getMiddle(name) + getEnd(age);
}

Don’t Mutate Parameters

In JavaScript, arrays and objects are passed by reference rather than value, and they are mutable. This means that when you pass an object or an array as a parameter into a function, both your code and the function you passed the object or array to have the ability to alter the same instance of that array or object in memory. This means that if you’re testing your own code, you have to trust that none of the functions your code calls are altering your objects. Every time you add a new place in your code that alters the same object, it gets increasingly hard to keep track of what that object should look like, making it harder to test.
Instead, if you have a function that takes an object or array have it act on that object or array as though it were read-only. Create a new object or array in code and add values to it based on your needs. Or, use Underscoreor Lodash to clone the passed object or array before operating on it. Even better, use a tool like Immutable.js that creates read-only data structures.
// alters objects passed to it
function upperCaseLocation(customerInfo) {
    customerInfo.location = customerInfo.location.toUpperCase();
    return customerInfo;
}

// sends a new object back instead
function upperCaseLocation(customerInfo) {
    return {
        name: customerInfo.name,
        location: customerInfo.location.toUpperCase(),
        age: customerInfo.age
    };
}

Write Your Tests Before Your Code

The process of writing unit tests before the code they’re testing is called test driven development (TDD). A lot of developers find TDD to be very helpful.
By writing your tests first, you are forced to think about the API you are exposing from the perspective of a developer consuming it. It also helps to ensure you’re only writing enough code to meet the contract being enforced by your tests, rather than over-engineering a solution that’s unnecessarily complex.
In practice, TDD is a discipline that can be difficult to commit to for all your code changes. But when it seems worth trying, it’s a great way to guarantee you are keeping all code testable.

Wrap Up

We all know there are a few pitfalls that are very easy to fall for when writing and testing complex JavaScript apps. But hopefully with these tips, and remembering to always keep our code as simple and functional as possible, we can keep our test coverage high and overall code complexity low!
This article was written by JOSHUA MOCK - FREELANCE SOFTWARE ENGINEER @ TOPTAL

Learn more about the best JavaScript resources here.

Wednesday, April 06, 2016

Getting Started with Elixir Programming Language - Kapil Sharma


If you have been reading blog posts, hacker news threads, your favorite developers tweets or listening to podcasts, at this point you’ve probably heard about the Elixir programming language. The language was created by José Valim, a well known developer in the open-source world. You may know him from the Ruby on Rails MVC framework or from the device and simple_form ruby gems him and his co-workers from the Plataformatec have been working on in the last few years.
According the José Valim, Elixir was born in 2011. He had the idea to build the new language due the lack of good tools to solve the concurrency problems in the ruby world. At that time, after spending time studying concurrency and distributed focused languages, he found two languages that he liked, Erlang and Clojure which run in the JVM. He liked everything he saw in the Erlang language (Erlang VM) and he hated the things he didn’t see, like polymorphism, metaprogramming and language extendability attributes which Clojure was good at. So, Elixir was born with that in mind, to have an alternative for Clojure and a dynamic language which runs in the Erlang Virtual Machine with good extendability support.
Getting Started with Elixir Programming Language
Elixir describes itself as a dynamic, functional language with immutable state and an actor based approach to concurrency designed for building scalable and maintainable applications with a simple, modern and tidy syntax. The language runs in the Erlang Virtual Machine, a battle proof, high-performance and distributed virtual machine known for its low latency and fault tolerance characteristics.
Before we see some code, it’s worth saying that Elixir has been accepted by the community which is growing. If you want to learn Elixir today you will easily find books, libraries, conferences, meetups, podcasts, blog posts, newsletters and all sorts of learning sources out there as well as it was accepted by the Erlang creators.
Let’s see some code!

Install Elixir:

Installing Elixir is super easy in all major platforms and is an one-liner in most of them.

Arch Linux

Elixir is available on Arch Linux through the official repositories:
pacman -S elixir

Ubuntu

Installing Elixir in Ubuntu is a bit tidious. But it is easy enough nonetheless.
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
apt-get update
apt-get install esl-erlang
apt-get install elixir

OS X

Install Elixir in OS X using Homebrew.
brew install elixir

Meet IEx

After the installation is completed, it’s time to open your shell. You will spend a lot of time in your shell if you want to develop in Elixir.
Elixir’s interactive shell or IEx is a REPL - (Read Evaluate Print Loop) where you can explore Elixir. You can input expressions there and they will be evaluated giving you immediate feedback. Keep in mind that your code is truly evaluated and not compiled, so make sure not to run profiling nor benchmarks in the shell.

The Break Command

There’s an important thing you need to know before you start the IEx RELP - how to exit it.
You’re probably used to hitting CTRL+C to close the programs running in the terminal. If you hit  CTRL+C in the IEx RELP, you will open up the Break Menu. Once in the break menu, you can hit CTRL+C again to quit the shell as well as pressing a.
I’m not going to dive into the break menu functions. But, let’s see a few IEx helpers!

Helpers

IEx provides a bunch of helpers, in order to list all of them type: h().
And this is what you should see:
Those are some of my favorites, I think they will be yours as well.
  • h as we just saw, this function will print the helper message.
  • h/1 which is the same function, but now it expects one argument.
For instance, whenever you want to see the documentation of the String strip/2 method you can easily do:
Probably the second most useful IEx helper you’re going to use while programming in Elixir is the c/2, which compiles a given elixir file (or a list) and expects as a second parameter a path to write the compiled files to.
Let’s say you are working in one of the http://exercism.io/ Elixir exersices, the Anagram exercise.
So you have implemented the Anagram module, which has the method match/2 in the anagram.exs file. As the good developer you are, you have written a few specs to make sure everything works as expected as well.
This is how your current directory looks:
Now, in order to run your tests against the Anagram module you need to run/compile the tests.
As you just saw, in order to compile a file, simply invoke the elixir executable passing as argument path to the file you want to compile.
Now let’s say you want to run the IEx REPL with the Anagram module accessible in the session context. There are two commonly used options. The first is you can require the file by using the options -r, something like iex -r anagram.exs. The second one, you can compile right from the IEx session.
Simple, just like that!
Ok, what about if you want to recompile a module? Should you exit the IEx, run it again and compile the file again? Nope! If you have a good memory, you will remember that when we listed all the helpers available in the IEx RELP, we saw something about a recompile command. Let’s see how it works.
Notice that this time, you passed as an argument the module itself and not the file path.
As we saw, IEx has a bunch of other useful helpers that will help you learn and understand better how an Elixir program works.

Basics of Elixir Types

Numbers

There are two types of numbers. Arbitrary sized integers and floating points numbers.

Integers

Integers can be written in the decimal base, hexadecimal, octal and binary.
As in Ruby, you can use underscore to separate groups of three digits when writing large numbers. For instance you could right a hundred million like this:
100_000_000
Octal:
0o444
Hexdecimal:
0xabc
Binary:
0b1011

Floats

Floare are IEEE 754 double precision. They have 16 digits of accuracy and a maximum exponent of around 10308.
Floats are written using a decimal point. There must be at least one digit before and after the point. You can also append a trailing exponent. For instance 1.0, 0.3141589e1, and 314159.0-e.

Atoms

Atoms are constants that represent names. They are immutable values. You write an atom with a leading colon : and a sequence of letters, digits, underscores, and at signs @. You can also write them with a leading colon : and an arbitrary sequence of characters enclosed by quotes.
Atoms are a very powerful tool, they are used to reference erlang functions as well as keys and Elixir methods.
Here are a few valid atoms.
:name, :first_name, :"last name",  :===, :is_it_@_question?

Booleans

Of course, booleans are true and false values. But the nice thing about them is at the end of the day, they’re just atoms.

Strings

By default, strings in Elixir are UTF-8 compliant. To use them you can have an arbitrary number of characters enclosed by " or '. You can also have interpolated expressions inside the string as well as escaped characters.
Be aware that single quoted strings are actually a list of binaries.

Anonymous Functions

As a functional language, Elixir has anonymous functions as a basic type. A simple way to write a function is fn (argument_list) -> body end. But a function can have multiple bodies with multiple argument lists, guard clauses, and so on.
Dave Thomas, in the Programming Elixir book, suggests we think of fn…end as being the quotes that surround a string literal, where instead of returning a string value we are returning a function.

Tuples

Tuple is an immutable indexed array. They are fast to return its size and slow to append new values due its immutable nature. When updating a tuple, you are actually creating a whole new copy of the tuple self.
Tuples are very often used as the return value of an array. While coding in Elixir you will very often see this, {:ok, something_else_here}.
Here’s how we write a tuple: {?a,?b,?c}.

Pattern Matching

I won’t be able to explain everything you need to know about Pattern Matching, however what you are about to read covers a lot of what you need to know to get started.
Elixir uses = as a match operator. To understand this, we kind of need to unlearn what we know about = in other traditional languages. In traditional languages the equals operator is for assignment. In Elixir, the equals operators is for pattern matching.
So, that’s the way it works values in the left hand side. If they are variables they are bound to the right hand side, if they are not variables elixir tries to match them with the right hand side.

Pin Operator

Elixir provides a way to always force pattern matching against the variable in the left hand side, the pin operator.

Lists

In Elixir, Lists look like arrays as we know it from other languages but they are not. Lists are linked structures which consist of a head and a tail.

Keyword Lists

Keyword Lists are a list of Tuple pairs.
You simply write them as lists. For instance: [{:one, 1}, 2, {:three, 3}]. There’s a shortcut for defining lists, here’s how it looks: [one: 1, three: 3].
In order to retrieve an item from a keyword list you can either use:
Keyword.get([{:one, 1}, 2, {:three, 3}], :one)
Or use the shortcut:
[{:one, 1}, 2, {:three, 3}][:one]
Because keyword lists are slow when retrieving a value, in it is an expensive operation, so if you are storing data that needs fast access you should use a Map.

Maps

Maps are an efficient collection of key/value pairs. The key can have any value you want as a key, but usually should be the same type. Different from keyword lists, Maps allow only one entry for a given key. They are efficient as they grow and they can be used in the Elixir pattern matching in general use maps when you need an associative array.
Here’s how you can write a Map:
%{ :one => 1, :two => 2, 3 => 3, "four" => 4, [] => %{}, {} => [k: :v]}

Conclusion

Elixir is awesome, easy to understand, has simple but powerful types and very useful tooling around it which will help you when beginning to learn. In this first part, we have covered the various data types Elixir programs are built on and the operators that power them. In later parts we will dive deeper into the world of Elixir - functional and concurrent programming.
This post originally appeared in the Toptal Engineering blog

Navigating Portfolio Management Services (PMS): Evaluation, Strategy, and Return Dynamics.

  What is Portfolio Management Services (PMS)? Portfolio Management Services (PMS) are customized, professional investment solutions designe...