Skip to content

Commit 8817318

Browse files
committed
Fix typos and wording issues
1 parent 68fead7 commit 8817318

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

project_and_code_guidelines.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ Layout files should match the name of the Android components that they are inten
6565
| AdapterView item | --- | `item_person.xml` |
6666
| Partial layout | --- | `partial_stats_bar.xml` |
6767

68-
A slighly different case is when we are creating a layout that is going to be inflated by an `Adapter`, e.g to populate a `ListView`. In this case, the name of the layout should start with `item_`
68+
A slightly different case is when we are creating a layout that is going to be inflated by an `Adapter`, e.g to populate a `ListView`. In this case, the name of the layout should start with `item_`.
6969

70-
Note that there are cases where these rules will not be possible to apply. For example, when creating layout files that are intended to be part of other layouts. In this case you should use the prefix `partial_`
70+
Note that there are cases where these rules will not be possible to apply. For example, when creating layout files that are intended to be part of other layouts. In this case you should use the prefix `partial_`.
7171

7272
#### 1.2.1.3 Menu files
7373

74-
Similar to layout files, menu files should match the name of the component. For example, if we are defining a menu file that is going to be use in the `UserActivity`, then the name of the file should be `activity_user.xml`
74+
Similar to layout files, menu files should match the name of the component. For example, if we are defining a menu file that is going to be used in the `UserActivity`, then the name of the file should be `activity_user.xml`
7575

76-
A good practise is to not include the word `menu` as part of the name because these files are already located in directory called menu.
76+
A good practice is to not include the word `menu` as part of the name because these files are already located in the `menu` directory.
7777

7878
#### 1.2.1.4 Values files
7979

