This is a reminiscent summary of learning experience, extracted from the author ZT’s (now a senior software r&d engineer of Xiaomi Youpin, mainly responsible for the infrastructure construction of iOS client and cross-terminal development) own mobile client development experience, and strives to provide a platform, language independent perspective and share some learning experience.

Learn on the job — start with reality

At the beginning of the Thatched cottage

When I first started my internship, I was a beginner and didn’t know anything. I started by reading code and fixing bugs — I couldn’t even tell what was good code from what was “broken” code (even if it worked). In the process of bug fixing, I gradually got familiar with the structure of the whole project and became more proficient in the language of development, so my tutor gradually began to assign business requirements to me. At this point, I was in the “copycat” phase — taking code from someone else on the project and copying it to fit my work.

Effective Books — “Best Practices”

After learning the grammar preliminarily and realizing simple requirements, I further read the corresponding Effective series of books (such as Effective Java for Java and Effective Objective-C 2.0 for Objective-C). I read it as if the author (usually a seasoned programmer) was teaching me how to code and explaining the reasons for a particular way of writing. I learned a lot from it and gradually improved my code quality and programming skills.

The series is a summary of practices that can easily be applied to your daily work. There may be some chapters in the book that you cannot understand temporarily (for example, the language features you have not touched yet). You can skip them by looking at them briefly and leaving an impression. With the accumulation of coding experience and the increase of proficiency, you may understand them after a period of time.

Note: Since the invention and popularization of a programming language, countless predecessors and peers have explored it in practice. With the accumulation of time and experience, they have accumulated a set of “best practices” suitable for the language, some of which are language-independent and some of which are strongly related to language features. It is important to note that “best practices” are not a golden rule, a magic formula or a silver bullet. They are simply “warm tips” that have been tested in most scenarios and can be analyzed on a case-by-case basis when they fail.

Cultivation of thinking — Reconstruction and Design mode

With version iteration, demand changes, gradually found a bit overwhelmed, even improve a function, change is very painful, there is a single point, may even lead to the function of unrelated bugs, often appear “demand amount of code itself is not big, to prevent affect other function code is heavy”. I realized something had to be wrong and it wasn’t supposed to be like this.

I described my confusion to my tutor, who pointed out that my problem was “common for novices, focusing only on partial solution implementation rather than overall solution design”. He suggested that I learn refactoring and design patterns, which are respectively used to “improve the design of existing code” and “implement new functions in a more systematic way”.

Refactor: Keep your feet on the ground

In terms of refactoring, I only read “Refactoring: Improving the Design of existing Code”. Although the examples are described in Java, it does not affect the understanding of concepts and application. Because the book itself is more practical, I can read and use it quickly.

Of course, there is another problem with refactoring: how do you make sure that refactoring is consistent and that you don’t introduce new bugs? A common solution is to use unit tests, not for small refactorings; In some scenarios, if it is not convenient to do unit testing, we must fully test and then put it online.

You can also read Refactoring: Improving the Design of Existing Code (Java version 1), JavaScript version 2 (JavaScript version 2), Code Cleanliness (Code Cleanliness: Professional Programmer)

Design pattern: Strategically positioned

In terms of Design Patterns, my advisor wanted me to read Head First Design Patterns as soon as possible so that he could communicate with me at a more abstract level rather than having to refer to concrete implementations, but he also stressed the importance of not over-designing. It’s not good to try to copy Design Patterns whenever you see them. After reading it, I felt I had no idea how to use it, so I turned to several other books on Design Patterns called Design Patterns Explained: Design Patterns: A New Perspective on Object Oriented Design Elements of Reusable object-oriented Software, Agile Principles, Patterns, and Practices in C#, Just a little bit more understanding of what design patterns are and when to use them… Later, through reading the project source code, I further confirmed that there was no deviation in my understanding of design patterns, and gradually mastered several common patterns.

