Skip to content

Instantly share code, notes, and snippets.

ItemClickSupport.addTo(recyclerView3).setOnItemLongClickListener(object: ItemClickSupport.OnItemLongClickListener {
// Press alt + enter and click implement methods
})
  1. Naming concern: Semantically, how does a SubmitButton have a TextField. Text makes sense as it could be the name of the SubmitButton itself. A more ideal name just looking at the class would be Form having a Text field and an InputField
  2. No encapsulation:
    1. All instance variables are public allowing users of object to freely mess with the state, thus putting the object in an erroneous state. Better make them private and expose constructors to initialise.
    2. Also if possible it is better to make the instance variables final reduce unnecessary state change, unless it is explicitly needed to to make them mutable.
    3. It is better to make the class final to prevent unnecessary inheritance unless required.
    4. Null concerns: I'm not sure of the best practice to prevent nullability in C#. One way is to fail fast in the constructor itself:
    // Approx Java code
    public class SubmitButton(Text text, TextField inputField) {