Before looking at head first design mode, a C + + version is implemented according to the code in the book (Java version in the book), and the code is uploaded in https://github.com/clpsz/ Book-hfdp-code.
At the time, because of limited capacity, there was no direct choice to see Gof's design pattern: The basis of reusable object-oriented software. In the last one months, I wrote a little QT program on Windows, had a little understanding of C + + and design patterns, and looked back at Gof's masterpiece and didn't feel so difficult. So take the time to read through the book, although the book has some C + + code, but basically is based on a specific scene, and many are not all, so I just by the way all of the patterns in the inside and put it on GitHub, the address is as follows https://github.com/ Clpsz/gof-design-patterns. All the code took me a little more than three days to write from Saturday onwards to this Tuesday morning.
All code is the demo version of this mode, there is no pre-set scene, no third-party library, using only the String,vector,map these STL, so directly native C + + can be compiled, my test environment for Ubuntu 12.04 64bit.
has been doing Linux development, so the C language is relatively familiar, intuitive feeling is C language good strong, high efficiency, less reliance, easy to run. Recently, a little C + + has been implemented, and the efficiency of development has been greatly improved, compared to C. Personal feeling when I use C + +, there are some very handy features:
- powerful STL can be used, such as vector,string,map and so on it is very comfortable to use. The
- function overload is so convenient that it is troublesome to have a different function name before, and sometimes have to use a number suffix such as foo1. The default value of the
- parameter, which is very convenient, is to add a default value directly to the parameters that are not changed frequently. The
- is programmed for the interface. This is an important principle of design patterns, which can be well achieved through the virtual functions of C + +.
Feel like you can use C + + in the future.
You are welcome to comment on the code https://github.com/clpsz/GOF-Design-Patterns and welcome the discussion.
23 C + + implementations of design patterns