In fact, you don’t have to read all of these books at once, but Head First Design Patterns, combined with project code, open source code (and other people’s articles), can be understood over and over again.

summary

Like Effective series, reconstruction is a direct summary of skills, which can be used as a reference book. Design mode is the “best practice” of design in most cases. It is more theoretical. After reading, it still needs to rely on daily accumulation and comprehension to master it, which is a long process.

I personally find refactoring and design patterns to be useful tools that are worth learning and practicing. Using them well can make your code more elegant, maintainable, and transferable (even in different languages). Overuse of design patterns, however, increases project complexity and is difficult to maintain.

There are also three stages in the learning process:

1. Don’t know what refactoring/design patterns are

2. You see code and you want to refactor it, and you want to apply a design pattern

3. Think about when to refactor and when to use the right design pattern

In a word, these two tools can be used, but it is best to learn to use; Use is discouraged everywhere and only when necessary.

Recursion learning – Ask yourself more why

One obvious feature of studying at work, as opposed to studying in your spare time, is that there is a limited amount of time for studying — after all, work is scheduled. After reaching a certain level of proficiency, you may have finished your tasks ahead of time. How do you take advantage of the extra time? My habit is to think about whether there is room for improvement and reconstruction of the code in this requirement, check some assumptions made in the early stage under uncertain circumstances, and read and organize other codes related to this requirement.

Example: a home floor in the mall APP

Take the requirement “achieve a floor” as an example:

1. Refer to other existing floors, imitate the writing, according to the requirements of the floor effect, to meet the test standards

2. Think about whether the code you implemented can be improved or reconfigured (when you are not experienced or skilled in reconstruction, or when the function is complex, it is important to implement the function first and then reconstruct it)

3. For complex requirements, add comments to key steps and write implementation documents for subsequent maintenance

4. Think about how the floors you implement are loaded and rendered, and what the method call stack looks like

A. Check whether there are documents and diagrams (class diagrams, flow diagrams, sequence diagrams) prepared by other colleagues

B. If there is, then combined with documents, charts to read the source code, you can get twice the result with half the effort

C. If not, try to read the source code in the process of synchronization, convenient for the future of their own convenience to others

D. Finishing process:

I. Sort out the classes and interfaces involved in realizing floors (class diagram) II. Sort out how floors are laid out and how floor spacing is realized (flow chart, sequence diagram) III. Sort out how floors acquire, load and cache data (flow chart, sequence diagram) iIII. How are statistics collected and reportedCopy the code

5. After sorting out the floor itself, you can further consider that clicking the floor will trigger the page jump, so how to realize the page jump and routing?

A. How to register a page?

B. How to switch to the page?

C. How to do the dynamic effect of page hopping?

6. How are the encapsulated components used in the implementation of floors implemented?

7. Some floors are dynamic floors, how is that achieved?

That is, ask yourself more than just completing the task, and explore the principles and solutions behind it. On the one hand, I can grasp the structure of the whole project more quickly. On the other hand, I can broaden my thinking and exchange what I have and need through reading. In the process of combing, I can draw some class diagrams, sequence diagrams and flow charts, which can help me understand better and recall quickly in the future without having to turn over the code from scratch, so as to improve my work efficiency in the future.

The above example, starting with the implementation of a floor requirement, extends a series of questions that, like recursion (tentatively called “recursive learning”), acts as a “cue” (recursive stack) in and of itself, helps to deepen the understanding of the entire project. By starting with several different requirements or function points and exploring them in this way, you can form a web of these “threads” to get the overall picture of the project. In this process, it is inevitable to be accompanied by the change of method -> class -> function module -> application layer -> the whole application cognitive level, which is reusable and transferable and applicable to other projects.

Learn new knowledge

Sometimes when you need to realize the requirements, you need to use knowledge points that you have not yet mastered, such as string matching to use regular expressions, customer service/after-sales message storage to use the database, etc. At this time, you can also carry out recursive learning — of course, first learn to meet the needs of the work, and then use the rest of the time to recursively learn after completing the quality and quantity guarantee.

