Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
class ImageFetcher | |
EXCLUDES = [ | |
"http://a2.behance.net/img/site/grey.png" | |
] | |
def self.get_all_img_src(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ApiEndpointInterface { | |
//Example of the implementation | |
@FormUrlEncoded | |
@POST("{token}/pay/cash?sandbox=1") | |
Call<ResponseBody> orderProducts(@Path("token") String token, | |
@QueryMap Map<String, String> map, | |
@Field("address") String addressId); | |
} |
Answer: As a user navigates through, out of, and back to your app, the Activity instances in your app transition through different states in their lifecycle.
To navigate transitions between stages of the activity lifecycle, the Activity class provides a core set of six callbacks: onCreate()
, onStart()
, onResume()
, onPause()
, onStop()
, and onDestroy()
. The system invokes each of these callbacks as an activity enters a new state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Driven Development | |
Main Principle: Write the test case before the implementation of the function (only for unit tests) | |
Convention: | |
1. You should only have one assertion per test case | |
- Why? Because we immediately want to know the cause of the failed test case | |
- Note: Sometimes there is no way around having multiple assertions. | |
Steps: |