博文

C++ constness and reference

Case 1: Make function const vs. non-const const Track& ScoreTableElement::getTrackLeft() const {     return left_; } vs. const Track& ScoreTableElement::getTrackLeft() {     return left_; } The difference is, if the function is not marked const, then we can not call this function on a const variable or const reference variable, because this function could change the content of the object, so the const variable/reference will not allow the calling of this function. Example: sf::of::ScoreTableElement element(track_left, track_right, 4.5F); scoretable.push_back(element); const sf::of::ScoreTableElement element_out = scoretable.back(); // or const sf::of::ScoreTableElement & element_out = scoretable.back(); element_out.getTrackLeft(); // compiler error getTrackLeft() is not const function Case 2: Assign return const reference to const vs. non-const reference const Track& ScoreTableElement::getTrackLeft() const {   ...

The problem with partially finished user story

Problem description: When a sprint finishes, some unfinished user stories have a status in which some of the work, or sometimes even most of the work is claimed to be finished already. The remaining work to be done will naturally be rolled over to the next sprint and get its size re-estimated. However, the question remains when it comes to how to handle the credits that lies partially in these user stories. Should the story points be extracted and summed up as finished story points in the previous sprint?  There is some discussion on stackoverflow The solution could be this one: Do not take partial credit for semi-finished user stories, based on splitting the big user stories into smaller ones as mush as possible. Here is a good article that explains this: https://www.mountaingoatsoftware.com/blog/dont-take-partial-credit-for-semi-finished-stories

C++11 compile issue in eclipse cdt

In order to compile the c++11 enabled code in eclipse, we need to add a flag to GCC compiler.  Project -> Property ->C/C++ build ->Settings ->GCC C++ Complier ->Miscellanous -> add " -std=c++0x" to flag. However... Although in this way we can compile the code for c++11 in cdt, the editor is unaware the c++11 code, so it still shows errors.  To workaround this, we need to add two symbols in cdt for C++ compiler.  Properties -> C/C++ General ->Path and Symbols -> add these two symbols "_GLIBCXX_USE_C99_STDINT_TR1" with no value "__cplusplus " with value "201103L"

A bit more about C++ extern and const

We all know in order to make a const variable global we need to use extern both for the definition of this const variable and its declaration.  That means, in file1.cpp we define the variable n in this way: extern const int n = 8;  In file2.cpp we declare n in this way:  extern const int n;  So why do we need extern in file1.cpp when we define the const variable?  It's because const implies internal linkage by default, so your "definition" isn't visible outside of the translation unit where it appears. In this case, by far the best solution is to put the declaration (extern int const n;) in a header file, and include that in both file1.cpp and file2.cpp. The linkage is determined by the first declaration the compiler sees(so become the header file), so the later definition in file1.cpp will have the correct (external) linkage. As an alternative solution, you add extern in both declare and define of the const, to make it external linkage.

One way to remember the difference between char * const pointer and const char * pointer

char * const pointer ; means that the pointer is constant and immutable but the pointed data is not. const char * pointer ; means that the pointed data is constant and immutable but the pointer is not. An easy to think it is the const modifier is always bind to the next closest thing it can. So in char * const pointer ; the const bind to the pointer variable directly, means the pointer itself can not be modified, but the value the pointer pointed to can be modified.   On the other hand, in this case const char * pointer ; the const modifier bind to *pointer, this means the *pointer(which is the value the pointer pointed to) can not be modified while as the pointer itself can be modified.

Problem with install sublime on ubuntu

Problem 1: Not able to add ppa for sublime under company proxy: sudo add-apt-repository ppa:webupd8team/sublime-text-2 Solution: The problem is caused by proxy. Solution is to keep proxy environment variables http_proxy when doing sudo: sudo -E add-apt-repository ppa:webupd8team/sublime-text-2 Problem 2: The problem is the repository only provide a amd64 package for sublime but during the update of ppa also look for an aarch64 package. First check which architecture your computer is using: dpkg --print-architecture shows that the architecture is amd64 Then edit the source.list file in /etc/apt/sources.list.d/webupd8team-sublime-text-2-trusty.list file to add [ arch=amd64 ] after deb, this means only check the package for amd64 architecture.

Tools installed previous

List of tools from previous work activator-1.2.3-minimal apache-ant-1.9.2 apache-maven-3.1.1 apache-tomcat-7.0.42 bootstrap-3.2.0 celum cygwin64 eclipse elasticsearch-0.90.8 Enterprise Architect Firefox Git gradle-1.10 grails-2.3.6 grails-2.3.8 grails-2.4.1 Greenshot grepWin groovy-2.2.1 gwt-2.6.0 IntelliJ IDEA 13.1.1 ipscan-win32-3.0-beta6.exe Java jboss-4.0.5.GA kibana-3.0.0milestone4 logstash Markdown_1.0.1 nodejs Notepad++ Pidgin play-2.2.4 Psi restclient-ui-2.4-jar-with-dependencies.jar sapjco3-NTAMD64-3.0.10 sapjco-ntamd64-2.1.8 scala scala-eclipse scala-eclipse-2.11 SoapUI-4.6.2 springsource Sublime Text 2 TortoiseGit WinDiff.Exe WinSCP