Microservice architecture discussion

23 08 2014

Microservice architecture is a quite new concept which currently I am fond of. I am gaining more and more experience and practical knowledge about its strengts and weaknesses as well. Until the system is deployed, still new conclusions appear.

And new articles appear on the web. I would like to share an article that is a proof that not everyone sees microservices the same way. There are of course new challenges in such design, totally different than in plain old monolyth apps, and of course big advantages. Thiere is a trade off – What is better.

Here is an article, woth reading to know other’s opinion on topic: http://contino.co.uk/microservices-not-a-free-lunch/

 

Surely not everything should be done as microservice, not everything fits, but I am afraid that authors’ doubts make him think that monolythic is not that bad. I mean, Iagree with arguments that API design is a challenge, however good API is crucial for an app, for a class and for system! this makes system responsibilities well defined, clear and testable.

So mostly I agree with author that these are challenges, however in my opinion microservices requires a good, well defined design from developers. Implementing a good design is challenging and not easy. Good software development is not a free lunch, neither are microservices. So I do not agree that things described in article are something new for developers. We all follow good designds. Aren’t we…?





Clean Code: Dont use if’s! Use polymorphism instead

23 03 2013

Writing clean code is crucial, so the software developer constantly needs to improve his skills and code understanding.

My way to do it, is to explore others’ best practices. Here is one of them to consider:

I am not fully convinced that all the if‘s shall be refactored and removed, however the example given is much cleaner with polymorphism. Moreover it is testable and deprived of code smells and arguments of this guy seems to be reasonable.

You may also want visit the Anti if campaign page :) – Thanks Maciek!

Do you like my blog?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Android custom button layout tutorial

1 12 2012

The goal of this tutorial is to create customized button with your own background. The result will be something like that:

Normal button state

Button in normal state

Button pressed state

Button in pressed state

There are two ways of creating such background. The common one is to define it in XML file – this way I will describe here. The other, more elastic way is to define it at runtime in Java Code. And this is described in another tutorial.

1. Create background graphics files
First you need to create backround image for each button state (normal, pressed, focused etc.). For simplicity it is enough just to provide graphics for pressed and normal state. My files looks like that:

button_left_normal.png

button_left_normal.png

button_left_pressed.png

button_left_pressed.png

2. Create scalable 9patches from background files

9 patch is common format that allows button background to scale to fit desired size (width and height). You have to define which fragments should be resized while scaling (middle part of image) and which not (image corners), in order not to change background image shape.

Android SDK provides 9patch tool to create these. It is in your Andrid directory in \Android\android-sdk\tools\draw9patch.exe. Run it and draw line on the left and top edge, then save it to drawables directory (it will have extension like <file_name>.9.png. My files are as follows:

button_left_normal.9.png

button_left_normal.9.png

button_left_pressed.9.png

button_left_pressed.9.png

Some draw9patch.exe tutrials and instructions are available on the internet. I hope these three will be helpful: Android developers tutorial or YouTube tutorial.

3. Define xml selector
Selector is responsible for reacting on button press changes and showing proper backgrounds to the user. Here you define background files for each state (use 9patch images! These with *.9.png extension!), and put it in your /res/drawable folder. Example:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_pressed="true" android:drawable="@drawable/button_left_pressed"/>
    <item android:state_focused="true" android:drawable="@drawable/button_left_pressed"/>
    <item android:drawable="@drawable/button_left_normal"/>
</selector>

4. Create UI button and define its background
Now all you need to do is to define a button and set its background to selector file defined earlier. In my case this is button_bgnd_left.xml file:

<Button
    android:id="@+id/calc_addPerson_button"
    android:layout_width="@dimen/height_button_big"
    android:layout_height="fill_parent"
    android:background="@drawable/button_bgnd_left"
    android:drawableLeft="@drawable/add_person"
    android:text="@string/calculation_button_addPerson_text" />

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Custom Eclipse shortcuts: Import / Export

24 11 2012

As working with eclipse is far easier while using shortcuts, here is the way to define your own custom keys and export them. This enables using them in every eclipse instance you use.

 

Define custom shortcut

Define new eclipse shortcut

1. Under Window -> Preference -> General -> Keys is window to set up shortcuts.

2. Find desired command and press desired keys combination in Binding text field. For instance I use Ctrl+R shortcut to clean project (command: Build Clean).

 

Export shortcut preferences

Export eclipse shortcuts

1. Go to File -> Export -> General section -> Preferences.

2. In the next screen choose Preferences (and anything else, you want to export)

3. save it to .epf file.

 

Import shortcuts from file

Import eclipse shortcuts

1. Go to File -> Import -> General section -> Preferences,

2. Choose previously saved .epf file

3. mark Preferences checkbox (and anything else, you want to import). That’s it.

4. Sometimes eclipse restart is required for changes to take an effect.

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!








%d bloggers like this: