Saturday, 16 July 2016

This week 10/2016

This weekend I got to know a little Groovy (v2.4). The most important for me was, how to start developing. I opened one tutorial and I did step by step every action. Finally to use Groovy in eclipse I had to add resource for my version (Mars) and install the Groovy tools. The resource provide the older version of Groovy, not supporting dynamic invoke. I didn't find out how is in IntelliJ case. Anyway it is possible to download jars manually or by extension in Maven and then you can start implementing in Groovy.
Using Eclipse version of Groovy I tested if it is possible to use Jdk8 lambda expression in Java method and then execute it in Groove. Test passed, code compiled and executed.
Now let's study Groovy syntax and it semantic.

Saturday, 2 July 2016

This week 9/2016

It pass a month since last post. I had a break because of my holidays and some other important things. Last week I was at Devoxx conference in Cracow. I'd like to write in a nutshell about some main topics.

1. What does Unsafe class and why there is some cry after it will miss?
Unsafe is a class in com.sun package. It was created for internal use of java classes but after some time it is used by common libraries. The Unsafe allow to manual managing memory usage, ex. creating table with greater index than allow int type. GC doesn't involve this part of memory.

2. Jdk8 - collections and lambda's expressions.
There was shown, how works lazy initialization and processing in collections. 
What gives us lambada expressions.

3. Next releases of Java. Architecture plans.
In Java 9 there is planned standardise an API. They plan to remove close 30 classes from com.sun package. The most problematic is Unsafe class. I mentioned about it role before.
Other main changes are:
- array index will be changed to long type,
- a generic class will save its type in bytecode. It will be possible overloading methods with generic collection.

4. Reactive programming - Rx.Java and Hysterix
Another time there was described Hysterix as a simple and excellent framework to maintenance microservices connections.

5. DDD and bounded domain context. One domain model is too huge and complicated to maintenance it. The best idea is to split it into subdomains connected with some context. Nobody shown a real code of that solution. I always asking me, how to do it with hibernate. Is it at all possible?

6. Angular JS 2
I didn't take a part in that sessions. Anyway sessions described how different is AngularJs 2 from AngularJs 1, pointed the way how to start. In a nutshell Angular 2 was totally changed. Now code is writing in typescript and than is compiled to javascript. As it could be noticed, it is totally other language.

7. Groovy - how to start and difference between syntax in Groovy and Java.
At first it is possible to change Java code file to groovy file and compile it. It will be working.  Groove is slower language, so is not recommended to use on production but it is very useful to create tests. It is possible to basic Java syntax and it will be working to. There is huge support for collections. Anyway last version of Groovy don't support lambda expressions from Java 8. But it is possible to code in Groovy and call Java classes and vice versa and then you can use lambda expressions in Java code. All details about language can be find on page http://groovy-lang.org/style-guide.html
One important notice. Sometimes the same code in Groovy could work otherwise than in Java.

8. JUnit 5 - futures


9. How to pass presentations. Good advice given by programmer for programmers.
Sławomir Sobótka was talking about causes of stage fright. He diagnosed that stage fright is caused by too high self-esteen and fright that it could be reduced.


10. Microservices







Saturday, 4 June 2016

This week 8/2016

This week I try to offload a queue of articles I'd like to read. I found some interesting blog about Gradle (v3.x) getting-started-with-gradle. Blog hides you from installig the tool to develop multi-module project. This time I just read multiple articles and I didn't do any examples, so my knowledge is shallow. Anyway I collect here main notices and differences between it and Maven.
In the nutshell the Gradle is much more powerful tool. It left traditional format of a configuration (XML) and took advantages of the closure syntax, so file look much more simple.

In Gradle it is possible to define own tasks and mark dependences - it's memorise me a Makefile. Gradle interprets Groovy language, ex:

from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

Other advantage is that it can generate test reports and you can separate reports for unit testing and integration testing.

A configuration file is smaller than pom file.


Sunday, 29 May 2016

This week 7/2016

This week I finished configure fragments in my simple application. As I mentioned that a filed marked as a number field is associated with a String type of model attribute. If you need to associate your field with other time it is required to create your own binder method.

A long time took me to find out how to make unusual binder method for spinner.  In my case, I needed to bind a view action to a model. I used standard spinner listener to update my model but it wasn't a final solution. The best was to create your own binding method with a special annotations contains used in XML parameters. It is possible to bind more than one parameter at once.

ex.

    @BindingAdapter({"bind:enumElements", "bind:selected"})
    public static <T> void spinnerEnumBinnder(Spinner view, Enum<?>[] enumClass, T selected) {
        if (view.getAdapter() == null) {
            loadEnums(view, enumClass);
        }
        .....
    }


And than it is needed to add in layout XML:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:bind="http://schemas.android.com/apk/res-auto">
    <data>
        <variable name="linkName" type="org.example.ModelObject" />
    </data>

    <LinearLayout android:orientation="vertical" tools:context="org.example.ParamFragment">
        <Spinner
            android:id="@+id/objectType"
            bind:selected="@{linkName.type}"
            bind:enumElements="@{linkName.deviceTypes}"
            android:layout_gravity="center_horizontal|top"
            android:spinnerMode="dropdown" />

    </LinearLayout>
</layout>

Sunday, 22 May 2016

This week 6/2016

Android - to be continued

In my project I used Fragments to could reuse fragments and to improve performance during switching between screens. Managing fragments it is important to care what is added to which object. Ex. I had problems with hiding and showing fragment because I added it to it self. 

Other area explored by me was testing Android application. 
- Unit tests - the same as for desktop/j2ee application tests
- UI test - there is a tool called uiautomatentest - I haven't used it yet. It can send to Android application events as touches, finger moves etc.

At the end I collected some best practices to develop in Android:
1) don't execute long process task in UI thread - since Android 3.x some IO tasks will throw an exception then they are used in the same thread as UI.
2) prefer to use a service than an asyncTask. During memory cleaning at first are killed asyncTask and only when there is too little memory services are killed.
3) give your application permission only it needs. Application will be safer.
4) store application and user data on phone, avoid save it on external memory.
Now, all hands to the pumps!

Saturday, 14 May 2016

This week 5/2016

Android - another meeting.

This is my another meeting with the Android development (this time with SDK v19). Last time I was coding for Android 2.3. It was 3-4 years ago.
At the beginning I checked what changed in architecture and developing Android applications. From my point of view there isn't any differences. The same as 3 years ago main activity extends Activity object. This time in my project I used fragments for fluent navigation and reuse some parts of code in a activity.

The Android promotes to use free of charge based on JetBrain product IntelliJ Idea - Android Studio IDE. Tool has good Gradle support.

I found one useful library to bind data between view and activity/model. It is possible to bind string object but also it is possible to create your own data converter and use it in layout xml. During creation of binding I founds some problems as:
1) from model I couldn't execute refreshing only one element of a data model
2) binding didn't worked until I used in xml following construction of calling variable @={pojoObjectAliasFromTagData.attribute} - on Android page is missing equal sign.

Wednesday, 4 May 2016

This week 4/2016

Last two weeks I explored Google looking for some libs to support IP camera in a linux environment. I found two or there libs  but any so good to describe some of them.
The main problem is, they don't support RTSP which is the most important for me. I'd like to allow my application two ways communication as it is possible in the Windows version of attached application. I found one native libs dedicated for Android but it doesn't work with my linux kernel.
Request of snapshot or fetch MJPG stream isn't enough for me.
Anyway I have other question. Is it possible to tunnel RTSP stream in https SSL connection?
Nowadays I know that best way to see a steam from my camera is to connect with it by VPN and use VLC to watch video.