smali

четверг, 25 сентября 2014 г.

java memory model

[video]

explain java memory model heap stack method area frames java interview
https://www.youtube.com/watch?v=YYfLDBKcfy8

From Java Code to Java Heap: Understanding the Memory Usage of Your Application
https://www.youtube.com/watch?v=FLcXf9pO27w

The JVM and Java Garbage Collection - OLL Live (Recorded Webcast Event)
https://www.youtube.com/watch?v=DoJr5QQYsl8

Understanding Java Garbage Collection and what you can do about it
https://www.youtube.com/watch?v=we_enrM7TSY

java concurrency

[video]

Multithreading in Java Part 1 | Introduction to Threads in Java | Java tutorial by Java9s
https://www.youtube.com/watch?v=O_Ojfq-OIpM

Multithreading in Java Part 2 | Thread States | Java Tutorials by Java9s
https://www.youtube.com/watch?v=wqkVCkeObsE

Thread Safety and code synchronization in java | Multithreading in Java part 3
https://www.youtube.com/watch?v=IYBrtzOvfqo

Multithreading Interview Question In Java
https://www.youtube.com/watch?v=Iea3p2HFqNo

java interview questions

[video]

Core Java Interview Questions And Answers
https://www.youtube.com/watch?v=mb9AzAIDK54&list=PLHyEAfc_mrxbifpPk6m94v_ii1a84phgh

Exception Handling in Java - Checked and Unchecked Exceptions
https://www.youtube.com/watch?v=4my7mKFaNQs

hash code

[video]

HashCode and its purpose
https://www.youtube.com/watch?v=HFoQEyxKDhQ

equals() and hashCode() in Java with an Example
https://www.youtube.com/watch?v=fAlRR2p9Le0

hashcode equals method java interview question and answer
https://www.youtube.com/watch?v=nkvdRrliOFc

Difference between == and equals method in JAVA
https://www.youtube.com/watch?v=WTOiuY7cNTo

java clone

[video]

Java jdk 7 tutorial 19 clone method
https://www.youtube.com/watch?v=_k08JRFwgBs

Object Clone: Deep vs. Shallow Copy
https://www.youtube.com/watch?v=7NXyF4NIuQw

Java Clone - Advanced topic
https://www.youtube.com/watch?v=i7_OKhrKoZ4

Object Class Hash Code and Clone on 05 09 2012
https://www.youtube.com/watch?v=SHBh7nAd6Nw

среда, 24 сентября 2014 г.

java serialization

[video main]

How java serialization works internally, Object Serialization algorithm
https://www.youtube.com/watch?v=nJrbbmySI70

Learn Java Tutorial for Beginners, Part 46: Serialization
https://www.youtube.com/watch?v=Sm9yoju1me0

Сериализация в Java - Serialization #1 - Advanced Java
https://www.youtube.com/watch?v=PcwXTCWRGvY

Сериализация в XML - Serialization #2 - Advanced Java
https://www.youtube.com/watch?v=cy9Bxkhpb0o

Сериализация в JSON - Serialization #3 - Advanced Java
https://www.youtube.com/watch?v=z2o5Wi355Cc

Программирование на Java для начинающих #18(Serialization)
https://www.youtube.com/watch?v=snw4Paafosg

[video additional]

Serialization and performance (Sergey Morenets, Ukraine)
https://www.youtube.com/watch?v=S7sv4ERK2uo

[articles main]

Сериализация в Java [ru]
http://habrahabr.ru/post/60317/

Java Object Serialization Specification
http://docs.oracle.com/javase/7/docs/platform/serialization/spec/serialTOC.html

Top 10 Java Serialization Interview Questions and Answers
http://javarevisited.blogspot.com/2011/04/top-10-java-serialization-interview.html

Java object serialization - Tutorial
http://www.vogella.com/tutorials/JavaSerialization/article.html

The Java serialization algorithm revealed
http://www.javaworld.com/article/2072752/the-java-serialization-algorithm-revealed.html

[articles additional]

5 things you didn't know about ... Java Object Serialization
http://www.ibm.com/developerworks/library/j-5things1/

How to Serialize an Object in Java
7 steps
http://www.wikihow.com/Serialize-an-Object-in-Java

Изучите секреты Java Serialization API [ru]
http://www.ccfit.nsu.ru/~deviv/courses/oop/java_ser_rus.html

Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent storage or streamed across a communication link. The byte stream can then be deserialised - converted into a replica of the original object.

пятница, 19 сентября 2014 г.

When to use Singleton pattern?

Patterns I Hate #1: Singleton
http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/

Singleton Pattern
http://www.oodesign.com/singleton-pattern.html

