Friday, 16 September 2016

ACID properties

For a transaction ACID is very important. It stands for Atomicity, Consistency, Isolation and Durability of the Transaction.

Atomicity

A transaction can be either be waiting to executed or would have executed. There is no middle ground/executing for a transaction.

Consistency

When a transaction is finished, system will be in the consistent state.

Isolation

A transaction doesn’t know about other transactions or their side-effect.

Durability

Once a transaction has succeeded, it would be part of the system even if system fails.

Let’s take money transfer as the example. Suppose, you moved X from account A to account B. Here are the tasks in the transaction.

  1. Take money out of account A.
  2. Put money in account B.
  3. Make sure that account balance of A is now less than it was earlier by X.
  4. Make sure that account balance of B is now more than it was earlier by X.
  5. Business rule checks: balance validity etc.

If any of the steps fail, transaction will be rolled-back; ensuring atomicity, consistency.

Take this parallel transaction in to the account: Move Y money from account A to account B; in such a way that X + Y is more than what account A has.

  1. Take money out of account A.
  2. Put money in account B.
  3. Make sure that account balance of A is now less than it was earlier by Y.
  4. Make sure that account balance of B is now more than it was earlier by Y.
  5. Business rule checks: balance validity etc.

Now, one of the transaction (x, y) will fail because account A doesn’t have enough balance. If they executed at the same time, both the transactions will see, account balance Z in account A. If they end at the same time, both should succeed; which will violate business rules. But it can happen. To prevent from this issue, Isolation is required.

Isolation can mark the account A unreadable and unwritable until one transaction is finished.

If machine looses power while executing the transaction, it might leave the application in the inconsistent state. This can be prevented if transaction logs everything. Even if the system crashes, logs will let transaction system know what to rollback or how many transactions are done. This is Durability.


Thing to note: SOAP is ACID compliant; REST is not; and ACID over web/http doesn’t make sense.

Use REST where you can. If you really need, use SOAP.

Monday, 29 August 2016

Clash Of Clans update

There's nothing left to upgrade, so Town Hall is on upgrade and in 2 hours it'll be TH3.

Sunday, 28 August 2016

TownHall Mayor - idea for new troop

Town Hall Mayor

A so fat guy that you haven't seen in ages. Living in TH from L1.

It protects village.
Very slow moving.

As soon as the village destruction is 40%, it wakes up. Mayor attracts first six types of  troops i.e. from barbarian to balloon.

Powers

High Hit Points, say 3500+
Attracts attacking forces.
On upgrade, becomes leaner and increases speed.

Bad investment calls and how to avoid them via Clash of Clans

Well, we ran it into the ground.


At present I am stuck here.

Stuck!
1. By my own rules
2. Bad investment calls
3. Experience helped me with #2
4. Executing mindlessly

As I discussed that I am going to follow Builder queue to upgrade my base/village; I am stuck now.

Here are the reasons that I think got me here:

1. By my own rules


If you read my last post you will be able to read that I have created some rules for playing Clash of Clans as challenge to myself.

I have got those rules out in a post of their own: Challenging rules for playing Clash of Clans.

As per rules, I have to follow next thing in the queue. But, I don't have resources left.

2. Bad investment calls


I did some village cleaning with precious elixir and gold. That was a bad call. I lost elixir and now cannot make enough of it.

3. Experience sucks


I made that bad investment call because that's what I did on my TH6 and TH8 villages. As soon as a builder freed up and I had elixir (which I have tons of on those bases), I'd cleanup village.

4. Executing mindlessly


I didn't take note of the situation with whole heart (actually mind) and let my experience guide me. Made some bad calls and have rigid rules. Flexibility in personal, professional, religious, diplomacy, politics, gaming etc. rules is required.

Due to the findings, I am updating rule #1, I am going to change it to: I will pick one of the task from the builder's queue per builder.

How to avoid bad investment calls?

1. Flexibility


