Skip to content

Commit af28053

Browse files
authored
Update project_style_guidelines.md
1 parent 1ab4ec0 commit af28053

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

project_style_guidelines.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The aim of this document is to define project guidelines. These should be follow
88

99
###1.1 Project Structure
1010

11-
When commiting work, the project should maintain the following structure:
11+
When contributing work, the project should maintain the following structure:
1212

1313

1414

@@ -23,7 +23,7 @@ When commiting work, the project should maintain the following structure:
2323
**CommonTest** - Directory containing shared test code for AndroidTest & Test
2424
**main** - Directory containing application code
2525

26-
The structure of the project should remain as documentation whenever you are modifying or adding new features.
26+
The structure of the project should remain as defined above whenever you are modifying or adding new features.
2727

2828
Using this structure allows us to keep the application code seperated from any test-related code. The CommonTest directory allows us to share classes between the functional and unit tests, such as mock model creation and dagger test configuration classes.
2929

@@ -41,15 +41,15 @@ Any classes extending an Android framework component should **always** end with
4141

4242
UserFragment, SignUpActivity, RateAppDialog, PushNotificationServer, NumberView
4343

44-
We use UpperCamelCase as this helps to seperate the words used to create the name, making it easier to read. Naming classes to end with the framework component makes it super clear as to what the class is used for. For example, if you're looking to make changes to the RegistrationDialog then this naming convention makes it super easy to locate.
44+
We use UpperCamelCase as this helps to seperate the words used to create the name, making it easier to read. Naming classes to end with the framework component makes it super clear as to what the class is used for. For example, if you're looking to make changes to the RegistrationDialog then this naming convention makes it really easy to locate that class.
4545

4646
####1.2.1 Resource Files
4747

4848
When naming resource files you should be sure to name them using lowercase letters and underscores instead of spaces, for example:
4949

5050
activity_main, fragment_user, item_post
5151

52-
This convention again makes it really easy to locate the layout for a specific file. Within android studio, the layout package is sorted in alphabetical order meaning that activity, fragment and other layout types becomes grouped - so you know where to begin looking for a layout file. Other than this, begining the file name with the component name makes it clear what component/class the layout file is being used for.
52+
This convention again makes it really easy to locate the specific layout file that you're looking for. Within android studio, the layout package is sorted in alphabetical order meaning that activity, fragment and other layout types becomes grouped - so you know where to begin looking for a file. Other than this, begining the file name with the component name makes it clear what component/class the layout file is being used for.
5353

5454

5555
####1.2.2.1 Drawable Files
@@ -107,7 +107,7 @@ Not only does this approach makes it easy to find files in the directory hierarc
107107

108108
####1.2.2.3 Menu Files
109109

110-
Menu files do not need to be prefixed with the menu_ prefix. This is because they are already in the menu package in the res directory, so it is not a requirement.
110+
Menu files do not need to be prefixed with the menu_ prefix. This is because they are already in the menu package in the resources directory, so it is not a requirement.
111111

112112
####1.2.2.4 Values Files
113113

@@ -136,9 +136,9 @@ This gives no information to both the developer and the user, making it harder t
136136