Use your singletons wisely
http://www.ibm.com/developerworks/library/co-single/

Difference between Singleton Pattern vs Static Class in Java
http://javarevisited.blogspot.com/2013/03/difference-between-singleton-pattern-vs-static-class-java.html

10 Singleton Pattern Interview questions in Java - Answered
http://javarevisited.blogspot.com/2011/03/10-interview-questions-on-singleton.html

Why Enum Singleton are better in Java
http://javarevisited.blogspot.com/2012/07/why-enum-singleton-are-better-in-java.html

Singleton Pattern – Positive and Negative Aspects
http://www.codeproject.com/Articles/307233/Singleton-Pattern-Positive-and-Negative-Aspects

This entry inaugurates a new series on patterns that I hate. Hate is a strong word, perhaps a better name would be “patterns that I’ve frequently seen lead to ruin”. But that seemed too long.
Anyhow, the singleton pattern is the hands-down #1 pattern that can lead me to froth at the mouth. When a programmer first stumbles on GoF, Singleton seems to be the pattern that they first latch on to because it’s so easy to understand (just one class). Novice programmers doing their first design will often break out subsystems and access them via singletons.
Why is Singleton evil?

When to use Object pool pattern?

Various pools - Thread pools, connection pools, EJB object pools - Flyweight is really about management of shared resources

java.util.concurrent.ExecutorService

You need to frequently create and destroy objects.

Objects are similar in size.

Allocating objects on the heap is slow or could lead to memory fragmentation.

Each object encapsulates a resource such as a database or network connection that is expensive to acquire and could be reused.

Basically, we'll use an object pool whenever there are several clients who needs the same stateless resource which is expensive to create.

When there are several clients who need the same resource at different times.

It is deprecated as a general technique, because - as you noticed - creation and destruction of short lived objects per se (i.e. memory allocation and GC) is extremely cheap in modern JVMs. So using a hand-written object pool for your run-of-the-mill objects is most likely slower, more complicated and more error-prone than plain new.*

It still has its uses though, for special objects whose creation is relatively costly, like DB / network connections, threads etc.

Examples of GoF Design Patterns in jdk

Pattern Proxy (Surrogate)

http://en.wikipedia.org/wiki/Proxy_pattern

Proxy Design Pattern Tutorial (video)
https://www.youtube.com/watch?v=cHg5bWW4nUI

Proxy Design Pattern Tutorial
http://www.newthinktank.com/2012/10/proxy-design-pattern-tutorial/

The proxy design pattern allows you to provide an interface to other objects by creating a wrapper class as the proxy. The wrapper class, which is the proxy, can add additional functionality to the object of interest without changing the object's code. Below are some of the common examples in which the proxy pattern is used,

Adding security access to an existing object. The proxy will determine if the client can access the object of interest.
Simplifying the API of complex objects. The proxy can provide a simple API so that the client code does not have to deal with the complexity of the object of interest.
Providing interface for remote resources, such as web service or REST resources.
Coordinating expensive operations on remote resources by asking the remote resources to start the operation as soon as possible before accessing the resources.
Adding a thread-safe feature to an existing class without changing the existing class's code.
In short, the proxy is the object that is being called by the client to access the real object behind the scene.

When to use proxy pattern?

Remote Proxy – Represents an object locally which belongs to a different address space. Think of an ATM implementation, it will hold proxy objects for bank information that exists in the remote server.
( RMI, CORBA and Jini)

Virtual Proxy (Lazy Load Proxy) – In place of a complex or heavy object, use a skeleton representation. When an underlying image is huge in size, just represent it using a virtual proxy object and on demand load the real object. You feel that the real object is expensive in terms of instantiation and so without the real need we are not going to use the real object. Until the need arises we will use the virtual proxy.

Protection Proxy – Are you working on a MNC? If so, we might be well aware of the proxy server that provides us internet by restricting access to some sort of websites like public e-mail, social networking, data storage etc. The management feels that, it is better to block some content and provide only work related web pages. Proxy server does that job. This is a type of proxy design pattern.

A smart reference - a replacement for a bare pointer that performs additional actions when an object is accessed.
Provides additional actions whenever a target
object is referenced such as counting the number of references to the object

Adding a thread-safe feature to an existing class without changing the existing class's code.

Cache Proxy - Provides temporary storage of the results of expensive target
operations so that multiple clients can share the results

Firewall Proxy - Protects targets from bad clients (or vice versa)

java.lang.reflect.Proxy
http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.html
java.rmi.*, the whole API actually.

Java Remote Method Invocation (RMI)

