Category Archives: Java

Kotlin can overcome Java issues?

This article looks at many categories of Java defects that Kotlin prevents in addition to null safety. Kotlin showed a surprising impact on productivity.

This article looks at many categories of Java defects that Kotlin prevents in addition to null safety. My first article (5 cool thing about Kotlin) provided a brief introduction to Kotlin and showed a surprising impact on productivity.

It’s important to realize the difference in value in fixing a defect in one class versus preventing an entire category of Java defects from occurring in any class.

What we see today:

Source: How Kotlin remove Java defects? 

Advertisements

Difference MVC v/s MVP v/s MVVM

Today, the MVC pattern is used by well-known frameworks such as Ruby on Rails, Apple iOS Development, ASP.NET MVC, etc. While MVP is mostly used for ASP.NET Web Forms applications and MVVM is used by WPF, Caliburn, Silverlight, nRoute, and more. Which development pattern are you currently using in your software projects? Let us know in the comments below.

Source: Comparison between MVC, MVP and MVVM in details

Nothing Type For Kotlin Programming

A colleague approached me a while ago and asked me a question about Kotlin. What was this “Nothing type”, and what was it used for? I did not really have a good answer for him at the time.

Since then, I’ve found my answer.

In mathematics, bottom (often denoted as _|_) represents the absolute minimum value something can hold.

Nothing type has no instances. You can use Nothing to represent “a value that never exists”: for example, if a function has the return type of Nothing, it means that it never returns (always throws an exception).

Previously shared Kotlin post:

  1. Top 12 Advanced Kotlin Tips For Pro Developers
  2. Kotlin Parcelize – Developer need to know
  3. Create Firefox Extension Using KotlinJS

When we’re talking about types, we can think of Nothing as being the absolute bottom (leaf) object of any type hierarchy.

What we can see in this diagram (figure 1) is that Nothing is the opposite of Any. While every object you will work with in Kotlin implicitly extends Any, so to does Nothing implicity extend any object that exists. This makes Nothing the ‘dual’ or opposite of Any.

So, why is this useful?

See full article >>

Which Android Dependency Injection is best?

This post is a summary of first impressions of a few android related frameworks that we (Tell Me How Blog) tried out during a competences session recently.

What is Android Dependency Injection?

Dagger

“Dagger constructs instances of your application classes and satisfies their dependencies. ”
Dagger is a dependency injection framework, unfortunately most of us did not manage to setupdagger or failed to get dagger running once setup. So I can not give a proper overview of dagger2.
Read more: http://google.github.io/dagger/

Butterknife

“Annotate fields with @InjectView and a view ID for Butter Knife to find and automatically cast the corresponding view in your layout.”
Butterkife is a view injection lib for android. As such it only handles injection of view components and does this using a InjectView annotation. So some boilerplate is removed and less code has to be written. Some of us found the result a bit harder to read and in some cases the reduction of code was not noticeably, but this is most likely true for the other injection frameworks to and not something specific for Butterknife. Setup was easy with just one dependency. Stack-traces was reportedly difficult to read when Butterknife was used.
Read more: http://jakewharton.github.io/butterknife/

RoboGuice 3

“RoboGuice 3 takes the guesswork out of development. Inject your View, Resource, System Service, or any other object, and let RoboGuice 3 take care of the details.”
RoboGuice 3 is similar to AndroidAnnotations and Butterknife, easy to setup, two dependency’s needs to be added to the build file. This framework seems like it should be easy to use if you are already familiar with Guice, and even if you don’t its not that hard to understand and use. It is similar to the other dependency injection frameworks that you don’t get all that much for your money, but it’s easy to use and removes some boilerplate. The documentation could use a touch-up.
Read more: https://github.com/roboguice/roboguice

Final Verdict:

The views on the frameworks above is the result of a 3 hour session where we tried them out and had a short discussion about each of them to sum up the experiences. Given the limited time we spent on each of the frameworks we might have missed some important things, if you find and mistakes or are missing some important information please post a comment below.

Read more >> Comparison of All Android Dependency Injection 

How to implement Android Prevent Screen Off?

Android prevent screen off is the library that keeps the screen on until user is looking at the screen. If you are using Samsung devices you might know there is one feature called “Smart Stay”.

When this feature is enabled, the device will prevent your screen from turning off regardless of your screen timeout settings. But, this technology is only available on some Samsung devices. What if we want to use that technology in our application to solve above problem?

Today, I am going to present the solution of this problem.

Here is the solution:

Prevent-Screen-Off” library handles screen on/off timing smartly. It prevents device display from turning off when the user is looking at the screen and he/she might be reading some textual content provided by your application. As soon as the user stop looking at the screen it will allow phone screen to turn off.

What is Android prevent screen off library for?

  • Ideally, when you user is looking at the screen, your application should not turn the screen off. This is huge deal for the blogging, messaging applications because those applications displays textual content to the user. Reading those textual content takes more time to the user. While reading that content (let say anu article) if the screen turns off, because of the screen timeout that is frustrating to the user.
  • This library provides smart handling of the screen on-off. This library prevents screen from turning off if your user is looking at the screen might reading some textual content on the screen. As soon as the user stop looking at the screen it will allow phone screen to turn off.

Source: What and How implement Android Prevent Screen Off?

Will Android support Java 9?

