程序员的自我修养

工程师素养

工程师价值观

编程思想

编程语言的设计和思想
面向对象编程(OOP)

In this chapter, we
• Introduce you to object-oriented programming;
• Show you how you can create objects that belong to classes in the standard Java library;
• Show you how to write your own classes.

If you do not have a background in object-oriented programming, you will want to read this chapter carefully.

Thinking about object-oriented programming requires a different way of thinking than for procedural languages.

The transition is not always easy, but you do need some familiarity with object concepts to go further with Java.

For experienced C++ programmers, this chapter, like the previous chapter, presents familiar information;

however, there are enough differences between the two languages that you should read the later sections of this chapter carefully.

You’ll find the C++ notes helpful for making the transition.

Introduction to Object-Oriented Programming Object-oriented programming (or OOP for short) is the dominant programming paradigm these days,

having replaced the “structured,” procedural programming techniques that were developed in the 1970s.

Java is totally object oriented, and you have to be familiar with OOP to become productive with Java.

An object-oriented program is made of objects. Each object has a specific functionality that is exposed to its users, and a hidden implementation.

Many objects in your programs will be taken “off-the-shelf” from a library; others are custom designed.

Whether you build an object or buy it might depend on your budget or on time.

But, basically, as long as objects satisfy your specifications, you don’t care how the functionality was implemented.

In OOP, you don’t care how an object is implemented as long as it does what you want.

Traditional structured programming consists of designing a set of procedures (or algorithms) to solve a problem.

After the procedures were determined, the traditional next step was to find appropriate ways to store the data.

This is why the designer of the Pascal language, Niklaus Wirth, called his famous book on programming Algorithms + Data Structures = Programs (Prentice Hall, 1975). Notice that in Wirth’s title, algorithms come first, and data structures come second. This mimics the way programmers worked at that time.

First, they decided the procedures for manipulating the data; then, they decided what structure to impose on the data to make the manipulations easier.

OOP reverses the order and puts data first, then looks at the algorithms that operate on the data.

For small problems, the breakdown into procedures works very well. But objects are more appropriate for larger problems.

Consider a simple web browser. It might require 2,000 procedures for its implementation, all of which manipulate a set of global data.

In the object-oriented style, there might be 100 classes with an average of 20 methods per class (see Figure 4–1).

The latter structure is much easier for a programmer to grasp. It is also much easier to find bugs. Suppose the data of a particular object is in an incorrect state.

It is far easier to search for the culprit among the 20 methods that had access to that data item than among 2,000 procedures.

英文能力

listen, speak, read and write.

问题和表达

Coding 能力

Coding

规范
基础

算法

  • 基础算法题。其中有大量的算法题,解这些题都是有套路的,不是用递归(深度优先 DFS,广度优先 BFS),就是要用动态规划(Dynamic Programming),或是折半查找(Binary Search),或是回溯(Back tracing),或是分治法(Divide and Conquer),还有大量的对树、数组、链表、字符串和 hash 表的操作。通过做这些题能让你对这些最基础的算法的思路有非常扎实的了解和训练。对我而言,Dynamic Programming 是我的短板,尤其是一些比较复杂的问题,在推导递推公式上总是有思维的缺陷(数学是我的硬伤)。做了这些题后,我能感到我在动态编程的思路上受到了很大的启发。
  • 编程题。比如:atoi,strstr,add two nums,括号匹配,字符串乘法,通配符匹配,文件路径简化,Text Justification,反转单词等,这些题的 Edge Case 和 Corner Case 有很多。这些题需要你想清楚了再干,只要你稍有疏忽,就会有几个 case 让你痛不欲生,而且一不小心就会让你的代码写得又臭又长,无法阅读。通过做这些题,可以非常好地训练你对各种情况的考虑,以及你对程序代码组织的掌控(其实就是其中的状态变量)

数据结构

网络模型

计算机原理

操作系统

  • 用这些系统知识操作一下文件系统,实现一个可以拷贝目录树的小程序。
  • 用 fork / wait / waitpid 写一个多进程的程序,用 pthread 写一个多线程带同步或互斥的程序。比如,多进程购票的程序。
  • 用 signal / kill / raise / alarm / pause / sigprocmask 实现一个多进程间的信号量通信的程序。
  • 学会使用 gcc 和 gdb 来编程和调试程序(参看我的《用 gdb 调试程序)。
  • 学会使用 makefile 来编译程序(参看我的《跟我一起写 makefile十一十二十三十四)。
  • Socket 的进程间通信。用 C 语言写一个 1 对 1 的聊天小程序,或是一个简单的 HTTP 服务器。

