Multi-device Syncing Strategy

While reconstructing my app (WordsBaking), a big challenge is data synchronizing. I’ve spent a lot of time thinking about possible ways, and still not sure if I got the best one.

There are two main problems I am facing.

Physical timestamps can’t be trusted

When the user is online, well we may actually calculate the timestamp based on the difference between client and server that can be somehow trusted at some degree. However the process could be really complex if we want to get every detail right. And if the user is offline, you can never tell the timestamp that can be trusted.

So I have to get rid of it, and choose only to trust the physical timestamps with limited correction (lower and upper bounds).

There are too many records to compare when syncing

For my app, there could be thousands of records. And I can’t just upload all of them every time to check whether their timestamps are smaller than the copies on the server. Another independent timestamp for syncing has to be set for quickly picking up records that might have newer version.

The solution seems to be really obvious, just add another timestamp for sync seeking. The question keeps around in my mind is, do both of the timestamp for seeking and for version comparing necessary?

If they are, the complete synchronizing logic would be:

Client

clientStamp: updated every time after syncing, and the value equals the server time when that syncing happens.
itemUpdateStamp: updated every time when an item gets created/updated/removed, and the value should be greater than the latest clientStamp.

When syncing, client would upload the clientStamp and changed items along with their own itemUpdateStamps. And then it would receive changed items from the server along with the new clientStamp, it won’t receive new itemUpdateStamps because it’s not the device that would compare the records version.

Server

For every record in the database, it will have both the clientStamp and the itemUpdateStamp. When receiving a syncing request, it will first find all the records that have the clientStamp greater than the value it receives or have the same ids, and then comparing itemUpdateStamp with the items it receives respectively if they match the items it receives. If a change from the client has a newer itemUpdateStamp, then update the record in database (with the upper bound of itemUpdateStamp being the current time of the server). Otherwise, send the change to the client.

Seems to be quick clear after writing the logic down. 😉

Later I added another feature called passive syncing, thus the client is now able to sync down some related data on demand.

iOS Web Application Directly Using Online URI

Will Apple App Store approve web apps that directly using online URL and resources?

Yes.

When I submitted my app to Apple App Store, I was worrying about a rule that forbidding downloading code in any way or form. And as a web app that downloads its main code only after installation, it does seem to violate this rule. But luckily, it’s finally approved.

Apple App Store http://itunes.apple.com/app/id843170841
See also the Windows Phone version http://www.windowsphone.com/s?appid=a3e70b25-b048-4bef-996f-cc2b30a6eda2

And congrats to myself that WordsBaking is scheduled to be FEATURED in Windows Phone Store (China) tomorrow. 😉

An Underestimated Tool in Windows: HTA (HTML Application)

I can’t find a convinced source telling in which specific date did HTA become available, but it seems to be earlier than the year 2000.

On the official introduction page of HTA, there’s a highlight saying “The Power of Trust”. Unlike normal HTML pages running in a normal browser, HTA can have almost the same permissions that an exe file could have. Which gives it access to varieties of ActiveX that are not available in normal browsers due to security reasons.

I am always wondering why only a few people know and use HTA? Hmm, maybe one of the reasons is its “Microsoft” tag. I have given up the thoughts hoping HTA could be relatively mainstream, however, for developers who use JavaScript and HTML, HTA could still be a good choice to write some lite productive tools for your colleagues and yourself.

NodeJS would certainly have much better ecosystem now but for some specific tasks I still prefer tools with GUI… T-T (Now I also use NodeJS to do some batch work.)

But it was a shame that Microsoft stopped making it better. Wishes.

Let's Again Talk About IE (Internet Explorer)

As an amateur but the same time professional front-end engineer, one of the most common things in my life is to press F5 in different browsers.

When this word was not “standardized” as it is now, I was used to pressing that button in several versions of IE, Chrome, Firefox, Safari, and, if I was in a really great mood, Opera. So I hadn’t suffer less than anyone. Especially from IE 6/7.

Now I basically test only in IE 8+ and Chrome. If the project is platform targeted, even better. There has been a lot of scoffs about IE  on compatibility and performance these years, which make me sort of sorry. People would always be fond of the new and tired of the old, even though it is the old one which brings the bright start to all these wonderful things.

