Author Topic: [Proposal] Codingconventions  (Read 10960 times)

Stelzi79

  • Newbie
  • *
  • Posts: 19
    • My mercural-fork on Bitbucket
[Proposal] Codingconventions
« on: June 22, 2013, 01:31:19 pm »
Hello,

I use the tool JustCode and this tool gives me arround 5700 warnings about naming-recommondations and such inconsitancies. If you look closer in to the warnings you have to come to the conclusion that there isn't any naming-convention in place. In fact the naming is all over the place. So here I propose some Codingconventions.

By the way: JustCode (http://www.telerik.com/products/justcode.aspx) is a neat "little" tool to enforce StyleRules and such things and also provides project specific settings-files.

3rd party libarries:
They should be left alone untouched! Where possible use NuGet-Packages. If there aren't any usable NuGet-Packages create a custom NuGet-like package feed. http://www.myget.org/ proviedes such services for free usable for open source projects. (I read a blog-post reacently which also spoke about reducing VisualStudio projects by using NuGet-Packages.)

Directories - Files - Namespaces - Types:
  • One file has only one type. A type can reside in different files (partial keyword) provided the parts of the type is appropiatly and logicaly grouped to the different files.
  • The filename (without the extension) is the name of the type.
  • The directory-path is the same as the namespace.
Tabs and Intends:
  • Tabsize = 4 (I personally use here 2 -> condenses the code a lttle)
  • Intentionsize = 4 (I personally use here 2 -> condenses the code a lttle)
  • Insert spaces
File Header Text:
Currently none in use. We could do a general puruose FileHeader Text with some Copyright-Informations in every file.

General:


Indentation:


Spacing:


New Lines:


Blank Lines:


Ordering:


Brace Positions:


Wrapping:


Using Directives:
Here we can define which Using should be in every file and wich shouldn't be deleted if they aren't used in this file.
In every file: none
Don't remove: System, System.Linq

Naming Conventions:
Possible naming conventions: camelCase, camel_Underscore, PascalCase, Pascal_Underscore, Sentence_Underscore, lower_underscore, UPER_UNDERSCORE, disabled
There can also be added secondary rules.
Allowed Accronyms are strings that are excluded from naming conventions


Migration Path:
Because a rampaging codecleanup would be nearly impossible to review this should only be done in some smaller cleanups. Private and in one file/type contained changes had to be done on sight. Changes which spread in more Types and files with public properties/fields should always reside in one clean commit with a limited number of changes. Every change have to be tested. All commits in this regard have to compile properly on there own!
My changes to the official version:
MY mercurial fork on bitbucket

emre

  • SambaPOS Developer
  • Samba Team
  • Hero Member
  • *****
  • Posts: 1564
Re: [Proposal] Codingconventions
« Reply #1 on: June 23, 2013, 05:39:02 am »
There are some third party libraries we are using in SambaPOS project. The reason I keep them in source code format is I've modified them for SambaPOS needs but couldn't reflect these changes on original projects.

Is it possible to see what kind of warnings it generates for SambaPOS code? For example can you run this tool for Order.cs or Ticket.cs ?

Stelzi79

  • Newbie
  • *
  • Posts: 19
    • My mercural-fork on Bitbucket
Re: [Proposal] Codingconventions
« Reply #2 on: June 23, 2013, 10:23:13 am »
Somhow suprisingly in the Order.cs and Ticket.cs there aren't any warnings from JustCode! Thought if you let JustCode order and format the files you get another story. I've attached this two files how they look after I let JustCode format and order things. By the way for my taste these files are with 500 and 800 lines of codes are way to big and I would have splited them in seperate files long ago.  But there is for example a EventTopicNames.cs where are several types in it and every and all static const string is PascalCase and not as every constant schould be a UPERCASE_UNDERSCORE. And that the guyes from fluentscript can't name things right shows in the namespace they named "_Core" => I havn't found a way to make a rule to allow for JustCode it! Many naming-issues are from fluentscript. I'll make some test, if we can make from FluentScript a sepperate git (sub)repository and genereate (on MyGet.org) a NuGet-Like package and include it everywehre as a package.
My changes to the official version:
MY mercurial fork on bitbucket