Main idea 1: An std::map inside of a std::list, for counting numbers, and iterate through the std::list by number of occurance. Each element appears only once in the std::list, emulating hence a std::set.
Main idea 2: An std::map inside of a std::map, for counting numbers, and iterate through the std::map by number of occurance, instead of by order of value.
Main idea 3: An std::set inside of a std::vector and iterate through the std::vector by order of value. When printing, the number of occurence will also be printed, emulating hence a Counter in Python.
By default, you agree to share your project reports on this platform. If you disagree, tell me in private chat.
If you want some suggestions for your project …
Whenever possible, use std::vector (or other STL containers) instead of built-in arrays.
Pay attention to code readability. Profs read every code file when grading.
There should be more than 5 (or, 10) header files in your project. If your program has only 1 header file, it can easily get very messy.
GUI (Graphic User Interface) is not essential. It might help give a good first impression.
Use as many Design Patterns as possible, but only when appropriate.
On academic misconduct
Just a note to remind everyone what is OK and what is not OK in terms of talking to other students about projects.
It is DEFINITELY OK to:
discuss the assignment in general terms (what do they mean by a copy constructor?)
discuss how different C++ standard library functions work (different ways to insert an element in a std::vector)
discuss strategies for successful implementation
help others debug their code and find problems
It is NOT OK to:
bug someone else for a lot of help (particularly if they are already done!)
share your code directly with other people/project groups
Discovery of any inappropriate code sharing will lead to harsh penalties for all involved parties. We expect that all students will conduct themselves with honesty and integrity.
UML with Draw.io
Draw.io is very popular in the academy as well as in the industry.
Voici comment seront calculées les notes de l’UV (sur un total de 105, au lieu de 100):
L’examen mi-terme : ??%
Le projet : ??%
L’examen final : ??%
Some further clarifications on mid-term/final exam:
You could print the pdf of poly_cours_opt and bring it with you. Your personal paper notebooks are NOT allowed. The poly d’exercices corrigés is NOT allowed. Chinese textbooks are NOT allowed. Any other reference book is NOT allowed.
Dictionaries in paper format are allowed.
Dictionaries on smartphone are NOT allowed. All electronic devices are forbidden of use during exam.
If you have difficulties writing your answers in French, you could answer in English. Don’t write your answer in Chinese.
You are expected to ask questions via Gitee Issue. However, as a secondary (and hence, less desirable, less encouraged) choice,
you could also
ask questions in the WeChat group.
Why Gitee Issue? Because it’s simply more professional, and better in every sense.
In Gitee Issue and the WeChat group, questions will be answered selectively.
Questions won’t be answered if:
they could be solved on a simple Google search
they are out of the scope of the course
they are well in advance of the progress of the course
professors think that it’s not interesting for discussion
Regarding personal WeChat chats:
Questions asked in personal WeChat chats will NOT be answered.
Messages sent after 21:00 in personal chats will be extremely unwelcome.
Learning how to use ChatGPT & Google & Baidu & Bing to solve programming problems is an important skill you should develop during this course.
Pour des questions privées, merci d’envoyer vos questions par mail à ces adresses ci-dessous :
If you got an A or B and want to share your experience, you can write it down and send it to me via private chat, or just email to lundechen@shu.edu.cn.
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Not too ugly is better than really ugly.
Explicit is better than implicit, but bad defaults are worse than either.
A simple implementation is better than a complicated one.
A complicated implementation is better than a complex interface.
Contiguous is better than pointer chasing.
Pointer chasing is better than double pointer chasing.
Readability is important; so C++ being what it is, write lots of comments.
Special cases will require breaking the rules, but try to keep the rule breaking hidden.
That said, if you can't hide the rule breaking, a practical impure solution to a smaller problem is better than a pure impractical solution to the generic problem.
Don't use error codes.
Unless their checking is statically enforced.
In the face of ambiguity, don't compile.
There will be many ways to do everything; know their trade-offs and be an engineer and pick one!
Although the cleanest, most maintainable way will not be obvious at first unless you read books and watch talks from a lot of really smart people.
2011 is better than never.
Though never can be better if you haven't thought it through.
If the interface easily causes undefined behavior, it's a bad idea.
If the implementation is safe, it may be a good idea.
Const is a honking great idea, use it everywhere you can!
You might want to add your id_rsa.pub to GitHub so that
you won’t need to input your GitHub user name and password in the terminal each time. You can refer to this blog as to how:
I learned this approach of teaching from Prof. Fabien Pfaender, the French Dean of UTSEUS. I was so impressed. It was another level.
Here in this course of LO02, we are using a very basic and simple form of teaching/learning with git/GitHub/Gitee. In the course of Introduction To Machine Learning, a more sophisticated approach will be employed.
Why you should use GitHub: Lessons for the classroom and newsroom
In general I don’t give any career or life advices to anyone. I am a liberal and believe that the beauty of life lies in its diversity and randomness, hence an infinity of possibilities. The meaning of life is 42, *, anything, everything. Giving advices to people is limiting and more often than not unhelpful.
However, if you aspire to be a programmer, it might be worth it to build your GitHub profile, by contributing to interesting projects (personal or open-souce) and, accumulating Green Blocks, like this:
A GitHub profile with a lot of Green Blocks will make your CV more attractive.
LO02 C++ OOP Design Patterns
Some Notes :
New Things by Self:
Lectures (Cours Magistraux)
Time
Each Monday, 8:00-10:45
Classroom
EJ103 (For both G1 and G2)
Tencent Meeting (VooV Meeting):
Room ID:958 9491 5777
Course videos
Travaux Dirigés (TD)
Time:
Each Tuesday, Wednesday and Friday, 8:00 to 11:40
Classroom:
8:00-9:40 (G1)
10:00-11:40 (G2)
Tencent Meeting (VooV Meeting):
Room ID:958 9491 5777
Which Operating System to boot from:
Windows 10
Exercises & Solutions 🔍
List of all videos
List of all branches
Table of content
Materials 🚀
ex5-extended
ex8-ans-2
ex9-ans-2
ex9-ans-extended
ex16-ans-extended
ex20-q3-ans-2
ex20-q3-ans-3
ex20-q3-ans-4
ex20-q3-ans-5
ex20-q5-ans-2
ex21-csdn
ex21-q1-ans-1
ex21-q1-ans-2
ex22-q5-ans-v2
leetcode-284-v1
leetcode-284-v2
ex24-singleton-v1
ex24-singleton-v2
ex24-singleton-v3
ex24-q1-ans-2
ex24-q1-ans-3
leetcode-1286-v2
video2
ex24-q6-iterator-v1
ex24-q6-iterator-v2
ex24-q6-iterator-v3
ex24-q6-iterator-v4
video2
leetcode-535
leetcode-1941
leetcode-136
ex35-q1-extended
ex35-q2-ans-2
ex35-q2-ans-3
ex36-extended
video2
Exam Revision
Midterm exam revision
Note: I make those videos so as to help you revise more targetedly. It represents significant extra work (for free) on my side.
For midterm exam revision, Ex23_Ex24_solution.pdf will help a lot, and LO02_poly_exercices.pdf is your best friend.
Final exam revision
Note: I make those videos so as to help you revise more targetedly. It represents significant extra work (for free) on my side.
For final exam revision, LO02_poly_exercices.pdf is your best friend, and practicing STL containers with above-listed leetcode will help a lot.
Final exam revision #1 - Ex75 (poly exercise)
Final exam revision #2 - live code - containers
std::map
inside of astd::list
, for counting numbers, and iterate through thestd::list
by number of occurance. Each element appears only once in thestd::list
, emulating hence astd::set
.std::map
inside of astd::map
, for counting numbers, and iterate through thestd::map
by number of occurance, instead of by order of value.std::set
inside of astd::vector
and iterate through thestd::vector
by order of value. When printing, the number of occurence will also be printed, emulating hence a Counter in Python.char
andint
. It’s up to you to make it a template class.Project 🔨
Project
Dans le cadre de cet UV, vous travaillerez par groupe sur un projet C++ en rapport avec le contenu de votre cours et des TDs.
Project description:
Forming teams:
https://docs.qq.com/doc/DT1R1RFdJdFRSUHVw
提交项目
正确示例:
往届学生优秀 project 作品 (videos)
You could get some inspirations from those projects, accomplished by students from past promotions.
Be innovative. You can do even better.
2021 Fall
2022 Fall
往届学生优秀 project 作品 (rapport pdf)
If you want some suggestions for your project …
std::vector
(or other STL containers) instead of built-in arrays.On academic misconduct
Just a note to remind everyone what is OK and what is not OK in terms of talking to other students about projects.
It is DEFINITELY OK to:
std::vector
)It is NOT OK to:
Discovery of any inappropriate code sharing will lead to harsh penalties for all involved parties. We expect that all students will conduct themselves with honesty and integrity.
UML with Draw.io
Draw.io is very popular in the academy as well as in the industry.
Download the software:
Online version:
Last but not least
Notes & Exams
Voici comment seront calculées les notes de l’UV (sur un total de 105, au lieu de 100):
Some further clarifications on mid-term/final exam:
Answer sheet for exams:
Failing rate
Despite the efforts from the prof side, historically, the failing rate of LO02 has been very high.
关于重修
重修的同学,去年项目分数是可以保留的,也可以今年重新做,刷新分数。
不过,公平起见,重修的同学的往年项目分数不会透漏。是否重做项目,大家自己把握。
学分替代
具体细节不详,如有需要,可以咨询教务处。
Asking Questions
使用 Gitee Issue 提问
By default, you should ask questions via Gitee Issue. Here is how:
Principe
Here is the principle for asking questions:
You are expected to ask questions via Gitee Issue. However, as a secondary (and hence, less desirable, less encouraged) choice, you could also ask questions in the WeChat group.
In Gitee Issue and the WeChat group, questions will be answered selectively.
Questions won’t be answered if:
Regarding personal WeChat chats:
Learning how to use ChatGPT & Google & Baidu & Bing to solve programming problems is an important skill you should develop during this course.
Pour des questions privées, merci d’envoyer vos questions par mail à ces adresses ci-dessous :
Office visit
Office visit is NOT welcome unless you make an appointment at least one day in advance.
Misc
Textbooks, slides, exercises in pdf
They have been there as well … and got an A/B!
Suggestions from students who got an A or B:
Books
See this branch: books
Bilibili Videos
🔨 Install CLion and Git
🚀 How to manipulate with git during TD sessions
git stash
,git pull
andgit checkout
most of the time.How to push your code to GitHub
🐛 🐛 🐛 🐛 Debug
For debugging with CLion, watch this:
How to clone this repository
Method 1:
Then open the
cpp
folder with CLion.Method 2:
In CLion, click
VCS
->Get From Version Control
, input the url:Then click
clone
.When your CLion project seems broken:
重新 clone (VCS->Get from Version Control)试试
关闭所有的代码编辑tab,然后再次打开代码文件。
或者关了 CLion, 删除项目的 .idea 文件夹,然后再次打开 Clion
Cpp and design patterns courses in other universities
See this branch:
Zen of Python
https://peps.python.org/pep-0020/
Zen of C++
https://www.reddit.com/r/cpp/comments/48obqd/what_is_the_rcpp_c_equivalent_of_the_the_zen_of/
Code style [optional]
CLion can help us reformat code.
Very Basic Markdown [optional]
You might need to use (triple) backquotes (`) to make your code in Gitee Issue more beautifully rendered:
Example 1
```cpp
int main() {
std::cout << “Hello, World!” << std::endl;
return 0;
}
```
will render in markdown as:
Example 2
```static``` will render as
static
.`static` will render as
static
as well.Detecting memory leak with Linux tools [optional]
https://www.cprogramming.com/debugging/valgrind.html
https://stackoverflow.com/questions/5360491/how-i-can-detect-memory-leaks-of-c-application-in-linux-ubuntu-os
https://www.networkworld.com/article/3006625/review-5-memory-debuggers-for-linux-coding.html?page=2
Valgrind can be used directly in CLion:
g++ v.s. CMake v.s. makefile [optional]
gcc
is used to compile C program whileg++
is used to compile C++ program.https://www.cvl.isy.liu.se/education/graduate/opencv/CMake%20presentation.pdf
https://courses.cs.washington.edu/courses/cse326/00sp/unix/g++.html
https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html
https://www.softwaretestinghelp.com/cpp-makefile-tutorial/
Very basic Boost library [optional]
https://www.tutorialspoint.com/advanced-cplusplus-with-boost-library
https://www.boost.org/doc/libs/
Other Cpp open source libraries:
Online C/C++ Compiler
If you are stuck with your CLion configuration during TP sessions, you could write and run your code online:
How to push your code to GitHub
1. Create a repo on GitHub
You might want to add your
id_rsa.pub
to GitHub so that you won’t need to input your GitHub user name and password in the terminal each time. You can refer to this blog as to how:2. Add the repo as a remote
3. push the branch to GitHub repo
Corresponding video:
Why do we use Gitee/GitHub in this course?
I learned this approach of teaching from Prof. Fabien Pfaender, the French Dean of UTSEUS. I was so impressed. It was another level.
Here in this course of LO02, we are using a very basic and simple form of teaching/learning with git/GitHub/Gitee. In the course of Introduction To Machine Learning, a more sophisticated approach will be employed.
Why you should use GitHub: Lessons for the classroom and newsroom
How do you use Issues in your class?
Why leetcode?
Keep things in perspective
Some programmers argue that “Object Oriented Programming is Inherently Harmful”:
http://harmful.cat-v.org/software/OO_programming/
https://nccastaff.bournemouth.ac.uk/jmacey/Lectures/DesignPatterns/lecture1/#/1/4
Design patterns repositories on GitHub
Those resources, found by googling “GitHub cpp design patterns”, could be interesting for some of you:
Career advice
In general I don’t give any career or life advices to anyone. I am a liberal and believe that the beauty of life lies in its diversity and randomness, hence an infinity of possibilities. The meaning of life is 42, *, anything, everything. Giving advices to people is limiting and more often than not unhelpful.
However, if you aspire to be a programmer, it might be worth it to build your GitHub profile, by contributing to interesting projects (personal or open-souce) and, accumulating Green Blocks, like this:
A GitHub profile with a lot of Green Blocks will make your CV more attractive.
xkcd