IE 6 in my opinion is a great browser. It is out of date but It was well-designed and ignited many features in modern browsers. Actually, tons of newly added features in HTML5 or CSS3 can be imitated in IE 6, a browser which was released 12 years ago. And many earlier IE-only features have become the standards.

The earlier versions of IE is buggy and perform slow, but they perfectly served the days when it was released.

Well I am not trying to ask people not to give it up, but just hoping we can keep the respect, which this browser deserves, to it in its last days.

Microsoft seems to have realized their mistakes on detaining the developing of IE these years and brings us the new IE 9/10/11. Compatibility issues have become minor since version 9 (also it brings us fully GPU acceleration, which is a really important event for web apps), and since version 10, IE finally caught up the steps of modern browsers.

IE now is almost ready for web apps which could be as great as native apps, and I am looking forward to the booming of mobile web apps in the next several years. 🙂

Thoughts after Developing WordsBaking

Several months ago I started my own project called WordsBaking, which is a tool developed for helping students or learners like me to remember new English words. Considering the time and resources I have, I finally decided to use HTML/CCS/JS technologies so that it could be easier to have the versions for the three major mobile platforms.

But there would certainly be some subsequent issues. In last post, I wrote something about performance, gestures and preventing tap highlight. And in this post, I am gonna write some notes about browser bugs.

First of all, I like IE 10 Mobile quite much, comparing to original Android browser. But unfortunately, it still gets some weird bugs.

1. Scrolling issue with CSS3 transform.

I spent a lot of time locating this issue, as scrolling should be one of the most basic features, which in other word should be stable enough. It is a list of which the parent node has the style “overflow” with value “auto”. And the pseudo element “:active” of the list items has a transform with transition: translateX, so that when finger is on the item, it moves a little bit rightwards. Then the problem came, you can’t scroll the list down directly. If you want to do so, you’ll have to scroll up a little first. And, after you scroll to the bottom, you can even continue scrolling up (though the scrolling becomes no longer smooth).

So I have to change the transform to some older ways, like margin, padding, etc.

2. Scrolling issue with phone:WebBrowser control.

Ohh, again scrolling. To use pointer series of events built in IE, I have set -ms-touch-action to none under html selector. So that the page won’t move around or dance with your fingers. It works well until you get some elements with style “overflow: auto;” (or “scroll” I guess). After a list is scrolled to the top or bottom, if you put away and back your finger and continue scrolling, the whole page starts a bouncing effect. Luckily, this only happens in a phone:WebBrowser control. But unfortunately, I am using that control to wrap up my app.

I guess there should be a solution but I really haven’t found it.

Okay, so these are issues with the front end. On back end, I chose NodeJS as I am more confident with my JS skill. But it really took me quite a lot time to start due to the poor documentation. I am not familiar with back end and everyone knows I write front end all the time. I can’t say it would be a challenge to write the back-end stuffs I’ve done these days, but it was a great chance to learn new things.

The main problem I have is lack of database related experience, I don’t know how the db engine works in the box, so I don’t know how would my structures and logic perform. T-T

But back to NodeJS, I am quite missing my VEJIS, which helps JSers coding without looking for online documentations. Oh dear you know how it feels when you press the “.” but there is no accurate auto completion and hints? It might not be that helpful after one is extremely familiar with a framework, but before that, it helps a lot. And one more thing, we are never be that familiar with every new code line we write…

A thousand words are reserved here…

wb

So, I am very excited as WordsBaking for WP is almost ready for beta, after months. I always believe the power of a team, but when a team is not available, I also believe my own skills. Thanks my CTO (Chief Track Officer) for Tracking my developing progress btw, or I wouldn’t be able to finish the beta version. 🙂

Windows 8 Earlier and Recent Start Screen Color Comparison

Every time when comes to Windows 8, I feel sad… The reason is simple, I want the latest version, but I feel better with the earlier one. So even though I was the first group of people out there who started trying Windows 8 since Developer Preview, then Customer Preview, Release Preview, and RTM. But finally I degraded (several times) to Windows 7, which is my favorite so far.

Some people might think I am not a fan of Metro UI, but they are wrong. I am a big fan of that, and I started using Windows Phone since Mango (7.5) is still in test version. I love Metro, but as well as Aero. I have posted about this and wrote Windows 7 along with VS 2010, Office 2010 etc, as well as Windows Phone 7.5 are the highest level Microsoft had reached on UI design (of course in my personal opinion).

