Tuesday, June 14, 2011

What is the best installer?

http://stackoverflow.com/questions/734057/what-is-the-best-installer

Nullsoft Scriptable Install System - it's popular, easy to use and FREE
Nullsoft Scriptable Install System (NSIS) is a script-driven Windows installation system with minimal overhead backed by Nullsoft, the creators of Winamp. NSIS has risen to popularity as a widely used alternative to commercial and proprietary products like InstallShield. - Wikipedia
There is rich plugins directory for NSIS, where you can find for example a plugin for installing windows services.

Commercial alternatives:

Other:

  • WiX
  • Inno Setup
  • Setup Project from Visual Studio - there are ways to make good complex installation packages with it, but it's not that easy.

List of Installatino Software


Software Auto-Update

The recent blog post from the Chromium team is a great guide:
http://blog.chromium.org/2009/01/google-chrome-installation-and-updates.html
Basically, the same thing is done when you use MS's ClickOnce and I have no problem using applications with such update method so far, so I guess this classify as a "Best practice"... but that's just me.
  1. Store each version in its own unique folder.
  2. Use a "Launcher" to launch the most updated version available and...
  3. Check for any new versions in the background after the application has launched.
  4. Download any new version found and make a new folder for that version.
Google Chrome is a little different since they use the Google Update service to do the updating but the overall experience/cycle is pretty much the same.
Your user launch an application, if any new version is available, it's downloaded in the background. And then the next time the application starts, your user gets the new version automatically and (if possible) silently.



Friday, June 3, 2011

构造函数和析构函数中调用虚函数有什么问题?


构造函数和析构函数中的虚函数调用
    一个类的虚函数在它自己的构造函数和析构函数中被调用的时候,它们就变成普通函数了,不“虚”了。也就是说不能在构造函数和析构函数中让自己“多态”。例如:
class A
{
public:
    A() { foo();}        // 在这里,无论如何都是A::foo()被调用!
    ~A() { foo();}       // 同上
    virtual void foo();
};
class B: public A
{
public:
    virtual void foo();
};
void bar()
{
    A * a = new B;
    delete a;
}
    如果你希望delete a的时候,会导致B::foo()被调用,那么你就错了。同样,在new B的时候,A的构造函数被调用,但是在A的构造函数中,被调用的是A::foo()而不是B::foo()。为什么会有这样的规定呢,原因如下:
    当基类被构造时,对象还不是一个派生类的对象,所以如果 Base::Base()调用了虚函数 virt(),则 Base::virt() 将被调用,即使 Derived::virt()(派生类重写该虚函数)存在。
    同样,当基类被析构时,对象已经不再是一个派生类对象了,所以如果 Base::~Base()调用了virt(),则 Base::virt()得到控制权,而不是重写的 Derived::virt() 。
    当你可以想象到如果 Derived::virt() 涉及到派生类的某个成员对象将造成的灾难的时候,你很快就能看到这种方法的明智。详细来说,如果 Base::Base()调用了虚函数 virt(),这个规则使得 Base::virt()被调用。如果不按照这个规则,Derived::virt()将在派生对象的派生部分被构造之前被调用,此时属于派生对象的派生部分的某个成员对象还没有被构造,而 Derived::virt()却能够访问它。这将是灾难。
文章出处:http://www.diybl.com/course/3_program/c++/cppsl/20071211/91630.html

What is REST?

http://blogs.windwardreports.com/tomasr/2011/04/what-is-rest.html


Let me give you a very simple, practical explanation.
  • REST is a methodology for creating web services.
  • The point of RESTful web services is to be as simple as possible.
  • RESTful web services use HTTP Methods: GET, POST, DELETE, PUT. You do not use the URL or the request body to specify the method.
  • RESTful web services use URLs specify what objects should be operated upon.
  • RESTFUL web services use HTTP status codes as return values.
  • The HTTP request body of a RESTful web service call is used only for data - not to specify the method, target objects, or return value.
The point of writing web services using REST is to take advantage of the simplicity of the HTTP protocol, and not to work against it. Your web service calls end up being very simple and easy to understand.
Here's an example of using a REST web service. This is a javascript function that retrieves a task object from the web service.
function sendGetTaskRequest(packet, template, task, handler) {
// This line creates a web request
requestGetTask = new XMLHttpRequest();

// This line specifies the HTTP method and the URL.
// Notice the URL is simply a path to an object.
requestGetTask.open("GET", baseUrl + "/v1/packets/" + packet + 
"/templates/" + template + "/tasks/" + task);

// This line hooks up a method to handle the response
requestGetTask.onreadystatechange = handler;

// This line sends the request
requestGetTask.send();
}

So to get a task, I just have to make a GET request to the task URL. To add a task, I could just POST to the tasks URL. REST makes web services very easy to use.
If you want a really good book to learn about REST, I recommend RESTful Web Services by Leonard Richardson and Sam Ruby.

http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/
http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
http://www.restapitutorial.com/resources.html

Monday, May 30, 2011

RCP and Java Web Start


A Rich Client Platform (RCP) is software consisting of the following components:

  • A core (microkernel), lifecycle manager
  • A standard bundling framework
  • A portable widget toolkit
  • File buffers, text handling, text editors
  • A workbench (views, editors, perspectives, wizards)
  • Data binding
  • Update manager

With it, programmers can build their own applications on existing platforms. Instead of having to write a complete application from scratch, they can benefit from proven and tested features of the framework provided by the platform. Building on a platform facilitates faster application development and integration, while the cross-platform burden is taken on by the platform developers.

OSGi
http://www.vogella.de/articles/OSGi/article.html



http://i-proving.ca/space/RCP+and+Java+Web+Start

Java to EXE
http://www.excelsior-usa.com/articles/java-to-exe.html

how to make a jar file that include dll files

Java Communication API

http://www.kuligowski.pl/java/rs232-in-java-for-windows,1

http://www.intellog.com/blog/?p=255

After much searching, I solved the problem by putting the "bluecove-2.1.0.jar" file in "C:\Program Files\Java\jdk1.6.0_11\jre\lib\ext" folder.
http://groups.google.com/group/bluecove-users/browse_thread/thread/db2e7632e7420712?fwc=1&pli=1