Give yourself and your team a little bit of flexibility. Rigidity hurts.

2. Know temporal impact of your calls today.


Had I just spent 30 seconds thinking about what will the impact of cleaning action be, I would have saved my self from this headache.

Always think if future you is going to be happy by this decision that you're making now.

3. Experience is overrated


If you have experience in something, all it means is that you have done something a particular way. It does not guarantee that you have learned something from it. It doesn't guarantee that you will be successful next time. It doesn't guarantee that you'll get better results next time. What it does guarantee however is that you'll think (to some degree) that it's the way to achieve success.

4. Execution should be mindful


While operating anything; heavy damage machinery or finances, be mindful of your actions.

Thanks.

Challenging rules for playing Clash of Clans

Rules to abide by


1. I will upgrade as per the Builder queue suggestion. Pick one of the five suggestions as per the condition demands.
2. I will not buy from shop until on-map items are upgraded fully.
3. I will not upgrade TH until on-map items are upgraded to max and until there are things in shops.
4. I will not attack needlessly. I will attack only when a builder is free or is about to be free.
5. I will try to sync my builders.

Update #1

1. I will upgrade as per the Builder queue suggestion. 

To

1. I will upgrade as per the Builder queue suggestion. Pick one of the five suggestions as per the condition demands.



My current clash of clans bases

Base #1 


This is my Level/TownHall 6 base. The thing I like about it is that when it was at TH 5, almost every thing was upgraded. Only two things were not maxed at L5.

I am going to upgrade this base as per new strategy: letting things come to me. Read about it here.

TH6 base

Base #2


This next base is at TH8. I am going to upgrade defenses first there.

TH8 base.

TownHall 8

Base #3


This last base that I have is at TownHall 2. CoC tutorial doesn't allow TH1. I would have stayed there a bit longer.

TH1 base

TH 1


TH2 base

TH 2

Self-Challenge


I am going to use TH2 base semi-exclusively from now on. The challenge I have taken is that:

1. I will upgrade as per the Builder queue suggestion.
2. I will not buy from shop until on-map items are upgraded fully.
3. I will not upgrade TH until on-map items are upgraded to max and until there are things in shops.
4. I will not attack needlessly. I will attack only when a builder is free or is about to be free.
5. I will try to sync my builders.

Saturday, 27 August 2016

A bug in SuperCell's Clash Of Clans

Update #2

Well, I did reinstall many times. Didn't work out. Out of curiosity, I went to App Info and deleted data. That did the trick. 

Here we go again.

Woo Hoo. TH 1

So it's not a bug on SuperCell game per se, but on the Android 6's data management. Does Android wait before deleting cached data for an app?

Update #1

Nope. Uninstall and install doesn't work for newer account.

I am going to continue with L8 and L6 Town Hall.


A bug in Clash of Clans client side software


So I thought I'll create another google account and link it with the CoC game. I told you about creating a new avatar and start from scratch to run an experiment. You can read about that here at Clash of clans taught me something about life today

As I said, I wanted to create a new account and start from scratch. I did. Then I uncovered a bug in CoC game.

I have two google accounts that I use to play CoC as two different village chiefs; one is at L8 and other at L6.

Here's how you can regenerate the bug

Bug reproducing steps


1. Have 1 google account connected to CoC.
2. Create a new google account.
3. Add new google account to android.
4. Open CoC.
5. Try to connect newer account.

You cannot play with the new account.

Bug


CoC runs an animation when a new player joins. That animation does not run. Google play account loads but village doesn't load.

What could be the cause?


When you are already connected to CoC via google play account, you are not able to run that animation.

What I need to do to solve the issue?


Tell developers about it.
Uninstall the game.
Install the game.
Play with newer account first.
Play as if this never happened.
Hope developers fix the issue for players to come.


TL;DR summary


Already google play connected CoC don't load villages for newer google accounts.

Uninstall and Install CoC to play with newer and older accounts.