It was not my plan to write this post actually. I made a comparison image of the start screens on early Windows 8 concept image and Windows 8 released to public a long time ago, and I have never thought that I might be wrong. Here’s the image:

win8

I like the earlier one (which in my opinion uses more reasonable colors) much more than the released version. No matter the color gradient or hue. But I was so confident and thought everyone will agree with me, until I sent this image in a group chat and get punched just now.

I always think I am person gifted on many, including some aesthetic feelings, and I don’t think this is negotiable. So I begin to wondering, how do most of the people judge the beauty of everything? One word I heard today was bright. So I started to thinking about all the facts that might bring visual impact just like bright colors, but may need more time to figure this out.

As far as I know, most of people just don’t care about the arrangement of colors. For Windows Phone users, a messy start screen is a proof. Also, most of them don’t care about the proportions of the elements (including text elements and images, no need to mention colors), and a proper margin between them just doesn’t matter to most of the people either, if it doesn’t make the features harder to use.

It is good to find that many IT industry leaders in China still have the first class designers so far, like Tencent, Alibaba. Actually even many start-up companies do. But what happened to companies like Microsoft and Apple? I still remember one of the reasons why I kind of liked Microsoft was that they had the best designers…

One of the reasons comes to me is, they might have valued the marketing researchers too much, and letting them manipulate designers and developers. Or maybe a much simpler answer, they just have lost the best people they had and that’s all.

Dust

I have spent my whole life thinking about everything. And like many doing the same, I might be closer to the answers, however, never less confused.

But some people like me just hate being confused, so they choose to believe something, or to get themselves crazy (joking), like that I choose to become a determinist as well as an atheist. My father has become a Buddhist since I was still a little kid, and actually I was always afraid of other people knowing that my father believed in that thing, which in my little eyes was stupid. I don’t know much more about Buddhism than I did, but I get to know more answer-like opinions which help me look into the world from better angles. And it turns out things I believe don’t seem to be much wiser than those religions.

We are dust in the universe.

I should be counted as an admirer of the nature. I stop everywhere to feel it, to feel the beauty, the strength, the details and everything that makes me feel that I am there. And of course, sometimes I just can’t help thinking about death, after which I would never be able to feel anything. Because I believe at that time, my consciousness would have again become part of the mind of the universe, and that amazing thing would never be able to feel myself any more. That’s sad, but the same time I am so curious about the mind of the universe. When I start dying someday, I hope I would get a second or two to take a glance at that great mystery.

But no, I don’t think I would get that chance, and that’s really a pity of choosing what I choose to believe.

One of the opinion I believe is that the universe is nothing and can’t even be defined by nothing, as no word can be used to describe it. Actually it makes people even sadder comparing to thinking about their consciousnesses being just illusions. And it brought me depression for a quite long time, but finally I became able to separate it from my real life and continue the meaningless everything. 🙂

Dust. But still amazing.

Freedom in My Eyes

Weeks ago when I was on the road aside a river, from the subway station to the bus station in Chengdu, again I saw people sitting on benches, and enjoying their afternoon. Suddenly I was touched. Most people around me are just pursuing really simple and easy lives. But I was just trying to ask them to give up their way of life and accept something they might not want, so called liberty and democracy.

Though actually, I have successfully brought the mind of those two things to many people around me, and I am still proud of that.

In my philosophy, to a question without any assumption, namely an ultimate question, proving whether a self-consistent answer is true or false might be impossible. So I think I should accept an opinion that says there is not a value which is universal. But on the other way, since we are not able to know whether an answer is true, we may want to believe one of them. And that’s what I call belief.

People might have several believes as they might be the answers to different questions. Like many people believe liberty and democracy are universal values as they also believe in God or maybe some other principles?

I am really into the theory of evolution as I find it explains many things in our life, and our society, other than the evolution of creatures. It might be the most interesting case as this theory is used on cultures and societies. As countries like United States are promoting the value of every single person (which is my type), countries like China are talking about the whole nation. Which one is better? Or even more straightforward, which one is correct? The answer in my opinion might not satisfy you but is really simple. You can’t tell the correctness without assuming universal values. However, so far, these two kinds of societies both exist on our mother planet, and both of them seem to be moving forward along with the progressing of human beings.

I am not saying that the CPC is doing great, just expressing the idea that I accept such a value of putting all the people together. But every thing has levels, and there are indeed some common wishes of human beings. Such as better life quality, less limitation, maybe also a louder voice etc.

