目录
目录Readme.md

LO02 C++ OOP Design Patterns

Some Notes :

  • 本仓库为备份自课程项目仓库,预防私有化而无法查看的情况
  • 本仓库会有一部分自定义内容,区别于原本的课程仓库
  • 本仓库仅用作备份和资料整合,如果需要查看通知等内容,请自行前往课程仓库:点击前往

New Things by Self:

  1. 添加部分文档的中文翻译:zh-pdf 2024-10-01

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

Course videos by Prof. Antoine Jouglet are on Chaoxing Platform.

Travaux Dirigés (TD)

请大家上课带上耳机,上课时不时会需要使用,谢谢!

Time:

Each Tuesday, Wednesday and Friday, 8:00 to 11:40

Classroom:

8:00-9:40 (G1)

  • D406

10:00-11:40 (G2)

  • D406

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

Exercise 🔒 Solution Leetcode Video Reading
Materials 🚀
ex1 ex1-ans leetcode-2235 video
ex2 ex2-ans
ex3 ex3-ans blog
ex4 ex4-ans leetcode-509 video blog1 blog2
ex5 ex5-ans
ex5-extended
blog
ex6 ex6-ans blog1 blog2
ex7 ex7-ans leetcode-1929 video blog
ex8 ex8-ans-1
ex8-ans-2
blog
ex9 ex9-ans-1
ex9-ans-2
ex9-ans-extended
blog1 blog2 blog3 blog4 blog5 blog6
ex10 ex10-ans video blog1 blog2
ex11 ex11-ans leetcode-709 ans blog1 blog2
ex12 ex12-ans leetcode-344 ans blog1 blog2 blog3 blog4 blog5
ex13 ex13-ans video blog
ex14 ex14-ans blog1 blog2
ex15 ex15-ans blog1 blog2
ex16 ex16-ans
ex16-ans-extended
video blog
ex17 ex17-ans leetcode-412
ex18 ex18-ans leetcode-1470
ex19 ex19-ans leetcode-2011
ex20-q1 ex20-q1-ans video blog
ex20-q2 ex20-q2-ans blog1 blog2 blog3
NAN ex20-q3-ans-1
ex20-q3-ans-2
ex20-q3-ans-3
ex20-q3-ans-4
ex20-q3-ans-5
ex20-q4 ex20-q4-ans leetcode-2574
NAN ex20-q5-ans-1
ex20-q5-ans-2
blog
ex20-q6 ex20-q6-ans blog1 blog2 blog3 blog4
NAN ex20-q7-ans blog1 blog2 blog3 blog4
ex21 friend
ex21-csdn
ex21-q1-ans-1
ex21-q1-ans-2
video blog1 blog2 blog3
ex21 ex21-q2-ans leetcode-1512 blog
ex21 ex21-q3-ans blog
ex21 ex21-q4-ans blog1 blog2
NAN ex22-q1-ans leetcode-1603 video blog1 blog2 blog3
NAN ex22-q2-ans
NAN ex22-q3-ans
NAN ex22-q4-ans
NAN ex22-q5-ans-v1
ex22-q5-ans-v2
NAN ex23-q1-ans leetcode-1313 video1 video2 blog1 blog2 blog3
NAN ex23-q2-ans blog1 blog2
NAN ex23-q4-q5-ans blog
NAN ex23-q7-ans video blog1 blog2 blog3 blog4
NAN ex23-q9-ans blog1 blog2 blog3
ex23-q3-q6-q8 ex23-composition-aggregation leetcode-1476
leetcode-284-v1
leetcode-284-v2
video blog1 blog2 blog3 blog4
ex23-q10-q11-q12-q13-q14 ex23-q10-q11-q12-q13-q14-ans (todo) video blog1 blog2
live code ex24-static-keyword
ex24-singleton-v1
ex24-singleton-v2
ex24-singleton-v3
video1 video2 blog
NAN ex24-q1-ans-1
ex24-q1-ans-2
ex24-q1-ans-3
leetcode-1286-v1
leetcode-1286-v2
blog1 blog2 blog3 blog4
NAN ex24-q2-q3-q4-q5-q6-ans leetcode-1672 video1
video2
blog1 blog2 blog3 blog4 blog5 blog6 blog7 blog8 blog9
live code ex24-q6-iterator-v0
ex24-q6-iterator-v1
ex24-q6-iterator-v2
ex24-q6-iterator-v3
ex24-q6-iterator-v4
blog1 blog2 blog3 blog4 blog5 blog6 blog7 blog8 blog9 blog10 blog11
NAN ex26-ans leetcode-1480 video blog1 blog2 blog3 blog4 blog5 blog6 blog7
live code live-code-inheritance video1
video2
blog1 blog2
NAN ex27-q1-q2-q3-ans leetcode-2798 blog1
NAN ex27-q4-ans blog
NAN ex28-ans (optional) video (optional) blog
ex29-q1 ex29-q1-ans leetcode-807 blog1 blog2 blog3 blog4
ex29-q2 ex29-q2-ans leetcode-1329
ex30 ex30-ans leetcode-2194 blog1 blog2 blog3 blog4 blog5 blog6
NAN ex31-ans leetcode-1748
leetcode-535
leetcode-1941
leetcode-136
blog1 blog2 blog3 blog4 blog5
NAN ex32-q1-ans leetcode-2610 video blog
live code live-code-nested-class leetcode-1859 blog1 blog3
NAN ex32-q2-ans leetcode-1365 blog1 blog2
NAN ex33-ans blog
NAN ex35-q1-ans
ex35-q1-extended
video blog
NAN ex35-q2-ans-1
ex35-q2-ans-2
ex35-q2-ans-3
leetcode-1636 blog1 blog2
NAN ex36-ans
ex36-extended
leetcode-1773 video1
video2
blog1 blog2
live code live-code-adaptor
NAN ex37-ans leetcode-20 blog
NAN ex38-q1-ans leetcode-844 blog1 blog2 blog3 blog4
NAN ex38-q2-q3-ans leetcode-150 blog1 blog2 blog3 blog4 blog5 blog6 blog7 blog8
NAN ex40-ans leetcode-2215 video blog1 blog2 blog3 blog4 blog5 blog6 blog7

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.

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.

  • Chaque groupe sera formé de 4 à 5 étudiants.
  • Vous devrez rendre un livrable le ?? novembre à 23h59 au plus tard (!) sur: “Chaoxing Plateform” - Section Homework (作业).

