Comments (8)
Another thing to add here is that maybe we should stop using --enable-experimental-non-null
as it makes the code more fuzzy and harder to read (mainly due to Vala lacking this)
from replay.
A link to the Vala coding style => https://wiki.gnome.org/Projects/Vala/Hacking#Coding_Style
from replay.
@nahuelwexd I'd prefer the coding style of Vala, e.g. you wouldn't want to read ruby style code in JavaScript. It also eases the eyes of potential readers of the code since that's what they'll probably be familiar with anyway.
from replay.
@lifeiscontent I was previously following a coding style more similar to C# because it was a little more practical to read (more spaces), plus the Vala being inspired by C#, it was still partly familiar
from replay.
Makes sense, another idea you could do is add something like vala-lint to pre-commit hooks, that way you don't need to think about it and formatting is automatically taken care of for you. I wish Vala had something like prettier so you could just run it along side your editor in real time.
from replay.
@lifeiscontent It's a nice idea, but vala-lint AFAIK does not lint your code. Currently just throws errors if your code is not following the style defined in the config file
from replay.
What do you think of this coding style? It's heavily based on the elementary's coding style, since most of the current Vala code comes from there.
- Whitespace before opening parentheses or braces
- Whitespace between numbers and operators in math-related code
- Closing brackets must be followed by an empty line, except when followed by an
else
statement - 4 column wide tabs for indentation and spaces for alignment
- "One True Brace Style" (1TBS) for classes, functions, loops, and general flow control
- Mandatory braces, even with single line blocks
- Cuddled
else
switch...case
instead of multipleelse if
- 1 public class per file.
- Same name for file as for its public class, but in
kebab-case
- Descriptive names for everything
//
for comments/// TRANSLATORS:
for translators annotationssnake_case
for variable and method identifiersPascalCase
for type identifiersSCREAMING_SNAKE_CASE
for enum members and constants- Static type casting over dynamic type casting
- Properties over getters/setters
- Object initializers to avoid redundancy. See:
// bad var label = new Gtk.Label ("Test Label"); label.ellipsize = Pango.EllipsizeMode.END; label.valign = Gtk.Align.END; label.width_chars = 33; label.xalign = 0; // good var label = new Gtk.Label ("Test Label") { ellipsize = Pango.EllipsizeMode.END, valign = Gtk.Align.END, width_chars = 33, xalign = 0 };
- Implicit GLib namespace
- String templates over printf-style, except for error messages, as they must be localized.
- 120 columns per line
- 1 argument per line when breaking long method calls
- GObject-style construction when possible
this
prefix to refer to current's instance members- Operators over methods when method has syntax support
public
only when necessary,private
otherwise- Underscore prefix for
private
fields - Auto-implemented properties when possible. See:
// bad private string _name; public string name { get { return this._name; } set { this._name = value; } } // good public string name { get; set; }
- Implicit type only when obvious. See:
// bad var result = ExampleClass.result_so_far (); // redundant => bad Person person = new Person (); // good ResultSet result = ExampleClass.result_so_far (); // good var person = new Person ();
- Newlines to separate the code into logical pieces
from replay.
@nahuelwexd I'm a fan of this. I'd say lets do it!
from replay.
Related Issues (20)
- Build action for ARM64 HOT 3
- Implement a navigator widget that connects to the navigation service and performs the main navigation
- Implement main window layout (sidebar navigation on desktop form factors, bottom navigation bar on mobile form factors)
- Connect the main window with the navigation service to display: primary and secondary views in the sidebar, and only the primary views in the bottom bar
- Empty window HOT 2
- Can't compile under archlinux / find gjson package HOT 4
- error: app/app.drey.Replay.Devel.flatpak/x86_64/master not installed HOT 1
- Nix flake HOT 2
- Should we move Replay-Design here? HOT 8
- Ability to store and organize playlists
- Update contributing guidelines HOT 1
- Basic GUI Layout HOT 1
- Implement the trends page
- Implement the search view
- Implement the videos page HOT 1
- Project is not written in Rust, the official language of the official GNU/Linux DE (Gnome) HOT 6
- Extend scope beyond youtube, support alternatives (for e.g. Odysee.com, Bitchute.com, PeerTube) HOT 1
- Link subscribed channels across backends (youtube, odysee...) in one place HOT 1
- Exporting, importing and syncing
- Is there a way i could contribute by translating replay to my mother language (Croatian) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replay.