Thursday, December 17, 2015

Configure Android Studio for UnitTesting with legacy structure

So you want to to use unit testing with Android Studio and you have an old code base that does not follow the standard folder structure of Android Studio.

- You need to create test/java folders in the module you want to test.
-- Tip: use external file explorer (e.g. Mac Finder) to do so outside Android.
- Add this to you module dependencies at build.gradle:
-- compile 'junit:junit:4.12'
-- Add Junit to the classPath
-- Start Testing!

Tuesday, December 8, 2015

Working with Legacy Code

As I am trying to find my way to a better quality well structured code, I am in my journey reading "Working Effectively with Legacy Code" by Michael Feathers.

I found the following strategy interesting:
"The general legacy management strategy is:
1. Identify change points
2. Find an inflection point
3. Cover the inflection point
 a. Break external dependencies
 b. Break internal dependencies
 c. Write tests
4. Make changes
5. Refactor the covered code."

Thursday, December 3, 2015

Dependencies Report in Android

So I learnt a nice feature through the Android Summit, How to generate dependencies report for certain module in your app:

-Gradle plugin -> your module -> help -> dependecies
- It will suffer saying no configurations
- Go to  Edit configurations -> tasks -> put your module you need to analyze e.g. ":app:dependencies"
- Build and run again, you would get sth like that:
+--- com.android.support:multidex:1.0.1
+--- project :volley
+--- com.squareup.picasso:picasso:2.5.2
+--- com.beaconinside:beaconinside-sdk-basic-1.2.2:
+--- com.android.support:support-v4:21.0.0 -> 23.0.1
|    \--- com.android.support:support-annotations:23.0.1
+--- com.android.support:appcompat-v7:21.0.0
|    \--- com.android.support:support-v4:21.0.0 -> 23.0.1 (*)
+--- com.google.android.gms:play-services-analytics:7.5.0
|    \--- com.google.android.gms:play-services-base:7.5.0
|         \--- com.android.support:support-v4:22.0.0 -> 23.0.1 (*)
+--- com.google.android.gms:play-services-gcm:7.5.0
|    \--- com.google.android.gms:play-services-base:7.5.0 (*)
+--- com.amazonaws:aws-android-sdk-core:2.+ -> 2.2.9
|    \--- com.google.code.gson:gson:2.2.4 -> 2.3.1
+--- com.amazonaws:aws-android-sdk-sns:2.+ -> 2.2.9
|    +--- com.amazonaws:aws-android-sdk-core:2.2.9 (*)
|    \--- com.amazonaws:aws-android-sdk-sqs:2.2.9
|         \--- com.amazonaws:aws-android-sdk-core:2.2.9 (*)
+--- com.readystatesoftware.systembartint:systembartint:1.0.3
+--- com.sensorberg.sdk:android-sdk-bootstrapper:2.0.0
|    \--- com.sensorberg.sdk:android-sdk:1.0.0 -> 1.0.4
|         +--- com.sensorberg.android:okvolley:1.1.4
|         |    +--- com.squareup.okhttp:okhttp-urlconnection:2.2.0
|         |    |    \--- com.squareup.okhttp:okhttp:2.2.0
|         |    |         \--- com.squareup.okio:okio:1.2.0
|         |    +--- com.google.code.gson:gson:2.3.1
|         |    +--- com.squareup.okhttp:okhttp:2.2.0 (*)
|         |    \--- com.sensorberg.android:volley:1.2.4
|         +--- io.realm:realm-android:0.79.1
|         +--- net.danlew:android.joda:2.7.2
|         |    \--- joda-time:joda-time:2.7
|         +--- com.sensorberg.android:networkstate:1.0.0
|         \--- com.sensorberg.android:volley:1.2.4
+--- com.sensorberg.sdk:android-sdk:1.0.4 (*)
+--- org.igniterealtime.smack:smack-bosh:4.1.5
|    +--- org.igniterealtime.smack:smack-core:4.1.5

