🧩 Why I stopped writing clever code. I started coding as a competitive programmer in high school. We were given five hours to solve five to ten hard algorithmic problems. Speed from thought to code matters. Code brevity matters. Even my typing speed matters. When I started working in a real company, I took a secret pride in writing short and clever codes, especially those magical one-liners. It made me feel quick and smart. I thought that it was a mark of expertise. But after the 17th "What does this line do?" DM, I felt that the problem was not my teammate's intelligence but rather my own code. If only me can understand and maintain the code, I haven't really built a system, I've made a puzzle 😂 🧑💻 I learned that readable code is about future-proofing my work: - The best code is written for humans first, computers second. - I'll thank myself 6 months later when I come back to fix a bug at 2am. - My new teammates will onboard faster. - Bugs are also caught earlier because the review is easier. ⁉️ How to make your code more readable? - Use clear, descriptive variable and function names. No more x, foo, or doStuff. - Write comments, but not essays. Explain the “why,” not the obvious “what.” - Break down complex logic into smaller, well-named functions. - Stick to consistent formatting and style. Clever one-liners may win you programming contests, but readable code wins you trust from your team 😉
Writing Functions That Are Easy To Read
Explore top LinkedIn content from expert professionals.
Summary
Writing functions that are easy to read means designing code so that anyone—including your future self or coworkers—can quickly understand what each function does and how it operates. This approach makes maintaining, updating, and collaborating on code much smoother and reduces the risk of errors.
- Use clear names: Choose descriptive names for your functions and variables so their purpose is obvious without extra explanation.
- Keep it focused: Make sure each function does one specific thing, and break down complex tasks into smaller, well-defined functions.
- Maintain consistency: Structure your code with consistent formatting and style, and add concise comments when needed to clarify the logic or reasoning.
-
-
The LET Function Will Change How You Build Formulas in Excel 🔥 I see it all the time when I'm working with clients... many professionals are still writing formulas the hard way, repeating the same logic over and over again. Every time you copy a formula segment multiple times within the same cell, you're making your spreadsheet slower and harder to maintain. Trust me, I've been there! The LET function changes everything by letting you assign names to calculation results within a single formula, making your formulas cleaner, faster, and easier to follow. ➡️ WHAT IS THE LET FUNCTION? The syntax is straightforward: =LET(NAME1, VALUE1, [NAME2, VALUE2], CALCULATION) You define variables in pairs, assign values or formulas to each variable, then use those variables in your final calculation. The variables you create exist only within that specific formula, so you can use descriptive names without worrying about conflicts with other parts of your workbook. Pretty cool, right? ➡️ WHY YOU NEED TO START USING LET TODAY ✅ Improves readability → replace repeated logic with meaningful names that anyone can understand ✅ Enhances performance → calculates values once instead of repeatedly, making your spreadsheets run faster ✅ Simplifies debugging → break down complex formulas step by step to find issues quickly ✅ Reduces errors → easier to audit and update when your logic is clearly named and organized ➡️ SIMPLE EXAMPLE THAT SHOWS THE POWER Without LET: =(A1 + A2) * (A1 + A2) With LET: =LET(X, A1 + A2, X * X) Cleaner, no repeated logic, and much easier to follow. Excel only calculates A1 + A2 once instead of twice. This is the kind of efficiency that gets me excited about spreadsheets! ➡️ ADVANCED EXAMPLE FOR FINANCIAL MODELING Want to calculate profit margin from total revenue and COGS while showing each step? =LET(REVENUE, B2, COGS, B3, PROFIT, REVENUE - COGS, MARGIN, PROFIT / REVENUE, MARGIN) Each step is clearly defined and you can see exactly what's happening. No more hunting through long formulas to find calculation errors...something that used to drive me crazy! ➡️ PRACTICAL USE CASES THAT WILL SAVE YOU HOURS 🔢 Financial Models → Define intermediate values like gross profit, taxes, EBITDA, and other key metrics without cluttering your worksheet 📊 Dashboards → Use inside named ranges or LAMBDA functions for dynamic KPIs that update automatically 📅 Date Calculations → Store reusable time logic like number of workdays, month-end dates, or fiscal year calculations 🎯 Complex IF/IFs → Simplify nested conditions by naming each logical component separately The best part? You can combine LET with other functions like SUMIFS, VLOOKUP, and INDEX/MATCH to create powerful formulas that would otherwise be impossible to read. === Have you tried the LET function yet? What complex formulas would you clean up first? Let me know in the comments below 👇
-
5 lessons I learned from reviewing code in 125+ interviews I've reviewed over 125 code snippets as an interviewer at Google and Amazon and trust me, clean code in an interview can be the difference between a "lean hire" and a "strong hire." Here are 5 tips to instantly improve your interview code: 1️⃣ Meaningful names: - Ditch x, y, and z. - Use names that describe the variable's purpose. - Example: item_count instead of x. - Makes your code so much easier to follow. - Imagine debugging code with variables like "value1" and "temp2" - a nightmare for both you and the interviewer! 2️⃣ Modular functions: - Break down large functions into smaller ones. - Each function should do one thing. - Instead of one giant calculate_discount() function. - Separate get_base_price(), add_coupon(), and calculate_final_price(). - This shows you can write organized and reusable code. 3️⃣ Pass by Reference: - When appropriate, pass variables by reference. - Avoids unnecessary copying. - Often makes your code faster. 4️⃣ Clean formatting: - Consistent indentation and spacing matter. - Make formatting while coding a habit. - Simple rule: Go to the next line after cleaning up the current one. - The interviewer would be more willing to help debug your code if they can see that it is length * (*width.begin()) and not length**width.begin(). 5️⃣ Readability is King: - Imagine the interviewer reading your code. - Is it easy to follow? - If not, refactor it. - Get rid of that nested ternary (?). - Instead use an if-else block for clarity. - I know being a one-line-coding-ninja feels great. - But it is wiser to not do that in our interviews. Start making these small changes. And trust me, you'll see a big difference - Your interviewers will love to help and work with your code more. 🌻 Let's make this post even more useful by sharing your top clean code tips! #cleancode #coding #interview #softwareengineering #tech #google #amazon
-
Every developer's nightmare - looking at your own code that's written 2 years ago and having no clue what it does. It's always better to write code like you are explaining it to your future self 𝐃𝐞𝐬𝐜𝐫𝐢𝐩𝐭𝐢𝐯𝐞 𝐧𝐚𝐦𝐢𝐧𝐠 - A name like calculateUserTaxRate() is much better than just calc() because it tells you what the function actually does. 𝐀𝐝𝐝 𝐂𝐨𝐦𝐦𝐞𝐧𝐭𝐬 - Don’t just say what the code is doing. Explain why you wrote it that way. 𝐒𝐢𝐧𝐠𝐥𝐞 𝐫𝐞𝐬𝐩𝐨𝐧𝐬𝐢𝐛𝐢𝐥𝐢𝐭𝐲 - Every function should do one specific thing, and do it well. 𝐂𝐨𝐧𝐬𝐢𝐬𝐭𝐞𝐧𝐭 𝐬𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞 - Write your code in a way that reads like a story, so others can easily follow it. 𝐃𝐨𝐜𝐮𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧 - Use README files and clear commit messages to explain how things work and why changes were made. 𝐖𝐫𝐢𝐭𝐞 𝐭𝐞𝐬𝐭 𝐜𝐚𝐬𝐞𝐬 - They help others (and your future self) understand exactly how your code is supposed to behave. 𝐑𝐞𝐟𝐚𝐜𝐭𝐨𝐫 - If something looks confusing now, it will be even harder to understand later. Make it better while it’s fresh. Pro tip: Write your code assuming the person fixing it later is having a really bad day and knows where you live. 😂 Remember: You're not just writing for the computer. You're writing for the developer who has to work with this code at 2 AM. and who knows that developer might be you in future again 😅 #SoftwareDevelopment #CleanCode #DeveloperLife #Programming Images Credits: Stackovermemes
-
Great Python functions drive great products 7 principles top developers follow Poor function design increases bugs and slows development, while well-written functions can transform your codebase. Here are 7 proven function best practices from Arjan Codes: 1️⃣ 𝗗𝗼 𝗢𝗻𝗲 𝗧𝗵𝗶𝗻𝗴 𝗮𝗻𝗱 𝗗𝗼 𝗜𝘁 𝗪𝗲𝗹𝗹 A function should have a single responsibility. If a function juggles multiple tasks, break it down into smaller, focused functions to enhance clarity and reusability. 2️⃣ 𝗦𝗲𝗽𝗮𝗿𝗮𝘁𝗲 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 𝗳𝗿𝗼𝗺 𝗤𝘂𝗲𝗿𝗶𝗲𝘀 This principle, known as Command-Query Separation (CQS), suggests that functions should either modify data (command) or return information (query), but never both. 3️⃣ 𝗢𝗻𝗹𝘆 𝗥𝗲𝗾𝘂𝗲𝘀𝘁 𝗜𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻 𝗬𝗼𝘂 𝗡𝗲𝗲𝗱 Avoid passing unnecessary data to functions. This promotes loose coupling, making your functions more independent, reusable, and easier to refactor. 4️⃣ 𝗞𝗲𝗲𝗽 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 𝗖𝗼𝘂𝗻𝘁 𝗠𝗶𝗻𝗶𝗺𝗮𝗹 A long list of parameters is a red flag, signaling potential complexity. Consider using default values, introducing data structures, or refactoring to encapsulate related parameters for improved readability. 5️⃣ 𝗗𝗼𝗻'𝘁 𝗖𝗿𝗲𝗮𝘁𝗲 𝗮𝗻𝗱 𝗨𝘀𝗲 𝗮𝗻 𝗢𝗯𝗷𝗲𝗰𝘁 𝗶𝗻 𝘁𝗵𝗲 𝗦𝗮𝗺𝗲 𝗣𝗹𝗮𝗰𝗲 Avoid instantiating and using an object within the same function. Instead, embrace dependency injection by passing the object as an argument to enhance testability and flexibility. 6️⃣ 𝗗𝗼𝗻'𝘁 𝗨𝘀𝗲 𝗙𝗹𝗮𝗴 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿𝘀 Boolean flags often indicate that a function is trying to do too much. Split the function into separate, more focused functions to eliminate flags and improve clarity. 7️⃣ 𝗥𝗲𝗺𝗲𝗺𝗯𝗲𝗿 𝗧𝗵𝗮𝘁 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗔𝗿𝗲 𝗢𝗯𝗷𝗲𝗰𝘁𝘀 Python functions are first-class citizens, allowing you to pass them too and return them from other functions. ❗𝗕𝗼𝗻𝘂𝘀 - 𝗡𝗮𝗺𝗲 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗪𝗲𝗹𝗹: Name your functions with verbs and arguments with nouns, creating a clear narrative within your code. If you find yourself using "and" in a function name, it's a strong sign that you should break it down into smaller, more specialized functions. These tips, derived from real-world experience, will help you craft functions that are focused, independent, testable, reusable, and readable. 💬 What tips would you add to this list? Share your thoughts below. ♻️ Know a Python developer or team lead? Share this post to help them out. 🔔 Follow me Daniel Bukowski for daily insights about delivering value from connected data.
-
Coding the correct optimized approach for the problem and keeping the code bug free is important, but what's also very important is making your code more understandable and readable. I mean all of us like reading well-written and clean pieces of code only, right? Here are a few tips that can help you make your code more elegant and readable- ✅ Use meaningful names: Choose descriptive names for variables, functions, classes so that it becomes easier for others to understand their purpose or meaning. ✅ Thoughtful comments: Wherever necessary, add comments to provide context or explain complex logic. Ideally, your code should be self-explanatory and excessive comments should be minimised. ✅ Proper indentation and formatting: This one is very important and I've seen interviewers emphasize on this one when they're assessing you. ✅ Reusable code: Remove duplicate code by creating reusable functions of using abstraction techniques. This reduces maintenance efforts and maintains consistency. ✅ Write modular code: Break your code into smaller, independent modules where each module should have a clear purpose and be responsible for a specific task. ✅ Avoid writing long code lines: Writing long lines of code makes it difficult to read moving back and forth horizontally. Use nesting and indentation to avoid this. Keep coding. All the best!❤️
-
Boost your efficiency in your data role by writing clean, readable Python code! Here is how to make your code easier to read and maintain: 1. 𝗨𝘀𝗲 𝗠𝗲𝗮𝗻𝗶𝗻𝗴𝗳𝘂𝗹 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲 𝗡𝗮𝗺𝗲𝘀: • It should be clear what the variable contains and its data type • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦𝘴: order_dates_list, shop_adresses_df, distance_in_km, cost_in_dollar 2. 𝗞𝗲𝗲𝗽 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗙𝗼𝗰𝘂𝘀𝗲𝗱: • Aim at a single responsibility with each function do one thing and do it well. • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦: Split a 𝘤𝘭𝘦𝘢𝘯_𝘢𝘯𝘥_𝘱𝘳𝘰𝘤𝘦𝘴𝘴_𝘥𝘢𝘵𝘢(𝘥𝘢𝘵𝘢) function into a 𝘤𝘭𝘦𝘢𝘯_𝘥𝘢𝘵𝘢(𝘥𝘢𝘵𝘢) and a 𝘱𝘳𝘰𝘤𝘦𝘴𝘴_𝘥𝘢𝘵𝘢(𝘥𝘢𝘵𝘢) function. 3. 𝗨𝘀𝗲 𝗗𝗼𝗰𝘀𝘁𝗿𝗶𝗻𝗴𝘀 𝗮𝗻𝗱 𝗖𝗼𝗺𝗺𝗲𝗻𝘁𝘀: • Add a multiline string at the beginning of the function describing what it does and how to use it. • Descript the parameters and return values for the function. • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦: 𝘥𝘦𝘧 𝘤𝘭𝘦𝘢𝘯_𝘥𝘢𝘵𝘢(𝘪𝘯𝘱𝘶𝘵_𝘥𝘧): """ Cleans the input dataset. Parameters: data (DataFrame): The raw input data. Returns: cleaned_df (DataFrame): The cleaned data. """ 4. 𝗙𝗼𝗹𝗹𝗼𝘄 𝗣𝗘𝗣 𝟴 𝗚𝘂𝗶𝗱𝗲𝗹𝗶𝗻𝗲𝘀: • Stick to Python’s style guide for a uniform look and structure. • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦: using snack case for function and variable names, following the rules for line breaks and parenthesis. 5. 𝗟𝗲𝘃𝗲𝗿𝗮𝗴𝗲 𝗟𝗶𝘀𝘁 𝗖𝗼𝗺𝗽𝗿𝗲𝗵𝗲𝗻𝘀𝗶𝗼𝗻𝘀: • Use list comprehensions to create lists without the use of normal loops. • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦𝘴: squares = [num ** 2 for num in range(10)] 6. 𝗕𝗿𝗲𝗮𝗸 𝗗𝗼𝘄𝗻 𝗖𝗼𝗺𝗽𝗹𝗲𝘅 𝗘𝘅𝗽𝗿𝗲𝘀𝘀𝗶𝗼𝗻𝘀: • Use intermediate variables for improved clarity. • 𝘌𝘹𝘢𝘮𝘱𝘭𝘦𝘴: 𝘛𝘶𝘳𝘯 result = (a + b) * (c / d) 𝘪𝘯𝘵𝘰 sum_ab = a + b division_cd = c / d result = sum_ab * division_cd Readable code isn’t just for others, but also for future you. Make your Python code clear, maintainable, and professional to make everyone's live easier. What’s your top tip for writing readable Python code? ---------------- ♻️ Share if you find this post useful ➕ Follow for more daily insights on how to grow your career in the data field #dataanalytics #datascience #python #cleancode #careergrowth
-
I’ve seen teams argue for hours about tabs vs spaces, but skip the basics that actually make code easier to read and maintain. Here’s what really moves the needle for Python projects: 1) Write code that explains itself. Clear names and small functions solve half the pain. 2) Treat PEP 8 as a baseline, not a religion. Consistency matters more than strictness. 3) Add type hints. They save time, catch silly mistakes, and make the code easier for teammates and tools to reason about. 4) Keep functions focused. If it’s hard to describe what it does in one line, it’s trying to do too much. 5) Handle errors thoughtfully. Catch what you expect and log what you need. 6) Document the “why,” not the obvious. 7) Clean imports, meaningful tests, and no random magic values sprinkled around. These simple habits make Python code kinder to whoever reads it next -including future you. #python #codingstandards #codequality #cleancode #bestpractices #programmingtips Follow Sneha Vijaykumar for more... 😊
-
"1. Write clearly -- Don't be too clever." I write almost every day in C. And the book I learned most how to do so didn't have any C in it. "The Elements of Programming Style" was the single book with the most affect on my programming and my thinking about putting ideas in motion. I thought it would be interesting to go back through their seventy-seven rules to good programming style. In their book, they used examples of bad code, taken from programming texts of the day, and fixed them, making them easier to understand, which endows them with fewer bugs, makes it much easier to add functionality in the future, and often made them more efficent. You should get a copy. They are available at ebay, amazon, and thrift books. I'm sure they are available at other used book sellers as well. While the programs are in FORTRAN and PL/I, you'll understand the examples--they don't make use of a large inventory of library functions as many programs do today. In those days, if you wanted to pad spaces to the left of a string, you just wrote the code to do so. "Write clearly" alone wouldn't tell us much, although the examples give more of the idea, the phrase that follows, "Don't be too cleaver," communicates the full idea. I have seen very clever code that at a glance gifted me with a new method I might not have thought of in a million years. "c = "0123456789abcdef"[i & 0xf]" is one of those. Want to turn the lower four bits of an integer into a hexadecimal character? There you are. It's obvious after you see it. I might not ever have thought of having a character array indexed by the binary corresponding to the character in that array. Plenty of examples of bad clever code almost defies scrutiny. If you have to be clever to UNDERSTAND the code, it's too clever. So what is clearly written code? It's code that follows the remaining seventy-six elements. (If there's interest, I'll make short comments in succeeding posts.) But even the idea to strive to write clear code was new to me. I hadn't realized that writing in FORTRAN, instead of hex digits of machine code, was for the benefit of the reader and not the execution by the machine. Programming languages are notations for the comprehension of programmers and not the compilers. Just like English text (or any other languages) the rules of style are to make it easier for the reader to acquire the thoughts of the writer. The most value I got from this first rule was the idea that I should try to make the program more understandable in the first place. Get a copy of the book. If you already have one, dust it off and re-read it. My comments here will not communicate Brian and Bill's insights, just muse about them. As Don Knuth told us with the title of his series of algorithm books, programming has an element of art to it, just as writing does. We can all write. We programmers and can write programs. And with K&P's insights, we can all learn to write better programs.
-
✨ Top Recommendations for Readable Code in Embedded Systems ✨ In embedded systems, code readability isn't just a luxury—it's a necessity. Clear, consistent code can mean the difference between smooth project progress and hours of debugging. Here are my top recommendations for crafting readable code in embedded systems: 1) Consistent Naming Conventions Choose descriptive names for variables, functions, and constants. Stick to a clear convention (e.g., snake_case for variables, CamelCase for functions) so that anyone reading the code can immediately understand its purpose. 2) Limit Function Size You can limit your functions Cyclomatic Complexity, but that doesn't mean your code will be readable. Use these rules of thumb for functions: - Don't allow code to go longer than a screen (formerly page) - Don't let a single line exceed 120 characters (I hate horizontal scrolling) 3) Comment with Intent Comments should explain why a piece of code exists, not what it does. Focus on explaining the reasoning behind non-obvious decisions, hardware constraints, or workarounds. 4) Use Constants, Not Magic Numbers Replace magic numbers with named constants. This practice not only improves readability but also makes future updates easier and reduces errors. 5) Avoid Deep Nesting Deeply nested loops and conditions can be hard to follow. Instead, use techniques like look-up tables, use do while loops for early returns, or refactor to flatten the structure and improve clarity. 6) Follow Industry-Recognized Guidelines There are a lot of great coding style guides out there. Adopt or adapt existing style guides (like MISRA for C/C++) to ensure your code adheres to best practices while remaining readable. 7) Automate Coding Style Checks Before you commit your code and put it up for review, run a tool that can autoformat your code to adhere to your coding standard. While this won't fix poor comments, magic numbers, etc, it can at least make sure that your code matches the style so these things can be spotted in review. Readable code is maintainable code—especially crucial in the long lifecycle of embedded systems. What coding style guidelines do you follow to keep your embedded code clean and readable? Share your tips or ask questions in the comments!
Explore categories
- Hospitality & Tourism
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Healthcare
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Career
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development