@@ -164,15 +164,15 @@ public class MyClass {
164164

165165
### 2.2.4 Use spaces for indentation
166166

167-
Use __4 space__ idents for blocks:
167+
Use __4 space__ indents for blocks:
168168

169169
```java
170170
if (x == 1) {
171171
x++;
172172
}
173173
```
174174

175-
Use __8 space__ idents for line wraps:
175+
Use __8 space__ indents for line wraps:
176176

177177
```java
178178
Instrument i =
@@ -222,13 +222,13 @@ According to the Android code style guide, the standard practices for some of th
222222

223223
* `@SuppressWarnings`: The @SuppressWarnings annotation should only be used under circumstances where it is impossible to eliminate a warning. If a warning passes this "impossible to eliminate" test, the @SuppressWarnings annotation must be used, so as to ensure that all warnings reflect actual problems in the code.
224224

225-
More information about annotations guidelines can be found [here](http://source.android.com/source/code-style.html#use-standard-java-annotations).
225+
More information about annotation guidelines can be found [here](http://source.android.com/source/code-style.html#use-standard-java-annotations).
226226

227227
#### 2.2.6.2 Annotations style
228228

229229
__Classes, Methods and Constructors__
230230

231-
When annotations are applied to a class, method or constructor they are listed after the documentation block and should appear as __one annotation per line__ .
231+
When annotations are applied to a class, method, or constructor, they are listed after the documentation block and should appear as __one annotation per line__ .
232232

233233
```java
234234
/* This is the documentation block about the class */
@@ -264,14 +264,14 @@ The ordering of import statements is:
264264

265265
To exactly match the IDE settings, the imports should be:
266266

267-
* Alphabetical within each grouping, with capital letters before lower case letters (e.g. Z before a).
267+
* Alphabetically ordered within each grouping, with capital letters before lower case letters (e.g. Z before a).
268268
* There should be a blank line between each major grouping (android, com, junit, net, org, java, javax).
269269

270270
More info [here](https://source.android.com/source/code-style.html#limit-variable-scope)
271271

272272
### 2.2.9 Logging guidelines
273273

274-
Use the logging methods provided by the `Log` class to print out error messages or other information that may be useful for developers to identifiy issues:
274+
Use the logging methods provided by the `Log` class to print out error messages or other information that may be useful for developers to identify issues:
275275

276276
* `Log.v(String tag, String msg)` (verbose)
277277
* `Log.d(String tag, String msg)` (debug)
@@ -290,8 +290,8 @@ public class MyClass {
290290
}
291291
}
292292
```
293-
294-
VERBOSE and DEBUG logs __must__ be disable on relase builds. It is also recommendable to disable INFORMATION, WARNING and ERROR logs but you may want to keep them enable if you think they may be useful to identify issues on release builds. If you decide to leave them enable, you have to make sure that they are not leaking private information such as email addresses, user ids, etc.
293+
294+
VERBOSE and DEBUG logs __must__ be disabled on release builds. It is also recommended to disable INFORMATION, WARNING and ERROR logs but you may want to keep them enabled if you think they may be useful to identify issues on release builds. If you decide to leave them enabled, you have to make sure that they are not leaking private information such as email addresses, user ids, etc.
295295

296296
To only show logs on debug builds:
297297

@@ -339,7 +339,7 @@ public class MainActivity extends Activity {
339339
}
340340
```
341341

342-
If your class is extending and __Android component__ such as an Activity or a Fragment, it is a good practise to order the override methods so that they __match the component's lifecycle__. For example, if you have an Activity that implements `onCreate()`, `onDestroy()`, `onPause()` and `onResume()`, then the correct order is:
342+
If your class is extending an __Android component__ such as an Activity or a Fragment, it is a good practice to order the override methods so that they __match the component's lifecycle__. For example, if you have an Activity that implements `onCreate()`, `onDestroy()`, `onPause()` and `onResume()`, then the correct order is:
343343

344344
```java
345345
public class MainActivity extends Activity {
@@ -355,7 +355,7 @@ public class MainActivity extends Activity {
355355
public void onPause() {}
356356

357357
@Override
358-
public void onDestory() {}
358+
public void onDestroy() {}
359359

360360
}
361361
```
@@ -369,18 +369,18 @@ The opposite case are __callback__ interfaces that should always be the __last__
369369
Examples:
370370

371371
```java
372-
// Context always go first
372+
// Context always goes first
373373
public User loadUser(Context context, int userId);
374374

375375
// Callbacks always go last
376376
public void loadUserAsync(Context context, int userId, UserCallback callback);
377377
```
378378

379-
### 2.2.13 String constants, naming and values
379+
### 2.2.13 String constants, naming, and values
380380

381-
Many elements of the Android SDK such as `SharedPreferences`, `Bundle` or `Intent` use a key-value pair approach so it's very likely that even for a small app you end up having to write a lot of String constants.
381+
Many elements of the Android SDK such as `SharedPreferences`, `Bundle`, or `Intent` use a key-value pair approach so it's very likely that even for a small app you end up having to write a lot of String constants.
382382

383-
When using one of these components, you __must__ define the keys as a `static final` fields and they should be prefixed as indicaded below.
383+
When using one of these components, you __must__ define the keys as a `static final` fields and they should be prefixed as indicated below.
384384

385385
| Element | Field Name Prefix |
386386
| ----------------- | ----------------- |
@@ -390,7 +390,7 @@ When using one of these components, you __must__ define the keys as a `static fi
390390
| Intent Extra | `EXTRA_` |
391391
| Intent Action | `ACTION_` |
392392

393-
Note that the arguments of a Fragment - `Fragment.getArguments()` - are also a Bundle. However, because this is a quite common use of Bundles, we define a different prefix for them.
393+
Note that the arguments of a Fragment - `Fragment.getArguments()` - are also a Bundle. However, because this is a quite common use of Bundles, we define a different prefix for them.
394394

395395
Example:
396396

@@ -407,11 +407,11 @@ static final String ACTION_OPEN_USER = "com.myapp.action.ACTION_OPEN_USER";
407407

408408
### 2.2.14 Arguments in Fragments and Activities
409409

410-
When data is passed into an `Activity `or `Fragment` via `Intents` or a `Bundles`, the keys for the different values __must__ follow the rules described in the section above.
410+
When data is passed into an `Activity `or `Fragment` via an `Intent` or a `Bundle`, the keys for the different values __must__ follow the rules described in the section above.
411411

412-
When an `Activity` or `Fragment` expect arguments, it should provide a `static public` method that facilitates the creation of the `Fragment` or `Intent`.
412+
When an `Activity` or `Fragment` expects arguments, it should provide a `public static` method that facilitates the creation of the relevant `Intent` or `Fragment`.
413413

414-
In the case of Activities the method is usually called `getStartIntent()`
414+
In the case of Activities the method is usually called `getStartIntent()`:
415415

416416
```java
417417
public static Intent getStartIntent(Context context, User user) {
@@ -421,7 +421,7 @@ public static Intent getStartIntent(Context context, User user) {
421421
}
422422
```
423423

424-
For Fragments it's named `newInstance()` and it handles the creation of the Fragment with the right arguments.
424+
For Fragments it is named `newInstance()` and handles the creation of the Fragment with the right arguments:
425425

426426
```java
427427
public static UserFragment newInstance(User user) {
@@ -433,18 +433,18 @@ public static UserFragment newInstance(User user) {
433433
}
434434
```
435435

436-
__Note 1__: these methods should go at the top of the class before `onCreate()`
436+
__Note 1__: These methods should go at the top of the class before `onCreate()`.
437437

438-
__Note 2__: if we provide the methods described above, the keys for extras and arguments should be `private` because there is not need for them to be exposed outside the class.
438+
__Note 2__: If we provide the methods described above, the keys for extras and arguments should be `private` because there is not need for them to be exposed outside the class.
439439

440440
### 2.2.15 Line length limit
441441

442442
Code lines should not exceed __100 characters__. If the line is longer than this limit there are usually two options to reduce its length:
443443

444-
* Extract a local variable or method (Preferable).
444+
* Extract a local variable or method (preferable).
445445
* Apply line-wrapping to divide a single line into multiple ones.
446446

447-
There are two __exceptions__ where is possible to have lines longer than 100:
447+
There are two __exceptions__ where it is possible to have lines longer than 100:
448448

449449
* Lines that are not possible to split, e.g. long URLs in comments.
450450
* `package` and `import` statements.
@@ -464,7 +464,7 @@ int longName = anotherVeryLongVariable + anEvenLongerOne - thisRidiculousLongOne
464464

465465
__Assignment Operator Exception__
466466

467-
An exception to the break at operators rule is the assignment operator `=`, where the line break should happen __after__ the operator.
467+
An exception to the `break at operators` rule is the assignment operator `=`, where the line break should happen __after__ the operator.
468468

469469
```java
470470
int longName =
@@ -487,7 +487,7 @@ Picasso.with(context)
487487

488488
__Long parameters case__
489489

490-
When a method has many parameters or its parameters are very long we should break the line after every comma `,`
490+
When a method has many parameters or its parameters are very long, we should break the line after every comma `,`
491491

492492
```java
493493
loadPicture(context, "http://ribot.co.uk/images/sexyjoe.jpg", mImageViewProfilePicture, clickListener, "Title of the picture");
@@ -527,7 +527,7 @@ public Observable<Location> syncLocations() {
527527

528528
### 2.3.1 Use self closing tags
529529

530-
When an XML element doesn't have any content, you __must__ use self closing tags.
530+
When an XML element doesn\'t have any contents, you __must__ use self closing tags.
531531

532532
This is good:
533533

@@ -541,7 +541,7 @@ This is good:
541541
This is __bad__ :
542542

543543
```xml
544-
<!-- Don't do this! -->
544+
<!-- Don\'t do this! -->
545545
<TextView
546546
android:id="@+id/text_view_profile"
547547
android:layout_width="wrap_content"
@@ -552,7 +552,7 @@ This is __bad__ :
552552

553553
### 2.3.2 Resources naming
554554

555-
Resource IDs and names are written in __lowercase_underscore__
555+
Resource IDs and names are written in __lowercase_underscore__.
556556

557557
#### 2.3.2.1 ID naming
558558

@@ -587,7 +587,7 @@ Menu example:
587587

588588
#### 2.3.2.2 Strings
589589

590-
String names start with a prefix that indentifies the section they belong to. For example `registration_email_hint` or `registration_name_hint`. If a string __doesn't belong__ to any section then you should follow the rules below:
590+
String names start with a prefix that identifies the section they belong to. For example `registration_email_hint` or `registration_name_hint`. If a string __doesn\'t belong__ to any section, then you should follow the rules below:
591591

592592

593593
| Prefix | Description |
@@ -617,22 +617,22 @@ As a general rule you should try to group similar attributes together. A good wa
617617

618618
### 2.4.1 Unit tests
619619

620-
Test classes should match the name of the class that the tests are targeting, followed by `Test`. For example, if we create a test class that contains tests for the `DatabaseHelper`, we should name it `DatabaseHelperTest`.
620+
Test classes should match the name of the class the tests are targeting, followed by `Test`. For example, if we create a test class that contains tests for the `DatabaseHelper`, we should name it `DatabaseHelperTest`.
621621

622-
Test methods are annotated with `@Test` and should generally start with the name of the method that is being tested, followed by a precondition and/or expected behaviour.
622+
Test methods are annotated with `@Test` and should generally start with the name of the method that is being tested, followed by a precondition and/or expected behaviour.
623623

624624
* Template: `@Test void methodNamePreconditionExpectedBehaviour()`
625625
* Example: `@Test void signInWithEmptyEmailFails()`
626626

627627
Precondition and/or expected behaviour may not always be required if the test is clear enough without them.
628628

629-
Sometimes a class may contain a large amount of methods, that at the same time require several tests for each method. In this case, it's recommendable to split up the test class into multiple ones. For example, if the `DataManager` contains a lot of methods we may want to divide it into `DataManagerSignInTest`, `DataManagerLoadUsersTest`, etc. Generally you will be able to see what tests belong together because they have common [test fixtures](https://en.wikipedia.org/wiki/Test_fixture).
629+
Sometimes a class may contain a large amount of methods, that at the same time require several tests for each method. In this case, it\'s recommendable to split up the test class into multiple ones. For example, if the `DataManager` contains a lot of methods we may want to divide it into `DataManagerSignInTest`, `DataManagerLoadUsersTest`, etc. Generally you will be able to see what tests belong together because they have common [test fixtures](https://en.wikipedia.org/wiki/Test_fixture).
630630

631631
### 2.4.2 Espresso tests
632632

633633
Every Espresso test class usually targets an Activity, therefore the name should match the name of the targeted Activity followed by `Test`, e.g. `SignInActivityTest`
634634

635-
When using the Espresso API is a common practise to place chained methods in new lines.
635+
When using the Espresso API it is a common practice to place chained methods in new lines.
636636

637637
```java
638638
onView(withId(R.id.view))

0 commit comments

Comments
 (0)