Sundarrajk's Weblog

Archive for the ‘GIDS’ Category

Synchronized makes one cross the memory barrier. Synchronizes local memory with remote memory.
Java Concurrency by …
Use of Lock object for synchronization.
Software Transactional Memory makes everything immutable. Identity and state is separated. Identity is conditionally mutable ; enforces transaction before allowing mutation. Clojure supports STM.
Use of Clojure for simple Concurrency in Java.
Use LockingTransaction.runInTransaction.

Use Multiverse .

Advertisements

JNew Features
1. Project Jigsaw: Version numbers in jar files.
2. Project Lambda
3. JVM convergence JRockit and Hotspot
4. JavaFX 3.0
5. Javascript / Java interoperability Nashorn using invoke dynamic
6. Device Support
7. Annotations on types
8. API updates

What is Lambda expression?
Reusable functions. A function that can be passed around. A first class citizen like variables.

External and internal iterators.

Internal iterator forEach takes a lambda expression.

Have used defender methods which are optional methods defined in interfaces.

SAM Single Abstract Method.

In Collection.map map maps a collection to another collection but mapping through something in between.

Can use Lambda where runnable is expected.

The first major change was 5 with generics.
7 is bringing some changes but not all features have been released
1. Support for multiple languages.
2. Support for concurrence mainly fork and join
3. Garbage collection improvements. G1 new garbage collection mechanism. Pointer compression. -XX:-UseCompressedOops
4. Support for annotations.
5. Support for invokeDynamic. Improves the performance of dynamic Jvm languages. Not supported in Java 7 but would be supported in Java 8.
6. Automatic resource management AutoCloseable.
7. Simpler generics.
8. Formatting long numbers.
9. Catch multiple exceptions.
10. Switch on strings
11. Watcher service.

Some new features in Java 7

1. Makes writing javascript easier
2. Lot like ruby
3. Single and double quote like ruby<
4. Keyword “is” is === and so is ==
5. Indentation is important like python.
6. Provides “if” and “unless”
7. Supports Lambda expressions.
8. Splat helps managing arguments more elegantly
9. Can assign results to named list of variables using splat.
10. Can use range working with arrays. Helps with list comprehension.
11. JSON objects can be created without curly braces
12. Using @ for attributes like ruby
13. Provides extends keyword to hide prototype
14. Provides ability to loop through the attributes using key value syntax. Possible to get only own properties.

html 5 by mark pilgrim free book
Cookies is persistence? Limited to 4k
Local storage is key value database
Session  storage is limited to session
Local storage is persisted across sessions. Limited to 5mb
Web sql available in webkit browsers.

Mozilla promoting index db. Will have transactions and will have more space like websql.

Application  cache allows you to write disconnected applications on mobiles.

This uses a manifest file in the root giving details of what to cache. Does not work in internet explorer.

Need to check how this works with sub domains.

Read Html5rocks.com

Multicore CPUs is making people look at functional.
1. What is functional? No assignment. Controlled assignments.
2. What is wrong with mutability? Problem when shared.
3. If it is immutable no locks are required. Immutable variables in F#. F# is Hybrid functional because it allows you to declare variables as mutable. Pure function is one that does not have side effects. They are predictable.  they can be run in parallel. (referential independence)
4. Higher order functions. You can create functions and return functions.
Demo of how functional style reduces code using F# list.filter and list.map

How to use mock to simplify unit testing?

Not easy to test code dependent on other pieces like database.

Unit test only the smallest piece of code that does something useful should be unit tested.

Types of unit tests
1. Positive test
2. Negative test
3. Exception test
4. Performance test

Create multiple mocks instead of complex mock objects for different test cases.


Categories