Avoiding Common Coding Pitfalls During My Amazon Internship
Written on
Identifying Key Coding Mistakes
Last year, I had the opportunity to intern as a Software Engineer in the Business Division at Amazon. It was my first experience in a tech company, which made me eager to learn as much as possible. While I’ll share the full story another time, today I’d like to focus on the coding habits I found challenging to overcome during my internship.
Understanding Code Abbreviation
One recurring issue I faced was my tendency to abbreviate code, which I didn’t realize was causing confusion. My team’s senior engineer frequently pointed out this habit during code reviews, advising me to avoid abbreviating variable and class names.
For instance, I would use shorthand like:
- “res” or “resp” for Response
- “sesh” for Session
- “conn” for Connection
- “err” for Error
- “prod” for Product
- “ctx” for Context
This highlighted the importance of clarity in coding. In a diverse team like ours, assumptions about what is obvious can vary widely. While it might only take a moment to decipher an abbreviation, ensuring clarity is crucial for team collaboration. Now, I strive to make my code as readable as possible.
Don't Make Assumptions
Assumptions can lead to misunderstandings. At Amazon, our team comprised individuals from various countries, each with their own coding styles. This experience taught me that even what seems clear to one person may not be so to another.
The Pitfalls of Excessive Commenting
Surprisingly, my team pointed out that I was overusing comments in my code. Initially, I thought that providing detailed comments was a good practice, but I learned that code should be self-explanatory. While it’s beneficial to include a brief comment for classes, excessive commenting can detract from code clarity.
Avoiding Overloaded Functions
Another mistake I frequently made was cramming too many tasks into a single function, violating the Single Responsibility Principle. This often led to the need for numerous comments. I learned that breaking responsibilities into smaller, manageable functions significantly enhances readability and eases debugging.
The Role of Design Patterns
When I started, I wasn’t familiar with design patterns, which posed a challenge. After some research and guidance from my lead engineer, I explored "Head First Design Patterns," which helped me understand when to apply various patterns effectively.
Cautions Against Overusing Patterns
Excited by my newfound knowledge, I sometimes overused design patterns, even when they weren’t necessary. This can lead to reduced flexibility and unnecessary complexity in code. I learned that while design patterns are valuable tools, they should be applied judiciously.
Reflecting on Coding Habits
What coding habits have you struggled to overcome? I'd love to hear your experiences in the comments!
The video, "How I got an Amazon Internship (after 6 months of failure)," shares insights on overcoming challenges during the internship journey.