Happy analyzing! :)

Sunday, November 22, 2015

Reactive Programming

- Why Rx:
abstracting away concerns about things like low-level threading, synchronization, thread-safety, concurrent data structures, and non-blocking I/O. Which makes your code more readable and bug-prone.


The key is stream... Everything is stream of events "Variables, User inputs, Data structures,...".
- A stream can be an input for another stream
- A stream can be filtered, combined or mapped to other values...
- A stream is immutable.
- Subscribe to a stream and get the value from onNext; finish at onCompleted; handle error at onError.
- A stream is called observable.


It is all about Feedback: Incremental Iterative Development

The following excerpt from "Growing object-oriented software guided by tests" is inspiring in how to Software Projects should work...

"The sooner we can get feedback about any aspect of the project, the better. Many teams in large organizations can release every few weeks. Some teams re- lease every few days, or even hours, which gives them an order of magnitude increase in opportunities to receive and respond to feedback from real users.
Incremental and Iterative Development
In a project organized as a set of nested feedback loops, development is incremental and iterative.
Incremental development builds a system feature by feature, instead of building all the layers and components and integrating them at the end. Each feature is implemented as an end-to-end “slice” through all the relevant parts of the system. The system is always integrated and ready for deployment.
Iterative development progressively refines the implementation of features in response to feedback until they are good enough."

Friday, October 9, 2015

Effective Permissions

I conducted a presentation about how to use Android Permissions effectively before and after M release at GDG Android Meetup: GDG Android Meetup

Here is the link for slides: here

The simple guide to contribute to open source


- Clone the repo you would like to contribute:
git clone https://github.com/aselims/frab.git

- Create a branch for the feature/issue you want to add/fix:
git checkout -b events_to_session

- Do your changes in the repo

- Commit & add
git commit -am "change event to session"

- Push your branch "with the changes"
git push origin events_to_session

- Go the github page and create a pull request and describe your change.

- Wait for merging :)

One Good Article: https://guides.github.com/activities/forking/

Tuesday, July 21, 2015

Retrieve a file that is mistakenly deleted with Git

Firstly, check the commits:

As-MacBook-Pro:Events aselims$ git log
commit dd2f0f7c2b3024ec29c2337be2f0a768a743a9a1
Author: aselims <selim.2k@gmail.com>
Date:   Tue Jul 14 20:22:15 2015 +0200

    time format.

commit 43032e348bf0015759836c4e5e035d66c62d05f1
Author: aselims <selim.2k@gmail.com>
Date:   Tue Jul 14 19:37:09 2015 +0200

    webFragment for support.
...

Then checkout the file you need from a specific revision
git checkout <revision> -- <path_to_file>

git checkout 43032e348bf0015759836c4e5e035d66c62d05f1 -- ./app/src/main/java/co/rahala/selim/events/util/WebFragment.java

The file is already now at its original place.

Tuesday, March 31, 2015

Resources to see!

A nice visualization of data: mix and match!
 https://keminglabs.com/ukuni/

Data Science at Harvard: 
 http://cm.dce.harvard.edu/2015/01/14328/publicationListing.shtml

Good for startups:
 https://developers.google.com/startups/

Thursday, January 22, 2015

Variety of possibilities

I quoted this from DeliAmsterdam.com. I modified it a bit. It really can describe our situation nowadays in many aspects of life:

"Having a lot of choices can be great, but it can also be confusing and you might end up not having found that one hidden gem. An Internet search could be a solution but the amount of information is overwhelming, and no one looks forward to a night of googling what one really needs. You need something customized to you and your personality!"


Wednesday, January 21, 2015

A Periodic Table of Visualization Methods

That is interesting!

If you are working with visualizations, this one will will get you on!
http://www.visual-literacy.org/periodic_table/periodic_table.html

Wednesday, January 7, 2015