In the final examination of a course called Basic Principles of Marxism, which is an obligatory course of every university student in China, the last question is: Explain why Communism will finally take the place of so called Capitalism. The first line of my answer is that: I don’t think Communism will finally take the place of Capitalism. (And yes I failed that exam.) As a student living with Internet, I understand both of these two things have their own advantages. And I also believe, the barrier in these two things is productive force. As it grows, we might see an earth with no boundary one day. The country under which institution will reach that point first? I believe it’s closer to the one that China has.

But I am just saying CLOSER, not IS. China needs to be reformed before this giant machine is able to run more (much much more) efficiently. The governments need the trust of their people, but from the things they have done or are working on, instead of fooling and using violence. People are not wise, but balloons will finally explode.

I understand all my thoughts about this topic might be facial, but I am still glad to share. I might some day immigrate to the U.S. if I am able to, as I want a free Internet and simpler social circles. Maybe also a place where I would be able to find a girlfriend, lol.

入手 ThinkPad Compact Bluetooth Keyboard with Track Point (带小红点的紧凑型 ThinkPad 蓝牙键盘)

这东西好像没中文名一样… 型号是 0B47189/0B47190, 前者带蓝牙, 后者有线.

最想说的就是,,, ThinkPad 的原厂配件质量做工都没的说, 就是性价比低得要死… 天猫 499 入手… 为了提高写代码的效率, 另外保护眼睛, 买了个外接显示器, 手不好伸那么长去摸本子的键盘, 所以就说买个蓝牙的. 还打算买个扩展坞, 不过暂时没钱了. (另外就顺便说下蛮喜欢微软的那个蓝牙键盘, 貌似叫 微软蓝牙便携键盘5000, 看起来不错, 不过没办法,,, 没小红点, 加上一套一套看起来多舒服.)

这款带小红点的蓝牙键盘是内置锂电池, Micro USB 充电, 据说充一次能用一个月. 键盘布局除了功能键之外, 跟我的 T430s 一模一样, 手感材质也如出一辙. 不过我觉得这样就足够了, 打字也挺舒服的, 没有机械键盘那么高的追求…(心灵手巧没办法)

大局观

侧面

底部

另外很奇怪这款键盘在网上基本上没看到什么测评, 大陆官网也搜不到, 所以更多细节我这个只注重外表的人也看不出来了. 有一点倒是非常好奇,,, 这东西, 防泼溅么? 欢迎土豪试试然后分享下感受哈哈.

上手 Visual Studio 2013 Preview

当然, 我最关心的还是对 JavaScript 的改进. 当然简单的看了下没法知道所有细节, 就说说我有看到的地方.

1. 在新建项目中发现了 Python 说是支持 IronPython 和 CPython, 不过想来单纯写脚本也应该没有任何问题? 不过不用 Python 表示不是很了解… 有点期待之后是否会有 NodeJS?
2. 在新建文件中看到了 LESS 和 coffeescript, 虽然也都不用,,, 囧…

JavaScript 相关:
1. 光标在变量名上时会高亮相关变量, 并且区分各种 scope, 但是怎么找也找不到重命名的选项, 不知道之后会不会提供.
2. 输入引号括号时会自动补全另一半.
3. 支持了 __defineGetter__ 等相关函数的实时运行.
4. intellisense 对象扩充了几个方法, 不过介于没有文档暂时懒得去捣鼓有什么用. 这里可以简单介绍下这个 intellisense 对象. 不出意外应该是在 VS 2012 的时候引入的, 可以让代码自己调整 IDE 的提示信息. VEJIS 0.5 使用专门开发的 intellisense 文件后能给出媲美 C# 的代码提示也是依赖于这个对象. 不过可惜知道这东西的人貌似并不多…
5. 有个 bug 貌似修复了… 之前如果打完第一个字母的时候, 提示还没有显示, 就打第二个字母, 那么就看不到提示了… 刚刚试了下这个问题不存在了.
6. 工具栏上多了个刷新按钮, 叫 Browser Link, 目测可以自动刷新网页, 但不幸的是,,, 可能是浏览器支持还没完成, 我试了下没有效果.

总的来说, VS 还是我心中前端开发的最佳选择, 虽然 2010 之后它变得有点那么丑了… 希望正式版崩给我们惊喜~