📜 ⬆️ ⬇️

Why would a developer scoff at his own code



Problem solved: 317 clicks fixed the error

In 1992, I considered myself the best programmer in the world. In my defense I can only say that then I just finished college (it was before the advent of the Internet) and lived in Boulder, Colorado, working for small companies - I read for great luck the opportunity to just hear about other programmers, not to mention to meet them.
')
In the end, I met a man named Bill O'Neill, who hired me as a contract programmer. He created a company with a rather non-original name Computer Research & Technologies, and we started working on various tasks together.

We were developing CRUD applications [Create, Read, Update, Delete is an application version with basic functions for creating, viewing, updating and deleting records in a database - approx. trans.] for business on Visual Basic and FoxPro under Windows 3.1 (and sometimes under DOS, since they had a premonition that the new-fashioned graphical user interface would stay with us for a long time).

Bill was the first professional programmer I ever worked with. What can I say, he was the first programmer in general, with whom I have ever worked. He gave me a technical task, according to him I wrote a program in Visual Basic and then gave it to Bill for verification. After that, he calmly explained to me that my code was no good.

A couple of examples:


I was surprised that the problem was not in the code itself. Sometimes he made comments to me about how I write and structure my code. I was afraid to give him my job to check. And gradually, through bitter experience, I learned that the most difficult thing about writing code is to exclude thousands of possible situations in which an application can work incorrectly: most of them depend on the user.

That was my first experience with the Mentoring System, and thanks to Bill, I learned to treat with deep respect the art of software development. I don't know what Bill is doing now, but wherever he is, I take my hat off to him. I didn’t always like what I was doing, but, having learned self-discipline in the process of testing (and “cracking”) my code, I certainly grew up as a developer.

Of course, you always want to shift your responsibility onto the shoulders of the mythical tester. If you are ever lucky enough to work with one of them, then you need to beware of professional testers. They are terrifying. Review the list of what “must be tested”, and you will immediately remember the worst that happened to you.

It seems to me that the starting point in a developer’s career is the moment when you realize that your main enemy is you yourself, and you can win only by accepting it. Act as if you are your worst enemy. Crush your interface. Crush your code. Mock your program.

This means that developers should have a good understanding of at least the most common mistakes that programmers usually make. You are the tester number 0. It is your duty.

First, consider the typical misconceptions of developers about the names proposed by Patrick McKenzie:

  1. Each person has only one canonical full name.
  2. Each person has only one full name that he uses.
  3. At the moment, each person has only one canonical full name.
  4. At the moment, each person has only one full name, which he uses.
  5. Each person has exactly N names, regardless of the value of N.
  6. The name of a person can be written in a certain number of characters.
  7. The names of people do not change.
  8. The names of people change, but only in a limited number of cases.
  9. Names of people are in ASCII.
  10. The names of people are written only in one encoding.

These are only the first 10 misconceptions. There are 30 more in the list. In addition, many more are recorded in the comments, if this is not enough for you. Maybe you will like the delusions of developers about the time?

  1. In the day 24 hours.
  2. In the month, either 30 days or 31 days.
  3. There are 365 days in a year.
  4. February is always 28 days.
  5. Any 24-hour period always begins and ends on the same day (or week, or month).
  6. A week always begins and ends in the same month.
  7. A week (or month) always begins and ends in the same year.
  8. The computer on which the program is running will always be in the GMT time zone.
  9. Well, let's say that it is not. But at least the time zone in which the program should work will never change.
  10. When the program is put into commercial operation, the time zone will not change for sure.
  11. The system time will always correspond to the exact local time.
  12. The system time will always correspond to a time that is not very different from local time.
  13. If the system time is displayed incorrectly, it will differ from the actual time by a certain number of seconds.
  14. The clock on the server and the client machine show one time.
  15. The clock on the server and the client machine shows about the same time.

Is there more? Of course there is ! There is even a whole extra list of what McKenzie forgot to include in that huge general list.



Catastrophic error: The user tried to use the program as intended. Possible actions: 1) destroy the computer; 2) cry

I think the scheme is clear. This is programming. We're doing all this for fun , haven't you forgotten?

But, as they say on TV: “Wait, there is something else!” Seriously, guys, where are you going? Come back. There are many other misconceptions that you should know about:




Mistakes of developers about geography


1. Geographical features have only one official name.

Some places use several languages ​​and, accordingly, several names that may differ from each other. Example - Geneva (German Geng, French Genève, Italian. Ginevra).

2. Geographical features in each language have only one official name.

Perhaps this is true for over-centralized states that never change their minds. My home is on a hill that has two names. Each of them depends on the map on which they are applied. On topographic maps (used by the military) it is called “Antlisberg” (Äntlisberg), while on the map of the city it is listed as “Entlisberg” (Entlisberg): both official names.

The names of Taipei streets in Latin used different types of transliteration depending on the quarter, so the official names of the streets in this city may vary.

3. Names of geographical objects comply with the rules for writing characters in the alphabet of a given country.

Geographical objects usually have very strange names, as they were often invented before the language appeared and its rules were fixed: therefore this statement is incorrect. For example, according to the rules of the German language, the sequence of letters "ue" is equivalent to "ü". This is true because the sound “üe” is no longer used in German. The name of one of the hills of Zurich is written as "Üetliberg" (Utliberg) (and pronounced accordingly).

4. Names of geographical objects can be written using the standard set of characters of the alphabet of the country

One of the islands of the archipelago Kerguelen (belonging to France) is recorded as “Île de Croÿ” (le-de-Croy). Most Frenchmen do not know how to enter the “” symbol.

5. Names of geographical objects can be written using the extended character set of the alphabet of the country

