Why do variables start with m




















Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Naming convention: field starting with "m" or "s" Ask Question. Asked 8 years, 11 months ago. Active 6 years ago. Viewed 22k times. Improve this question. Noya Noya 1 1 gold badge 1 1 silver badge 5 5 bronze badges. You dont need to use them prefixes — Yousha Aleayoub. Add a comment. Active Oldest Votes. Improve this answer. Community Bot 1. StuperUser StuperUser 6, 1 1 gold badge 26 26 silver badges 56 56 bronze badges.

First hit on web search took me to developer. You are mixing two kinds of things in that list. The scopes — m , c and s — and the Hungarian-style kind prefixes p , v , i and e. To do this, concretely:. This topic was automatically closed days after the last reply. New replies are no longer allowed. Please help. Proper Java Conventions. No more capital method names now though yay!! To reiterate: Consistency is key.

All of these rules stick to the principle of prioritizing read-time understandability instead of write-time convenience. Coding is primarily a method for communicating with other programmers, so give your team members some help in making sense of your computer programs.

A magic number is a constant value without a variable name. I see these used for tasks like converting units, changing time intervals or adding an offset:. Changing the value requires looking up all the locations where it's used and manually typing in the new value. Instead of using magic numbers in this situation, we can define a function for conversions that accepts the unconverted value and the conversion rate as parameters :.

If we use the conversion rate throughout a program in many functions, we could define a named constant in a single location:. Standards matter! It also tells anyone reading your code exactly what the constant represents.

A function parameter is also an acceptable solution if the name describes what the parameter represents. As a real-world example of the perils of magic numbers, in college, I worked on a research project with building energy data that initially came in minute intervals.

No one gave much thought to the possibility this could change, and we wrote hundreds of functions with the magic number 15 or 96 for the number of daily observations. This worked fine until we started getting data in five and one-minute intervals.

We spent weeks changing all our functions to accept a parameter for the interval, but even so, we were still fighting errors caused by the use of magic numbers for months. Real-world data has a habit of changing on you. There is no place for magic in programming, even in data science. The benefits of adopting standards are that they let you make a single global decision instead of many local ones.

Instead of choosing where to put the aggregation every time you name a variable, make one decision at the start of the project, and apply it consistently throughout. The objective is to spend less time on concerns only peripherally related to data science: naming, formatting, style — and more time solving important problems like using machine learning to address climate change.

If you are used to working by yourself, it might be hard to see the benefits of adopting standards. However, even when working alone, you can practice defining your own conventions and using them consistently.

Anytime you have more than one programmer on a project, standards become a must! The key point is to stop spending so much time on accidental difficulties and instead concentrate on the essential difficulties. Now we can see that this code is normalizing the pixel values in an array and adding a constant offset to create a new array ignore the inefficiency of the implementation!

When we give this code to our colleagues, they will be able to understand and modify it. Clarifying your variable names may seem like a dry activity, but if you spend time reading about software engineering, you realize what differentiates the best programmers is the repeated practice of mundane techniques such as using good variable names, keeping routines short, testing every line of code, refactoring, etc. This article was originally published on Towards Data Science. Clean Up Your Code.

Learn how to improve your code quality with clearer variable names. Will Koehrsen. Expert Columnist. November 4,



0コメント

  • 1000 / 1000