Project description:

Project description in pdf

Forming teams:

https://docs.qq.com/doc/DT1R1RFdJdFRSUHVw

提交项目

  • 超星平台-作业-Projet
  • 将 pdf文件(文件里面包含视频 或/及 其bilibili链接)、代码文件夹(未压缩),放在同一个文件夹(文件夹命名为 Projet,注意没有 ‘c’ 字母, ‘P’字母大写),然后将Projet文件夹压缩成一个 zip 文件(命名为 Projet.zip,注意没有 ‘c’ 字母, ‘P’字母大写)。然后上传 zip 文件作为本题的答案即可。
  • 每个小组只需要一个人提交就行。小组成员不需要来自同一个班级。
  • 提交后检查一下网页的显示:

正确示例:

往届学生优秀 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

By default, you agree to share your project videos on this platform. If you disagree, tell me in private chat.

往届学生优秀 project 作品 (rapport pdf)

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.

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):

  • 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.

Answer sheet for exams:

  1. 答题纸单面答题。因为答题纸需要扫描发给法国老师。
  2. 每张答题纸最上面写上学号、中文姓名、姓名拼音。
  3. 每张答题纸最上面写上序号,比如 1/4, 2/4, 3/4, 4/4。
  4. 法方老师反馈,考试的时候卷面分占有一定比值(10%)。请大家答题时保持清晰、整洁。可以适当使用涂改液或者修正带(在不影响扫描的前提下)。

Failing rate

Despite the efforts from the prof side, historically, the failing rate of LO02 has been very high.

  • 2020: ~25% failing rate
  • 2021: ~30% failing rate
  • 2022: ~30% failing rate
  • 2023: ~22% failing rate

关于重修

重修的同学,去年项目分数是可以保留的,也可以今年重新做,刷新分数。

不过,公平起见,重修的同学的往年项目分数不会透漏。是否重做项目,大家自己把握。

学分替代

具体细节不详,如有需要,可以咨询教务处。

Asking Questions

使用 Gitee Issue 提问

By default, you should ask questions via Gitee Issue. Here is how:

Principe

Here is the principle for asking questions:

ChatGPT/Google First, Peers Second, Profs Last.

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 :

Office visit

Office visit is NOT welcome unless you make an appointment at least one day in advance.

Misc

Textbooks, slides, exercises in pdf

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:

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.

Books

See this branch: books

  • 剑指Offer
  • 编程之美-Page 169
  • 编程珠玑-Page 53
  • 编程珠玑-Page 175

Bilibili Videos

🔨 Install CLion and Git

Clion 2020.1 版本无法激活的同学,可以尝试下载 CLion 2022.2,然后激活:https://docs.qq.com/doc/p/41f1c0098815f3d0a6cbb3f9ad2b2312de4b43b3?dver=3.0.0

🚀 How to manipulate with git during TD sessions
How to push your code to GitHub
🐛 🐛 🐛 🐛 Debug

For debugging with CLion, watch this:

有红色波浪线,不能编译,那就不能 debug。

How to clone this repository

Method 1:
git clone https://gitee.com/lundechen/cpp.git 

Then open the cpp folder with CLion.

Method 2:

In CLion, click VCS -> Get From Version Control, input the url:

https://gitee.com/lundechen/cpp.git 

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/

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!

Zen of C++

https://www.reddit.com/r/cpp/comments/48obqd/what_is_the_rcpp_c_equivalent_of_the_the_zen_of/

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!

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:

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
Example 2

```static``` will render as static.

`static` will render as static as well.

Detecting memory leak with Linux tools [optional]

valgrind --tool=memcheck <your_app> <your_apps_params>

Valgrind can be used directly in CLion:

g++ v.s. CMake v.s. makefile [optional]

gcc is used to compile C program while g++ 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
git remote add github <YOUR-SSH-OR-HTTPS-REPO-URL>
3. push the branch to GitHub repo
git checkout -b <NEW BRANCH NAME>
git add .
git commit -m "<SOME MESSAGE>"
git push github <NEW BRANCH NAME>

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?

  • Because it’s fun.

Keep things in perspective

Some programmers argue that “Object Oriented Programming is Inherently Harmful”:

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

Life is short. Have fun.

关于

Shanghai University LO02 C++ Course

466.3 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号