In java RMI an object on one machine (executing in one JVM) called a client can invoke methods on an object in another machine (another JVM) the second object is called a remote object. The proxy (also called a stub) resides on the client machine and the client invokes the proxy in as if it is invoking the object itself (remember that the proxy implements the same interface that RealSubject implements). The proxy itself will handle communication to the remote object, invoke the method on that remote object, and would return the result if any to the client. The proxy in this case is a Remote proxy.

Adapter vs Proxy Design Pattern

Adapter design pattern provides a different interface from the real object and enables the client to use it to interact with the real object. But, proxy design pattern provides the same interface as in the real object.

Decorator vs Proxy Design Patter

Decorator design pattern adds behaviour at runtime to the real object. But, Proxy does not change the behaviour instead it controls the behaviour.

среда, 17 сентября 2014 г.

How to make code review?

The Helpful Tips

- Limit your review to the scope of the work. An effective review is laser-focused on the problem that is being worked on. Create follow-up action items (e.g., tickets) for any out-of-scope work that you think needs additional consideration.
- Make your review specific. Address specific lines, or components in your review. Avoid making general, sweeping statements.
- Make your review actionable. If it’s not immediately obvious how to implement the change you’ve requested, leave it out of your review.-
- Deliver your review in a timely manner. The longer you wait to give your review, the more the creator will have to draw from their memory on why certain decisions may have been made. I’ve started scheduling review times with one of my co-workers so that we can go through the work together. This isn’t always possible, or desirable, but it can be effective for small teams.
- As part of your review, be sure to acknowledge the time spent by the coder on the issue. Sometimes a three line change can take hours and hours of work. Take the time to be a human being and acknowledge the time that’s been spent on the issue.
- Be thankful. Especially on open source projects where contributors are generally not *required* to submit anything. And especially at work where co-workers are sometimes forced to work on parts of the project they genuinely hate. Take the time to say “thanks”. It can make all the difference.

Six Ways to Make Your Peer Code Reviews More Effective
http://radar.oreilly.com/2013/07/six-ways-to-make-your-peer-code-reviews-more-effective.html

Types

- Over-the-shoulder – One developer looks over the author's shoulder as the latter walks through the code.
- Email pass-around – Source code management system emails code to reviewers automatically after checkin is made.
- Pair Programming – Two authors develop code together at the same workstation, such is common in Extreme Programming.
- Tool-assisted code review – Authors and reviewers use software tools, informal ones such as pastebins and IRC, or specialized tools designed for peer code review.

Four ways to a Practical Code Review
http://www.methodsandtools.com/archive/archive.php?id=66

For your convenience, here are the 11 practices in a simple list that's easy to keep on file:
- Review fewer than 200–400 lines of code at a time.
- Aim for an inspection rate of fewer than 300–500 LOC per hour.
- Take enough time for a proper, slow review, but not more than 60–90 minutes.
- Be sure that authors annotate source code before the review begins.
- Establish quantifiable goals for code review and capture metrics so you can improve your processes.
- Use checklists, because they substantially improve results for both authors and reviewers.
- Verify that the defects are actually fixed.
- Foster a good code review culture in which finding defects is viewed positively.
- Beware of the Big Brother effect.
- Review at least part of the code, even if you can't do all of it, to benefit from The Ego Effect.
- Adopt lightweight, tool-assisted code reviews.

11 proven practices for more effective, efficient peer code review
http://www.ibm.com/developerworks/rational/library/11-proven-practices-for-peer-review/

Effective Code Reviews Without the Pain
http://www.developer.com/tech/article.php/3579756/Effective-Code-Reviews-Without-the-Pain.htm

What Makes a Good Code Review?
http://humblecoder.co.uk/blog/2010/10/13/what-makes-a-good-code-review/

10 ways to be a faster code reviewer
http://blog.codacy.com/top-10-faster-code-reviews/

Three tools that make Java code review painless and effective
http://www.techrepublic.com/article/three-tools-that-make-java-code-review-painless-and-effective/

How We Code Review
http://inside.unbounce.com/team/code-review-2

вторник, 16 сентября 2014 г.

среда, 10 сентября 2014 г.

Cloneable Interface in Java

1) Resources

Cloneable Interface in Java

Java Cloning Tutorial, Shallow Copy and Deep Copy
http://www.javaexperience.com/java-cloning-tutorial/

A guide to object cloning in java

How to implement Cloneable Interface

Implementing Cloneable interface

clone() and the Cloneable Interface in Java

How to implement cloning in java using Cloneable interface?

About Java cloneable

What is the use of cloneable interface in java?

Implementing the Cloneable Interface

How clone method works in Java