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
0
votes
1 answer

Convention for inline glossary definitions?

Does anyone know if there is a convention for including inline definitions of words within HTML text? I've made a documentation platform. It auto-generates glossaries, but I also want the user to have the option of having terms from the glossary…
Mitya
  • 33,629
  • 9
  • 60
  • 107
0
votes
2 answers

[+], [-], [i]... Coding Conventions

I have spent time coding a nice console App for windows users. It is 'console-based' so I wanted to make sure it looks professional when displaying messages to the user. I have seen many exploit code or linux codes displaying console information in…
learnerX
  • 1,022
  • 1
  • 18
  • 44
0
votes
4 answers

Custom exceptions or empty list

I am working on a project to parse the text. I am parsing for specific text and store them in the array. I have written a class for it. If I get improper text so that I cannot find what I want in the given input, What is the best practice, should I…
user2990315
  • 271
  • 1
  • 5
  • 11
0
votes
1 answer

Container class for REST get list method

I ran into a situation where I thought is a problem of not following REST convention. Please consider this, I have an API that allows working with book records via this REST API http://localhost:8080/api/books In my mind, when I do a GET to…
Bolto Cavolta
  • 413
  • 1
  • 8
  • 16
0
votes
1 answer

Naming convention for controller used to parse a page in Rails

I want to have a page where a User can enter a URL and on the back the page will be parsed and show back some information found in the page. I am wondering what would be a naming convention for this case, given the fact that there is no model…
Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
0
votes
1 answer

In C++ is it more conventional to define method bodies within or outside the class definition?

Rather self explanatory. I was just wondering what was more conventional to do in object-oriented C++? Example A: class CarObject{ private: //Local Variables string name; int cost; public: CarObject(string…
Jake Byman
  • 540
  • 12
  • 29
0
votes
1 answer

Struts2's convention plugin doesn't scan jars in WEB-INF/lib

I packaged some actions in jar files and put these files in WEB-INF/lib. Also,I've configed struts.convention.action.includeJars constant. But I found convention plugin doesn't scan jars in WEB-INF/lib. See…
yonder
  • 1
0
votes
1 answer

Trying to move my object initialisation and method calls out of my Main method

I am trying to move some code out of the main method and use it in another class. The reason for doing this is that I learnt it was advised convention to do so and I am relatively new to Java so looking to try it out. Currently when I move the code…
RichE
  • 133
  • 1
  • 6
0
votes
1 answer

Finding where a method is called for a convention test

I'm trying to write a convention test that specifies that a method should only be called in some contexts - specifically I have a static Empty getter that I only want to allow used in test methods, vis methods decorated with TestAttribute. I know…
Rebecca Scott
  • 2,421
  • 2
  • 25
  • 39
0
votes
1 answer

Are there accepted names for the two types of arrays in a multidimensional array?

Sorry if this question is a bit elementary, but I was wondering if there are names for the different arrays in a 2D array. For example, in: int[][] array = new int[5][10]; What do I call the array with the length of 5? And what about the arrays…
yts
  • 1,890
  • 1
  • 14
  • 24
0
votes
1 answer

Change URL mapping in Struts2 with convention plug-in

I'm currently learning struts2 annotation with convention plug-in. Everything went okay except URL mapping. I want to access to action with URL like: http://{my domain name}/{action name}. But after many tried, i always ended up with http://{my…
Doan Cuong
  • 2,594
  • 4
  • 22
  • 39
0
votes
2 answers

What is the best practise to use with default drawables?

Having a specialized folder for default drawable ("drawable" with no screen size extension) would be more intuitive and self explanatory, making it easier to locate files. But will it cause logical errors in runtime? What is the convention here? do…
user1545072
0
votes
1 answer

Pattern name/Convention -> Class that merge different attributes from other classes

I wanted to know if there is a known pattern or convention for the following scenario: I have two classes: MAT (name:String, address:String) & MATversion(type:String, version:int) Now I have a DataGrid (DataTable) which will take a generic List of…
Matthias Reisner
  • 581
  • 1
  • 6
  • 25
0
votes
1 answer

Serialization of only changed members

I am new to MongoDB and want to serialize my object efficiently. That means when updating an object i want only to write the fields that changed. If my object has sub objects in a list, i only want to add or remove the changed sub objects. That is…
Tuan
  • 893
  • 1
  • 9
  • 24
0
votes
1 answer

JavaScript Constructor Function Instantiated Object Prefix Convention

In JavaScript, is there a naming convention for objects instantiated from constructor functions? For example, if I had a constructor function set up like so: function Dance(style, timing) { this.style = style; // for reflection this.timing =…
user1354017
  • 431
  • 6
  • 11