C. Keith Ray

C. Keith Ray writes about and develops software in multiple platforms and languages, including iOS® and Macintosh®.
Keith's Résumé (pdf)

Wednesday, June 12, 2019

Advice to a young programmer

Someone on Quora asked:

"I make so many mistakes while coding. All code reviews get lot of review comments and sometimes it’s create regression on the system too. Am I not good for developer role?"
My answer:

Sometimes review comments are more about the commenter than the code or you: they're telling you how THEY would write the code rather than evaluating the code on its own merits.

On the other hand, causing regressions is not at all desireable. Why didn't the reviewers catch the source of the regression? Did you have tests you should have run before checking in the code? What could you have done to find the side-effects of your changes?

Keep a journal: what did the code look like before the review and after changes required or requested by the reviewers. Do you understand why the "after" code is better? Are there things you didn't know that you needed to do?

Also journal your bugs and bug-fixes. When you make a fix, did you look for other places in the codebase with the same or similar problems? Can you fix that code too?

You can learn most rapidly if you pair-program. (Google it. There's a book on that subject.) Can you pair-program bug-fixes or new code with a partner? As a junior programmer, you should "drive" while the experienced programmer "navigates". 

Or try Mob Programming: the whole team can learn and code at the same time. You can also pair program with testers (to replicate and fix a bug) and/or analysts/designers (implementing new features), though they will have less to teach you about coding.

Software development is exacting. One semi-colon in the wrong place can create a  bug that may not show its effects for years. That bug could be harmless or it could cost multiple companies millions of dollars. In this paragraph, I used "its", which is the possessive version of "it". Many people, whether native English speakers or not, would have incorrectly used "it's", which is the contraction of "it is". You have to have the same level of knowledge for your programming languages and development tools as I have for English.  (Also, it's a rule that whenever someone writes about correct English grammar or spelling, they will make a mistake or two.)

Beware of cutting and pasting code from Stack Overflow: a lot of it is wrong or out of date. You need to understand why the code offered in SO is right or wrong for your situation.

If being extremely detail-oriented and knowledgeable about your code is too hard for you, then programming may not be your best career choice. I don't want to say that programming has to take over your life, but mastering it will take commitment and time. 

Comedian Bob Newhart joked that as an accountant, he was happy getting the books almost right. He said his bosses didn't find that funny. So he quit accounting and became a famous stand-up comic/actor.


Wednesday, June 5, 2019

Writing Exercise - Action genre

This is a writing exercise. It is fiction. It is not meant to be scientifically accurate. I'm pretty sure I've got several details wrong.

Tah’dt and Zhei’Sun were tracking an immature mammoth through the brush when the wind shifted, bringing the acrid scent of a saber-toothed tiger to their attention. It was very likely the female tiger known to the tribe as Less Lee, hunting the same mammoth. Less Lee had killed Zhei’Sun’s mate, B’Uff Eee, when she was hunting small game earlier that summer — it wasn’t afraid of The People. If they got in the way of Less Lee hunting the mammoth, she would be happy to kill them and the mammoth, feeding her mate, sisters, and adolescent cubs for days.

Tah’dt peered around him. Broken branches and underbrush led deeper into the forest on his right. The mammoth was foraging for young shoots, making a lot of noise in the process, but there were few fresh shoots this late in the summer. Tah’dt and Zhei’Sun had stayed on higher ground, off the mammoth’s trail. There! A glimpse of tiger stripes in the underbrush confirmed the tiger’s presence. It was on the other side of the trail, and closer to it. It was a mature saber-tooth, nearly as tall walking on all fours as B’Uff Eee’s mother was standing erect, who had been tall for a woman. It probably weighed as much as four well-fed men. Its claws would be as large as Tah’dt’s hands, and its incisors as large as Zhei’Sun’s head. Zhei’Sun had a big head.

In previous times, when The People were well-fed, they would have abandoned the hunt. Better to let the tiger have the young mammoth than to lose seasoned hunters. Coming home empty-handed from a hunt was bad for a hunter’s reputation, but in times of plenty, it would merely be a source of jokes. This summer had been much hotter than normal. The river was down to a trickle and and their food plant had died. Prey animals were hard to find. Coming home with nothing to eat would mean death for weaker members of the tribe. Tah’dt’s two-year-old girl-child was already just skin-and-bones. They could not give up this hunt.

Tah’dt pointed the tiger out to Zhei’Sun, and signed for him to wait for the tiger to advance out of sight. They might be able to kill the tiger while it was attacking the mammoth, hopefully after it had wounded it. Then there would be enough food for a while, and removing a predator from the area also meant more food for The People. They waited with stillness of experienced hunters, not even flicking flies away from their sweat-soaked hair. The mammoth herd, while out of sight, could be heard occasionally, as the males signaled their “all is safe” sound. Tah’dt devised a plan. He whispered it to Zhei’Sun. He nodded agreement and started quietly making his way back to the tribe’s shelter.

Clutching his spears, Tah’dt crept along the high path, keeping the young mammoth’s path in sight. The wind stayed favorable; it seemed likely that the tiger hadn’t sensed him, yet. Eventually he saw the mammoth. It was in a shady area where a creek used to run through the forest. It was tearing up the underbrush with its tusks, grabbing green plants with its trunk. Tah’dt looked for the tiger. It had to be near, but he didn’t see it. Would his tribe’s men get here in time?

A bird call came from where he had been. Tah’dt looked and saw Zhei’Sun signing that the men were in place. Tah’dt signed them to wait. Before he knew it, the saber-tooth tiger had leapt from concealment onto the mammoth. They began to struggle fiercely. Tah’dt signaled Zhei’Sun, and they all advanced with their short spears in one hand, their long spears in another, and their daggers hung in their belts. They surrounded the shady area and waited for an opening to attack the tiger and the mammoth.

The mammoth was old enough to match the tiger in weight, but it was inexperienced and fought poorly. Soon it was bleeding from several slashes. As it struggled for its life, Tah’dt and some others threw their short spears at the tiger. Their hits drew blood. The tiger hissed and rounded on them, but they kept out of its reach, brandishing their long spears. 

Zhei’Sun cried out when another saber-toothed tiger pounced on him from a tree! It was one of Less Lee’s sisters! It slashed his neck with its long teeth and he was dead. Tah’dt and the other men backed away but didn’t run away. If they kept close together they could maybe survive this.

The young mammoth whimpered as it continued to struggle against Less Lee on its back. The tiger was suffocating the mammoth because it wasn’t able to slice through the thick coat over the mammoth’s throat. It was still alive but it had no chance against two tigers.

Tah’dt handed his long spear to the man next to him, who was shocked he would disarm himself like that. He took a breath, and put both hands over his mouth. Tah’dt made the distress call that the young mammoth in front of his should have been making. He did it again and again while his tribesmen brandished their long spears.

They heard the rumble and saw the brush shaking as two adult mammoths burst onto the scene. They were a male and a female; they might even be the young one’s sire and dam. The tiger on Zhei’Sun fled immediately. Less Lee was encumbered long enough for the male to attack her, first with a tusk, then pulled off and thrown by a trunk. 

Tah’dt and his men threw their spears into Less Lee, mortally wounding it. The female adult mammoth slashed Less Lee with a tusk. The tiger coughed and died.

Tah’dt and his men pulled out their daggers. At his signal, they moved back into the underbrush until they were out of sight of the mammoths.

The female mammoth caressed the young one, but its wounds were too much; it would be dead soon.

When darkness descended, Tah’dt and his men came back, bearing torches. They prayed thanks for the gift of food, and began butchering the mammoth, the tiger, and their friend. The People would live for a while longer.