The “recursion” here generally refers to the “known-unknown stack” formed by other unknown knowledge points involved in a certain knowledge point. When learning, of course, you can learn in two ways of “depth first” and “breadth first”, and you can choose to meet your own habits.

For example, with regular expressions, the learning process might look like this:

Learn the “syntax” of regular expressions

2. How to write a regular expression that meets the requirements of the job

3. Completed work requirements, reconstruction, etc., to meet the standards of testing

4. Solve the puzzle of writing regular expressions (why some forms match differently than expected)

5. Explore the principles of regular expressions (formal languages and automata Theory)

Pause and continue recursion

Recursion learning may find too much unfamiliar content, in the case of a tight schedule will feel great pressure, irritability, resistance, boredom and other negative psychology, affecting learning efficiency. At this point, we can not rush to in-depth study, only learn just enough to use, temporarily do not explore those unknown areas, the unknown content as a “library”, not concerned with its specific implementation, only concerned with the way of calling its “interface”; At the same time, the learning progress will be “archived”, after finishing the work/feeling calm, and then continue to master one by one, layer by layer recursion.

Stop the recursive

Limited time and energy, it is impossible to learn recursively indefinitely, how to determine the stop point? I have strong curiosity, so I may not want to learn at one time, stop if I don’t understand (I don’t have enough mathematical foundation), or stop learning just a little bit.

Generally, it can be determined according to the following rules:

1. Try to fully understand and master each layer of learning

2. If you can understand and master more than 80%, you can proceed to the next level of learning (generally, the further you go, the lower the level of understanding and mastery is).

3. Less than 80%, you can stop, make a record of the points you have mastered “archive”, learn other knowledge points

4. As time goes by, your understanding may be deepened. Recursively learn from other knowledge points to previous records, review again to confirm whether you can continue to learn

Study outside of work: Books are seldom used

Review/Supplementary learning materials – Combining theory with practice

Computer major students go to school to learn a lot of courses, but at that time may learn a little knowledge, rote memorization, and even pass long live; Non-computer majors may not even have read the relevant textbooks. While none of this affects work in the short term, in the long run, what is owed always needs to be paid back.

The advantage of teaching materials and classic books lies in the establishment of a systematic and comprehensive knowledge system, connecting all aspects of knowledge points, making up for the acquisition of relatively fragmented knowledge points in recursive learning, and accelerating the formation of knowledge network. And with the blessing of working experience, compared with the half-knowledge when going to school, at this time to read textbooks, classic books, there must be new harvest.

As in the regular expression example above, it is a process of moving from working practice to theory. In this process, we will find that compilation principle has been involved in the textbook, at this time, we will have a sense of “theory with practice”, which not only deepens the impression of theory, but also improves the practical ability.

If the skills used in daily work are compared to the moves in martial arts novels, then the teaching material involved in the computer major is internal skills — only skills without internal skills, easy to become a boxing; Only repair internal work do not repair moves, strong so not out; Inside and outside repair, can play the maximum power.

Books include but are not limited to the following:

  • Composition principle
  • The operating system
  • Data structures and algorithms
  • network
  • architecture
  • Compilation principle
  • Database system
  • Mathematics (Discrete Mathematics, Linear algebra, probability statistics, etc.)

These books take a whole slice of time (at least one continuous hour) to read and digest, and are perfect for weekends and holidays.

Summary and acknowledgements

This paper records the author’s experience of reading Effective books, learning reconstruction and design patterns under the guidance of the tutor, and “recursive learning” in daily work, as well as the effect of reviewing classic books with the growth of work experience.

Thank you for reading and I hope you found this article inspiring.

Thanks to my tutor Li Yuhua (Li Banxian) and other colleagues for their guidance and help along the way.