This would be fair if the streets were not named after foreigners with unusual spellings of names. In Paris, there is Béla Bartók street. In the French alphabet there is no symbol “ó”.

6. Geographical features have only one official address.

In Geneva, there is a dam located on the Rhone River and, accordingly, on the border of two states. Therefore, in Switzerland and France, it has different names.

7. Each state has its own capital

Not in Switzerland. The government of the country is located in Bern, but officially this city is not the capital.

8. Buildings cannot move

In Zurich, a building weighing 6,200 tons was moved 60 meters in order to build a railway .

9. The street address is always indicated in the mailing address.

In many remote locations in Europe, the name of a small settlement is enough to record the postal address.

10. The language code is always the same as the country code.

The code of Japan is recorded as “jp”, and the code of the Japanese language is “ja”.




Developers misconceptions about addresses


1. All addresses begin or at least contain the building sequence number.

Example: UK, WC2E 9DD, London, Royal Theater Covent Garden.

2. If the building has a sequence number, it will be recorded only in numbers.

Examples: EC2A 4BX1A, London, Bonhill Street, 4-5 and TS4 2HT, Middlesbrough, Egmont Road, 1A.

3. There are no buildings with serial number 0

Example: TS4 2HT, Middlesbrough, Egmont Road, 0.

4. At least there are no buildings with a negative sequence number.

Guy Chisholm gives the following example: RG14 7QS, Newbury, Meinus-One (Minusone) Priory Road.

5. A building cannot have both a name and an unusual number.

Example: HU5 2RD, Hull, Princess Road, 4-6, Idas Court.

6. If the building has a name, then it will not have a sequence number (and vice versa)

Example: UK, EC1N 8QX, London, Saffron Street, 60-66, Ziggurat Building, apartment 1.4.

7. On one street, only one building can have one sequence number.

The difference between SA18 3QJ, Ammanford, Taikrous, Ammanford Road, 50 and SA18 3YF, Ammanford, Llandibi, Ammanford Road, 50 is about 4 miles ( Google Maps ).

8. If there is a number in one of the address lines, it indicates the ordinal number of the building.

Great Britain, EC1N 8FH, London, Safron Hill, 44, Da Vinci House, apartment 18.

In addition, hotel rooms may be mentioned, as well as numbers of floors and blocks and organizations containing numbers in their names.

Adrien Pirar refers to an address in Japan containing 15 digits in 6 separate numbers (if you count the index as a single number, then 5).

The address is written in the format: 980-0804 (index), Miyagi-Ken (prefecture) Sendai-Shi (city) Aoba-Ku (district) Kokubuncho (subdistrict) 4-10-20 (subdistrict number, quarter number, building number) Sendai (building name) 401 (apartment number).

9. Then the first line in the address always begins with the sequence number of the building.

[it’s about address format in English-speaking countries - approx. transl.]

One of the exceptions: WC1V 7BN, London, High Holborn, 311-318, 3rd floor.

10. A building can have only one sequence number.

Benton Lam, as an exception, offers the following example from the Hong Kong Special Administrative Region. It indicates both the number of the road (14) and the number of the group of buildings (3): HKSAR, Island East, Taiku Van Road, 14, Citylase, 3, 15 / F.

11. The number of buildings on the street is the difference between the highest and lowest number of buildings

Tibor Schulz says that building numbers can be skipped, for example, when on the one side of the street there are buildings with even numbers and on the other with odd numbers; several buildings can have one number (as is the case with a newly constructed building) or one building can have several numbers at once.

Cyril Chepelov and Sami Lehtinen claim that in Antibes, France, and rural areas of Finland, some buildings are numbered depending on how far from the beginning of the road they are. For example, Long Road, 65, means that the building is located 750 meters from the place where the road begins.

12. If the building numbers on the right side of the road are even, then on the other side they should be odd

Cyril Chepelov says that on the Boulevard Theophile Syuer, Montreuil, Saint-Saint-Denis, France, on both sides of the road are only even numbers of buildings, as well as in some other cities and departments.

13. The name of the building cannot mention the number

Ben Tilly reports the address: USA, 02109, Boston, Massachusetts, Ten Post-Office Square - and it seems to be different from the address: USA, 02109, Boston, Massachusetts, Post-Office Square, 10.

14. At the very least, you can omit leading zeros.

Shaun Crampton reports on a house located at 101, Palo Alto Street, Alma Street, where rooms numbered 1 and 001 are located on different floors.

15. If there is building A on the street, then there should not be an Alpha building on it.

Douglas Perrot says that he lived in the block of one of the big hostels, in which there were blocks from A to Z, as well as Alpha, Beta, Gamma, Delta and Theta blocks. Mail and delivery services are constantly confused blocks A and Alpha. At that time, he lived at the address: 33613, Tampa, Florida, 14100 N 46 Street, Alpha, 39.

16. The name of the street can not include numbers

IP13 6SU, Woodbridge, Seven Gardens Borough, 8 (reported by Rafael Mankin).

17. Good, but numbers in street names are written in words, not numbers.

Jan Yongbum says that in the Netherlands the streets may contain numbers written in numbers, for example, Plain 1944 in Nijmegen.

18. If street and building names contain numbers, there should be a separator between them

Another example from Jan Yongbum: Gondel, 2695 in Lelystad means “Gondel district, 26, 95”.



Now I will not blame you if you decide to quit programming. But it seems to me that we need to do for each other what Bill did for me 20 years ago - to teach less experienced developers what a good programmer knows that he should pass his code through the toughest tests.

Otherwise, I guarantee you that others will do it. And when this happens, either competitors will overtake you, or because of you, the support service will have much more work. I don't even know what's worse.

PS More materials on startups in our blogs on Geektimes and Megamozg .

Source: https://habr.com/ru/post/271733/


All Articles