With work moving forward on the next edition of standard Java, developers can start looking forward to what they will get with the planned upgrade.

Will Android support Java 9 after Kotlin updates?

Jigsaw isn’t the only new addition slated for Java 9. Support for the popular JSON (JavaScript Object Notation) data interchange format is key feature as well, along with process API, code cache, and locking improvements. “The key message is that there’s a tremendous investment in the continuing evolution of Java,” says Scott Sellers, CEO at Azul Systems, which offers JVM technology.

See this : How to Create Your Own Ransomware Virus

Here is a rundown of what’s in store with JDK 9.

Modular source code

JDK source code will get reorganized into modules, the build system will get enhanced to compile modules, and module boundaries will be enforced at build time. “Project Jigsaw aims to design and implement a standard module system for the Java SE Platform and to apply that system to the platform itself and to the JDK. Its primary goals are to make implementations of the platform more easily scalable down to small devices, improve the security and maintainability, enable improved application performance, and provide developers with better tools for programming,” the JEP document says.

Lightweight JSON API

This is an API for consuming and generating documents and data streams via the JavaScript Object Notation data interchange format, which is based on a subset of JavaScript and serves as an alternative to XML. “JSON has become the lingua franca for Web services, and it is time for Java SE to adopt functionality for interacting with and utilizing JSON documents and data streams,” the corresponding JEP document says. “This proposal is designed [to] provide the most commonly needed functionality and take advantage of Java 8/9 language and library features.”

You must know ; Create Android Studio Live Templates for Writing Less Code

Process API updates

This will improve the API for managing operating system processes and is intended to overcome limitations of the current API that often forces developers to use native code. Java SE 7, the JEP notes, offers limited support for native operating system processes; the new API, though, needs to account for operating system differences, particularly on Windows. “The design of this API needs to accommodate possible deployment on smaller devices with different operating system models. It should also take into account environments where multiple Java virtual machines are running in the same operating system process,” the JEP document states.

Improve contended locking

The goal is to improve contended Java object monitors. The documentation says that “improving contended locking will significantly benefit real-world applications in addition to industry benchmarks such as Volano and DaCapo.”

Do you know : Comparison of All Android Image Loading Library

Segmented code cache

This effort is intended to divide code cache into segments, each containing compiled code of a particular type, to improve performance and allow extensions.

Smart Java Compilation, Phase 2

This project is intended to improve the sjavac (Java programming language compiler) tool enabling it to be used by default in the JDK build and also to generalize it so it can be used to build large projects other than the JDK. “The current implementation has proved to be useful and does indeed improve build speed and allow for incremental builds. The quality of the code and stability of the tool as a whole, however, is not satisfactory and it is certainly not ready for public release,” the JEP document states.

Source: Will Android support Java 9 after Kotlin updates?

Build your own Malware apps for Ransomware

Hi guys, I recently wrote an article for my blog about a new service that lets you create your own ransomware. Due to Cybrary policies, this article was rejected from Cybrary OP3N, but I still think it would be interesting to some people, so I will write about it here.

A new type of ransomware is being freely distributed on the Deep Web, but this is not normal ransomware. This RaaS (ransomware as a service) is a new form of cybercrime that works by malware authors distributing the ransomware builder, and then taking a cut of the ransoms it generates. Anyone, no matter how computer savvy they are, can launch a fully-functional ransomware campaign to unsuspecting victims.

Atom Ransomware, formerly called Shark, first started popping up on the Internet in mid July 2016. You can download it through their professional looking website that gives you step by step instructions on how to set it up and start infecting people. The creators claim that it is undetectable by AV software, supports multiple languages, and uses a strong but fast encryption algorithm.

After you download the Atom payload builder, you can specify the bitcoin address to send the ransom to, the directories to infect, the file formats you wish to lock, the price of the ransom, and varying prices for different countries. All of this you can do with no technical knowledge. If you can type on a computer, you can use Atom to create ransomware. The payments are supposedly automated; sending the money first to the malware developers who take a 20% cut, then they send the other 80% to your bitcoin address that you supplied. After it encrypts the files with a .locked extension, it creates an encryption key like every other ransomware. After that, it locks the screen prompting for a password to unlock the files.

Could this be the start of a new cybercrime service? Could this be the future of ransomware? It’s hard to say what the future will look like in this ever-changing industry, but it very well may play a big part in the future of cybercrime. With open source ransomware such as HiddenTear, and the DIY ransomware builders already out there like Tox, ransomware is becoming easier and easier to make. And with all the work it takes to launch a ransomware campaign, why distribute your ransomware yourself? Atom has a great business model so far. Easily make the ransomware, have other people distribute it, and take 20% of the profits. 20% might not sound like a lot, but say someone customizes Atom to sell for $100 to unlock the files. If that person infects one other person, that’s still $20; and it will only continue to grow as more and more people create new Atom ‘strains.’ This is highly illegal and extremely unethical, but you have to admit, it’s a great idea, and will surely be a huge money maker for them.

The one problem that may arise is that there’s no way for Atom users to guarantee that they will get the 80%. Could this just be a huge scam to get people to spread Atom? Could the developers just take the whole ransom and walk away? Let me know what you think in the comments below!

In the future I hope to be analyzing Atom more in depth, as it seems like a very cool project, and I’d love to know more about how it works internally.