Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Coding style

Stefano Pacifici edited this page Jun 14, 2018 · 1 revision

We follow the Mozilla Coding style, plus some addition to explicitly mark Cliqz changes.

Marking changes

C/C++/Java/Javascript

We use to mark changes in .java files like show below.

/* Cliqz Start */
// Doing something cool
System.out.println("Hello, world!");
/* Cliqz End */

We do not have a form for single line comments.

To comment out an entire block, please use the following syntax.

/* Cliqz start o/
int maxId = 0;
while(maxIdCurosr.moveToNext()) {
    maxId = maxIdCurosr.getInt(0);
}
/o Cliqz end */

XML/HTML

As per C/C++/Java/Javascript, we add start and end markers around our changes.

<!-- Cliqz Start -->
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">
<!-- Cliqz End -->

Again, the form to comment out a block of code is visually similar to the one above.

<!-- Cliqz Start -+>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">
<!+- Cliqz End -->

Because is not possible to comment out attributes in a tag, the adopted practice is tho move the attributes outside the tag and create a comment block around them as shown in the following example.

Suppose we want to remove the paddings from the following TextView node.

<TextView
    android:id="@+id/blocked_trackers"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@id/total_trackers"
    android:layout_toEndOf="@id/total_trackers"
    android:layout_toRightOf="@id/total_trackers"
    android:paddingEnd="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingStart="10dp"
    android:textColor="@android:color/holo_red_dark"
    android:textSize="12sp"
    tools:text="2 blocked" />

The final code will look like:

<!-- Cliqz Start -->
<TextView
    android:id="@+id/blocked_trackers"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@id/total_trackers"
    android:layout_toEndOf="@id/total_trackers"
    android:layout_toRightOf="@id/total_trackers"
    android:textColor="@android:color/holo_red_dark"
    android:textSize="12sp"
    tools:text="2 blocked" />
<!--
    android:paddingEnd="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingStart="10dp"
-->
<!-- Cliqz End -->

Naming conventions

TBD

Clone this wiki locally