Sunday 2 April 2017

7 Easy Code Tricks Android Development - Part - I

Here we go through the six easy tricks to reduce our code time.  This IDE's facilitates our work to get done in a quick time.

  1. Auto-Generate the parameterized constructor
  2. Auto-Generate the Getter and Setter Method
  3. Quick Walk-through on the documentation of android classes and methods
  4. Play around the bookmarks
  5. Generate documentation comments to the user defined methods. 
  6. Rename the text and reflect them to all places.
  7. Shortcut to set comments.
1. Auto-Generate the parameterized constructor:  We can simply presses the shift key twice in the code area it will brings you the popover search, there we need to key a search term as "constru....".  Select the constructor and then it will put you to the choose fields section, here select your necessary fields which you want to make as a parameters to the constructor.  After selecting click "ok" to generate the constructor, if you want an empty constructor just select an option "Select none". 

2. Auto-Generate the Getter and Setter Method:  Same as above, press the shift key twice on the code area and key the search term as "Getter and Set...", there you can find an option "Getter and Setter" also we can select either Getter or Setter  to generate those methods.  once selecting that option we need to choose the fields to which we required the set and get methods.


3. Quick Walk-through on the documentation of android classes and methods:  Select or keep cursor on the classes or methods and press the shortcut key "Ctrl+Q".

4. Play around the bookmarks: This is good feature on the coding part help us to switch immediately to the line of code, no need to worry about where we are in the project or files.  Once we presses the bookmark id. it will immediately takes you to the line of code.   In order to set the Bookmark, place the cursor to the line of code and press Ctrl+Shift+<ID which sounds the number between 1 to 9>.  Same the way we need to use the same shortcut id to remove the bookmark. Importantly if you use the same bookmark Id on the other places, the previous one will be get deleted.
  • Set - Ctrl+Shift+<ID 1 to 9>
  • Goto Bookmark - Ctrl+<ID>
  • Remove - Ctrl+Shift+<ID 1 to 9>

5. Generate documentation comments to the user defined methods: The documentation for the user defined is more important, it helps the other to review our code and finds the usage details of the params and returning values and it is a adds value to the business logic as well.   Simply place the cursor above the method and put /** <Press Enter>  This will gives you the documentation template where we can fill-up with the description details. 

6. Rename the text and reflect them to all places: Normally most of the developer faces this problem they have created a variable or method or class names, they intended to change i.e. rename that and this needs to be impact on all part of the project without any glitches. 

7. Shortcut to set comments: It is a general things we can use the below key shortcuts to comment the line of codes. 
  • Single - Ctrl+/
  • Select Multiple line - Ctrl+Shift+/

No comments: