Skip to content

Instantly share code, notes, and snippets.

Orhan Obut orhanobut

View GitHub Profile
View Singleton.java
final class DiskPersistence {
private final static DiskPersistence instance = new DiskPersistence();
public static DiskPersistence getInstance() {
return instance;
}
private DiskPersistence() {
// prevents to create a new instance
View NullObject3.java
interface Persistence {
void delete();
void add(String value);
String get();
}
static class EmptyPersistence implements Persistence {
private static Persistence persistence;
View NullObject2.java
interface Persistence {
void delete();
void add(String value);
String get();
}
static class EmptyPersistence implements Persistence {
@Override void delete(){
}
View NullObject.java
interface Persistence {
void delete();
void add(String value);
String get();
}
class FooBar {
private Persistence persistence;
void persistence(Persistence persistence) {
View srp1.java
public class LoginFragment extends Fragment {
void onLoginClicked(){}
void makeLoginRequest(){}
void displayHome(){}
void onRegisterClicked(){}
void displayRegistrationFragment(){}
}
View staticfactor7.java
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
user = User.newUser(response.userResponse);
}
}
View staticfactor8.java
public class User {
private final String id;
private final String name;
public User(UserResponse response) {
if (response != null) {
id = response.id;
name = response.name;
}
}
View staticfactor7.java
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
UserResponse userResponse = response.userResponse;
if (userResponse != null) {
user = new User(response.userResponse);
}
View staticfactor6.java
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
user = new User(response.userResponse);
}
}
View staticfactor5.java
public class MyFragment extends Fragment {
private static final String KEY_NAME = "KEY_NAME";
public static Fragment newFragment(String name) {
Fragment fragment = new MyFragment();
Bundle bundle = new Bundle();
bundle.putExtra(KEY_NAME, name);
fragment.setArguments(bundle);
return fragment;
}
You can’t perform that action at this time.