137137
public void setCount(String count) {
138138
try {
139-
mCount = Integer.parseInt(id);
139+
count = Integer.parseInt(id);
140140
} catch (NumberFormatException e) {
141-
mCount = 0;
141+
count = 0;
142142
Log.e(TAG, "There was an error parsing the count " + e);
143143
DialogFactory.showErrorMessage(R.string.error_message_parsing_count);
144144
}
@@ -168,7 +168,7 @@ Catching exceptions generally should not be done:
168168

169169
Why?
170170

171-
*Do not do this. In almost all cases it is inappropriate to catch generic Exception or Throwable (preferably not Throwable because it includes Error exceptions). It is very dangerous because it means that Exceptions you never expected (including RuntimeExceptions like ClassCastException) get caught in application-level error handling. It obscures the failure handling properties of your code, meaning if someone adds a new type of Exception in the code you're calling, the compiler won't help you realize you need to handle the error differently. In most cases you shouldn't be handling different types of exception the same way.* - Android Code Style Guidelines
171+
*Do not do this. In almost all cases it is inappropriate to catch generic Exception or Throwable (preferably not Throwable because it includes Error exceptions). It is very dangerous because it means that Exceptions you never expected (including RuntimeExceptions like ClassCastException) get caught in application-level error handling. It obscures the failure handling properties of your code, meaning if someone adds a new type of Exception in the code you're calling, the compiler won't help you realize you need to handle the error differently. In most cases you shouldn't be handling different types of exception the same way.* - taken from the Android Code Style Guidelines
172172

173173
Instead, catch the expected exception and handle it accordingly:
174174

@@ -220,7 +220,7 @@ Using try-catch statements improves the readability of the code where the except
220220

221221
####2.1.5 Never use Finalizers
222222

223-
*There are no guarantees as to when a finalizer will be called, or even that it will be called at all. In most cases, you can do what you need from a finalizer with good exception handling. If you absolutely need it, define a close() method (or the like) and document exactly when that method needs to be called. See InputStreamfor an example. In this case it is appropriate but not required to print a short log message from the finalizer, as long as it is not expected to flood the logs.* - (Android code style guidelines)
223+
*There are no guarantees as to when a finalizer will be called, or even that it will be called at all. In most cases, you can do what you need from a finalizer with good exception handling. If you absolutely need it, define a close() method (or the like) and document exactly when that method needs to be called. See InputStreamfor an example. In this case it is appropriate but not required to print a short log message from the finalizer, as long as it is not expected to flood the logs.* - taken from the Android code style guidelines
224224

225225

226226

@@ -394,7 +394,7 @@ For blocks, 4 space indentation should be used:
394394

395395

396396
if (userSignedIn) {
397-
mCount = 1;
397+
count = 1;
398398
}
399399

400400
Whereas for line wraps, 8 spaces should be used:
@@ -551,7 +551,7 @@ We do this as it makes the statement easier to read, for example the statement '
551551

552552
The scope of local variables should be kept to a minimum (Effective Java Item 29). By doing so, you increase the readability and maintainability of your code and reduce the likelihood of error. Each variable should be declared in the innermost block that encloses all uses of the variable.
553553

554-
Local variables should be declared at the point they are first used. Nearly every local variable declaration should contain an initializer. If you don't yet have enough information to initialize a variable sensibly, you should postpone the declaration until you do. - (Android code style guidelines)
554+
Local variables should be declared at the point they are first used. Nearly every local variable declaration should contain an initializer. If you don't yet have enough information to initialize a variable sensibly, you should postpone the declaration until you do. - taken from the Android code style guidelines
555555

556556

557557
####2.2.12 Unused elements
@@ -560,7 +560,7 @@ All unused **fields**, **imports**, **methods** and **classes** should be remove
560560

561561
####2.2.13 Order Import Statements
562562

563-
We use Android Studio, so imports should always be ordered automatically. However, in the case that they aren’t, then the following applies:
563+
Because we use Android Studio, so imports should always be ordered automatically. However, in the case that they may not be, then they should be ordered as follows:
564564

565565

566566
1. Android imports
@@ -570,8 +570,8 @@ We use Android Studio, so imports should always be ordered automatically. Howeve
570570

571571
**Note:**
572572

573-
- Imports should be alphabetically ordered within each grouping, with capital letters before lower case letters (e.g. Z before a).
574-
- There should be a blank line between each major grouping (android, com, junit, net, org, java, javax).
573+
- Imports should be alphabetically ordered within each grouping, with capital letters before lower case letters (e.g. Z before a)
574+
- There should be a blank line between each major grouping (android, com, junit, net, org, java, javax)
575575

576576
####2.2.14 Logging
577577

0 commit comments

Comments
 (0)