Starting my developer career I experienced a really good interaction with the team where we were proposed to read a book and weekly we discuss about it. We're currently at the 14th chapter - Successive Refinement
This chapter is interesting as it is a show case and validates almost all rules said up to now. Uncle Bob - writer friendly nickname - brings his engineering process from a class that handles string of arguments and extract from the text booleans, sub strings and integers.
At the start, only booleans were being extracted and validated from the string.
At this point, even though the code is in Java, we can see clearly somethings taught by the book very important to code structure and readability:
- Well named/positioned variables/methods;
- Methods intent very clear;
Cohesion is very good, also vertical distribution, for example, when a function calls another, this other is written next to its usage.
Following a comprehensive sequence and clearly naming pattern allows the reader to understand what’s being done and prevent the need to “lost scrolls” through the code looking for anything. A well written prose, as it’s called on the book;Error handling is well defined and messages shows clearly what is wrong;
When he starts to handle more types, the code starts to grow and repeat it self with few changes. Here he emphasizes how a programmer needs to know when it’s time to stop adding features and start some refactoring, he says:
→ Many different types, all with similar methods — that sounds like a class to me
So he starts to separates responsibilities as types handling and content validations to another class, and so on.
I though as very rich conclusion, even tough reading pages and pages of Java code without IDE highlight was hard, the message was clear.
While reading, I took note of concepts learned and I intend to bring some show cases too about it using newer technologies other them Java. I want to build a knowledge base with concepts from the book, coming soon.
Top comments (0)