Questions tagged [convention]

A convention is a set of agreed, stipulated, or generally accepted norms. It typically helps common efficiency or understanding but is not required, as opposed to a strict standard or protocol. In programming, a typical kind of convention is the coding convention which stipulates how programmers should format and style their programs.

Here are some examples of conventions that affect programming:

  • Coding style: how the source code is formatted (indentation & spacing, location of braces, ordering of methods/functions, etc.). This helps programmers to read and understand the code more quickly, find bugs more easily.
  • File naming: some programs expect the files they process to be named a certain way. For example, the ant command assumes by default that the build file is names build.xml, which allow developers to omit the file name in the command line.
  • File structure: programmers are often used to particular way to organize the files, that depends on the language / technology. This allows to read / browse through an unknown code base more easily. Even compilers of some language may expect files to be organized by default in a conventional way. For example, maven expects source files to be in a src directory and binary files in a target directory.
  • Variable naming: some variables with given semantics are conventionally named. For example, for loop variable are usually named i, j, k, etc.; and Cartesian coordinates are usually named x, y and z.
353 questions
-1
votes
1 answer

What is the prefered way of writing methods in Laravel?

Which one of these styles are prefered when retrieving data to display in a view? Straight forward laravel with no custom methods in the model: $guest->bookings->first()->id; $guest->bookings->first()->bed; $guest->bookings->first()->date; or a…
Lasse
  • 77
  • 1
  • 10
-2
votes
1 answer

Security of Cake Php due to the conventions followed

I want to know whether the conventions that are followed in cake php poses any kind of security vulnerability in the web app. As in it is a convention to set id as the primary key in all the tables.So doesn't it provide a security vulnerability as…
Kumar Akarsh
  • 4,954
  • 2
  • 20
  • 31
-2
votes
1 answer

Project structure for class inheritance in Python

What is the best practice to deal with inheritance in Python in terms of organizing the project structure? I am using something like this: utils/Parser.py utils/XMLParser.py utils/JsonParser.py Parser.py class Parser(): def parse(self): raise…
renatodamas
  • 16,555
  • 8
  • 30
  • 51
-2
votes
4 answers

Is it ok to get variable value directly instead of using getter in Java?

I'm writing program which operates on coordinate system so I need to use coordinates pretty often. I decided to use Point class because it obviously allows to easily store coordinates of a point. The problem is everywhere in my program I store it as…
sajran
  • 317
  • 4
  • 15
-2
votes
7 answers

what style is better?

this: public void foo() { for (int i = 0; i < rows; i++) // <--- no brace! for (j = 0; j < columns; j++) // <--- no brace! table[i][j] = new Blabla(i, j); other(); } or this: public void foo() { for (int i =…
Marcos
  • 4,643
  • 7
  • 33
  • 60
-2
votes
1 answer

Names in JavaScript

var A = function () { this.someProperty = 0; }; var a = new A(); The variable a is an object. What do I call to A? A class?
SlySherZ
  • 1,631
  • 1
  • 16
  • 25
-2
votes
1 answer

Rails indentation convention

<%= link_to 'Foo', {:contoller => 'bar', :id => 'baz.id' %> } There is no consensus amongst my peers as how this should be indented. I'd like to know myself so that I am not writing code the wrong way.
-8
votes
3 answers

string.equals(null) vs string == null

I've seen some of this answered for PHP, SQL and C++, but can't find by java. There is some convention or best practice with that? I'm asking about null not equals vs == if (myString != null && myString == null) or if (!myString.equals(null) &&…
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
1 2 3
23
24