Giter Club home page Giter Club logo

real-time-naming-convention's Introduction

Real-Time Naming Convention

Developers often work with multiple programming languages, each with its own set of naming conventions. Manually adapting to each convention can be error-prone and time-consuming. This extension solves that problem for you.

Simply type in a new variable name with spaces, like new fancy name, and this extension will automatically adapt it to the naming convention of the language you're working in: new_fancy_name, newFancyName or NewFancyName.

Usage (Python)

Just type it like this:

class some class:
  def some method(self, some parameter, another parameter):
    self.some field = 42

def some function(some parameter, another parameter):
  some variable = 42
  for some int in [1, 2, 3]:
    print("Hello world!")
  return

As soon as you type the above, you will get:

class SomeClass:
  def some_method(self, some_parameter, another_parameter):
    self.some_field = 42

def some_function(some_parameter, another_parameter):
  some_variable = 42
  for some_int in [1, 2, 3]:
    print("Hello world!")
  return

Note on Existing Names

This extension is designed to assist you in creating new variable, function, or class names by automatically adapting them to the naming convention of the language you're working in. It will not modify names that are already defined in your codebase.

For existing names, this extension is fully compatible with and encourages the use of VS Code's built-in autocompletion features. Simply start typing the name, and VS Code's autocompletion will help you complete it, without any interference from this extension.

Supported Languages and Features

  • Python
  • TODO: C, Java, JavaScript ...

Python Naming Conventions and Syntax for Defining Names

In Python, naming conventions play a critical role in enhancing code readability and maintainability. The naming of variables, functions, classes, and other entities must be consistent and self-explanatory. This section outlines the various syntactical locations where new names can be introduced in Python, accompanied by the naming conventions commonly adhered to.

Variable Assignments

Use snake_case for variable names.

variable_name = value

Function Definitions

Use snake_case for both the function name and its parameters.

def function_name(param1, param2):
    pass

Class Definitions

Use PascalCase for class names.

class ClassName:
    pass

For Loops

Use snake_case for loop variables.

for item_name in iterable:
    pass

List Comprehensions

Use snake_case for the loop variables.

[ <expression> for item_name in iterable ]

With / Import statements

Use snake_case for context variable names.

from module import entity as entitiy_name

with open("file.txt") as file_handle:
    pass

Except Clauses

Use snake_case for exception variable names.

try:
    pass
except Exception as error_name:
    pass

Lambda Function Parameters

Use snake_case for the lambda function parameters

lambda param_name: <expression>

Class Attribute and Method Definitions

Use PascalCase for class names, and snake_case for attribute and method names.

class ClassName:
    class_attribute = value

    def method_name(self, param_name):
        pass

Global and Nonlocal Statements

Use snake_case for the variable names

global variable_name
nonlocal variable_name

Function Arguments

Use snake_case for argument names.

def func_name(arg_name):
    pass

Unpacking Assignments

Use snake_case for all unpacked variable names.

u_a, u_b, *u_rest = [1, 2, 3, 4, 5]

Release Notes

Users appreciate release notes as you update your extension.

0.0.1

  • Initial release, support limited naming convention of Python.

0.0.2

  • Support for loop in python and add test cases.

0.0.3

  • Support recording input statistics for research purposes.

0.1.0

  • Supports full Python grammar
  • More powerful input recordings (for research purposes)

0.1.1

  • Fix Python assignment patterns
  • No auto correction while recording

0.1.2

  • Fix duplicate recording disposable

0.1.3

  • Add Python unpacking patterns
  • Add demo GIF in readme.md

0.2.0

  • Add optional indication for automatic modification
  • Add correction rule for reserved word exception

Enjoy!

real-time-naming-convention's People

Contributors

p51lee avatar najiwoong avatar mdsnins avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.