DEV Community

Arpit Mohan
Arpit Mohan

Posted on • Originally published at insnippets.com

Why Go succeeded; Java's naming conventions; & Python optimization tips

TL;DR style notes from articles I read today.

5 things Rob Pike attributes Go’s success to


  • Writing a formal specification of the language.
  • Making Go attractive for app developers to use. Having key software written in Go created confidence in it.
  • Establishing a strong open-source community that supported Go. Being prepared for a tricky balancing act while listening and implementing.
  • Counterintuitive, but making the language hard to change. Yes, it creates rigidity but also makes it harder for old code to break.
  • Constantly listening to the community, but sticking to the things Go team believed are important from their specs.  


Full post here, 4 mins read


What’s in a name: Java naming conventions

  • In the base package name, put your company’s domain in reverse order & then add the project name & maybe version - all in lower case.
  • Use nouns, written in CamelCase (with first letter capital), for class names. Class names should say what function or variable to expect from it as well.
  • Choose short, meaningful nouns for variables and fields, saying what values or variables they hold, in camelCase.
  • Avoid single character variables. Avoid underscore & dollar as first letters. For boolean values, start with ‘is’ or ‘has’, since they are yes/no questions. 
  • Put constants in all-caps, with underscores to separate words.
  • Make methods and functions verbs, implying what they do in 2-3 words in camelCase. Use ‘get’ & ‘set’ to start the names of data fetching and setting functions.
  • Use similar conventions as classes and interfaces for enums and annotations, respectively, with enums in all-caps.

Full post here, 5 mins read


Python code optimization tips for developers

  • Optimize the slow code first. In the case of Python, PyPy helps you use less space and work faster than CPython’s typical bulk allows for.
  • Profile codes (using CProfile or PyCallGraph, say) to analyze how they work in different situations and estimate the time taken.
  • Python strings tend to be immutable and slow. Concatenate them with the .join() method rather than relying on the memory-hungry (+) operator alone.
  • Use list comprehension rather than loops for faster coding and execution.
  • For memory optimization, prefer xrange over the range function to speed up the creation of integer lists.


Full post here, 4 mins read

--- 

Get these notes directly to your inbox every weekday by signing up for my newsletter, in.snippets(), here.

Top comments (0)