操作系统处理大并发请求的问题(世界级难题):The Secret To 10 Million Concurrent Connections -The Kernel Is The Problem, Not The Solution

实现一个 telnet 版本的聊天服务器,主要有以下需求。

  • 每个客户端可以用使用telnet ip:port的方式连接到服务器上。
  • 新连接需要用用户名和密码登录,如果没有,则需要注册一个。
  • 然后可以选择一个聊天室加入聊天。
  • 管理员有权创建或删除聊天室,普通人员只有加入、退出、查询聊天室的权力。
  • 聊天室需要有人数限制,每个人发出来的话,其它所有的人都要能看得到。

实现一个简单的 HTTP 服务器,主要有以下需求。

  • 解释浏览器传来的 HTTP 协议,只需要处理 URL path。
  • 然后把所代理的目录列出来。
  • 在浏览器上可以浏览目录里的文件和下级目录。
  • 如果点击文件,则把文件打开传给浏览器(浏览器能够自动显示图片、PDF,或 HTML、CSS、JavaScript 以及文本文件)。
  • 如果点击子目录,则进入到子目录中,并把子目录中的文件列出来。

实现一个生产者 / 消费者消息队列服务,主要有以下需求。

  • 消息队列采用一个 Ring-buffer 的数据结构。
  • 可以有多个 topic 供生产者写入消息及消费者取出消息。
  • 需要支持多个生产者并发写。
  • 需要支持多个消费者消费消息(只要有一个消费者成功处理消息就可以删除消息)。
  • 消息队列要做到不丢数据(要把消息持久化下来)。
  • 能做到性能很高。
设计
编程范式

六个编程范型将改变你对编程的看法

Thinking more before coding.

软件设计

####### 设计原则

Coding Language
C and C++
Java
Go

Review

单元测试

工程师需要注意的安全问题

软件测试

监控

认识自己

酷壳-CoolShell.程序员如何把控自己的职业

Google SRE评分卡

0 – 对于相关的技术领域还不熟悉
1 – 可以读懂这个领域的基础知识
2 – 可以实现一些小的改动,清楚基本的原理,并能够在简单的指导下自己找到更多的细节。

3 – 基本精通这个技术领域,完全不需要别人的帮助
4 – 对这个技术领域非常的熟悉和舒适,可以应对和完成所有的日常工作。

  • 对于软件领域 – 有能力开发中等规模的程序,能够熟练和掌握并使用所有的语言特性,而不是需要翻书,并且能够找到所有的冷知识。
  • 对于系统领域 – 掌握网络和系统管理的很多基础知识,并能够掌握一些内核知识以运维一个小型的网络系统,包括恢复、调试和能解决一些不常见的故障。

5 – 对于该技术领域有非常底层的了解和深入的技能。

6 – 能够从零开发大规模的程序和系统,掌握底层和内在原理,能够设计和部署大规模的分布式系统架构
7 – 理解并能利用高级技术,以及相关的内在原理,并可以从根本上自动化大量的系统管理和运维工作。
8 – 对于一些边角和晦涩的技术、协议和系统工作原理有很深入的理解和经验。能够设计,部署并负责非常关键以及规模很大的基础设施,并能够构建相应的自动化设施

9 – 能够在该技术领域出一本经典的书。并和标准委员会的人一起工作制定相关的技术标准和方法。
10 – 在该领域写过一本书,被业内尊为专家,并是该技术的发明人。

SRE 技能表

– TCP/IP Networking (OSI stack, DNS etc)
– Unix/Linux internals
– Unix/Linux Systems administration
– Algorithms and Data Structures
– C/C++
– Python
– Java
– Perl
– Go
– Shell Scripting (sh, Bash, ksh, csh)
– SQL and/or Database Admin
– Scripting language of your choice (not already mentioned) _
– People Management
– Project Management

参考资料

酷壳-COOLSHELL

极客时间-左耳听风-陈皓

Object-Oriented Programming Concepts

Introduction to Object Oriented Programming Concepts (OOP) and More