Sunday, March 17, 2019

A rant against annotations

This is an old issue, ever since annotations came up. I usually dislike most use of annotations, except for those that belong to the source code, like assert or deprecated. The reason is that they break reusability by pulling into a class info about how the class is to be used by other classes, and many times, tying a class to a framework.

E.g. using spring/hibernate annotations in a class tie that class to that framework. What if i later want to change from hibernate to something else ? I will have to change the source code.

Consider the following case of a service class CustomerService using a customerDao. The dao uses something @Component(name='customerDao'),
and its injected into the service as @Resource(name='customerDao')
Lets say that this Dao uses hibernate. Later on, we decide to change the dao to use JdbcTemplate instead of hibernate. But i want to keep the hibernate implementation as well. And maybe, i need to use both of them in different places. So i now have a new customerDaoSpTpl say. But the service code now needs to be changed in order to use this new customerDaoSpTpl. So did we really achieve DI, if we needed to change the service class using the dao ?

The problem is due to annotations. We are putting stuff in a class, that does not really belong in a class definition, but is about the wiring or interaction of classes.
There are also issues when old classes from a jar are to be replaced with new ones, the annotation processor can fire annotations for both. ( There probably is some exclude facility for the annotation processor ) The names used in annotated classes from a jar can't be changed either.

Ideally the wiring should be kept separate from the class definition.
Spring does support this, thru xml as well as a java annotations format, but everyone seems to be putting annotations into source code, because thats easier to use upfront.

One disadvantage of having a single separate source for wiring maybe that it has frequent changes and always needs merging when checking in.

Saturday, March 9, 2019

Distributing the database

You want to design you application to scale, so need to choose a database solution that will scale.
And it would be nice to have the querying and integrity features of an RDBMS.

Assuming that we want to shard data, and not just have a replica,
Some questions arise :
  •  How easy would it be to add a new node ?Should sharding be automatic, or per some partitioning rules ? If as per rules, what happens when we add/remove nodes, the data will need to be redistributed.
  • If a table is distributed across nodes, what happens to primary key ids ? How to prevent duplicates across nodes ? Id ranges ?
  • One major use of ids as primary keys is for use in foreign key constraints. But will a distributed table support foreign keys ? Probably not.
  • Will ACID transactions be available ?

Found some open-source solutions to scale RDBMS :
  • CockroachDB (https://www.cockroachlabs.com/) : A key-value store that supports the wire-protocol of Postgresql, sql, ACID transactions etc. So it behaves as if its a distributed postgresql to the sql drivers, but internally is not.
  • Citus : https://www.citusdata.com : A Postgresql extension that allows us to scale Postgresql. The underlying db is indeed postgresql. However, not all postgresql features can be supported in distributed mode.
  • Posgres-XL (https://www.postgres-xl.org/overview/)

Sell Software online

Where can software developers sell their products online ?
There are many facilitators that help setup your own site from templates like opencart, with payment-processing baked in.
But what if I don't want the hassle of setting up a site ?
Are there online stores where one can  register and start selling ?

Payloadz : https://store.payloadz.com/
$19.95 per month 2.9%+$0.29 per transaction, billed monthly. Has store. No reviews ?

ClickBank: https://accounts.clickbank.com
This affiliate marketplace is for all things digital.  Though ClickBank has its own store, it focuses mainly on using affiliates to generate sales.
50$ activation, no monthly, 2.5$ per batch payment xferred to ur acct. You can decide what to pay affiliates. Has store, no reviews.

EBay:
Don't see much custom software sold here. Commissions hefty.

Amazon:
Don't see much custom software sold here. Commissions hefty.

E-junkie: https://www.e-junkie.com/
eBay affiliation ? Seems to have lots of e-books.
5-40$ per month, based on num of products, storage space, remote files.
Features like pay-what-you-want, pdf protection, affiliates.
Has store. No reviews.


PayPro: https://payproglobal.com/
Provides many features, including software protection.
4.9% + 1$ to 7.9% minimum 1$ of sales. Has store, reviews. Download trial ? Adds GST too. Does not need buyer to log in, but then how do you have verified reviews ? Does not support custom tags for searching. Does allow full text search. Does not show price on list page. Has poor reviews, unable to login etc.