Name for design pattern used in complex or boolean search criteria

I am looking to see if there is a term that describes this type of design pattern or if there are well known examples of its implementation.

This is an extension of the design pattern where a search term is entered into an input field and becomes a filter/criteria for a search query (e.g. e-commerce website) or tagging of an entity (e.g. UXSE question).

In the diagram below, there are two input fields from which a user can select a combination of the values provided in each list (and it might have some logic embedded depending on the value selected). The values are then combined and presented as a lozenge/badge/chip UI element that can be selected and deleted.

enter image description here

Are there examples of this type of design pattern used anywhere? And is there a name that is commonly associated with it?

/inicio.java:23: error: incompatible types: int cannot be converted to boolean if (pergunta = ab) {

estou começando a estudar java, decidi criar um programa q conversava cmg para ir me acostumando com a sintaxe e fica dando o erro acima, o codigo eh esse aqui

import java.util.Scanner;  public class inicio { public static void main(String[] args) {  Scanner entrada = new Scanner(System.in); int a = 30; String jg = "#"; System.out.println("SEJA MUITO BEM VINDO NOVO USUARIO!!!"); System.out.println("#########################"); System.out.println("Hi, novo usuario, qual seu nome? : "); String nome = entrada.nextLine(); System.out.println(nome+" Que bonito nome! oq gosta de fazer nas horas vagas? "); String hobbies = entrada.nextLine(); System.out.println("WoW vc gosta dessas coisas tmb? sou muito fan, acho que vamos se dar bem!!"); System.out.println("OK, topa participar de uma brincadeira?"); System.out.println("[1]YES [2]NO"); int pergunta = entrada.nextInt(); String ab = "1";  if (pergunta = ab) {     System.out.println("OK!!!"); } else{         System.out.println("AINDA ESTOU DESENVOLVENDO ESSA PARTE");        }       } } 

**/ acabei de trocar a interface grafica do meu linux, meu teclado ta todo desconfigurado, nn liguem para os erros de gramatica */

Attempt to invoke virtual method ‘boolean android.widget.CheckBox.isChecked()’ on a null object reference, if com CheckBox não funciona, o que faço?

Estou com um erro que ridiculamente parece facil, mas não consigo resolver. -No meu xml tem um CheckBox retornando false(desativada), no meu java tem um simples if(termosUso.isChecked()){}, em tese era para que quando o CheckBox estivesse retornando true(selecionado), ele execultar oq estiver dentro do if ou no simplesmente dar continuidade ao programa, quando eu do um ‘Run’ ele execulta no celular mas o CheckBox não funciona, quando debugo o app aparece no console o seguinte erro quando clico no botão de registrar:

ERRO:

E/AndroidRuntime: FATAL EXCEPTION: main Process: app.conect.medicconect1, PID: 12972 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.CheckBox.isChecked()' on a null object reference     at app.conect.medicconect1.LoginActivity$  4.onClick(LoginActivity.java:178)     at android.view.View.performClick(View.java:6600)     at android.view.View.performClickInternal(View.java:6577)     at android.view.View.access$  3100(View.java:781)     at android.view.View$  PerformClick.run(View.java:25912)     at android.os.Handler.handleCallback(Handler.java:873)     at android.os.Handler.dispatchMessage(Handler.java:99)     at android.os.Looper.loop(Looper.java:193)     at android.app.ActivityThread.main(ActivityThread.java:6923)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.RuntimeInit$  MethodAndArgsCaller.run(RuntimeInit.java:493)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 

XML:

 <CheckBox             android:id="@+id/termosUso2"             android:layout_width="314dp"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:checked="false"             android:drawableRight="@drawable/icon_termo_uso"             android:text="Li e Concordo com os Termos de Uso."             android:textStyle="italic" /> 

JAVA:

package app.conect.medicconect1; 

import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.textfield.TextInputLayout; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion;

public class LoginActivity extends AppCompatActivity {

protected EditText emaillog, password;//Parte de Login protected Button login, cadastreSe, desn;//Tela de Login protected TextInputLayout txtInLayoutUsername, txtInLayoutPassword, txtInLayoutRegPassword;//2 telas (LAYOUT) protected CheckBox rememberMe;//Tela de Login private String HOST = "http://192.168.0.4/LoginApp/";//HOST da pasta do mysql para ter acesso aos arquivos protected EditText nomeCad, apelidoCad, emailCad, passwordCad, passwordConfCad;//Parte de cadastro protected Button cadastroCad;//Tela de cadastro protected CheckBox termosUso;//Tela de cadastro  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_login);      emaillog = findViewById(R.id.emaillog2);     password = findViewById(R.id.password2);     login = findViewById(R.id.login2);     cadastreSe = findViewById(R.id.cadastreSe2);     desn = findViewById(R.id.desenvolvedor2);     termosUso = (CheckBox) findViewById(R.id.termosUso2);     txtInLayoutUsername = findViewById(R.id.txtInLayoutUsername);     txtInLayoutPassword = findViewById(R.id.txtInLayoutPassword);     rememberMe = findViewById(R.id.rememberMe);      ClickLogin();      cadastreSe.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             ClickSignUp();         }     });     desn.setOnClickListener(new View.OnClickListener(){...}); }  private void ClickLogin() {...}  private void ClickSignUp() {      AlertDialog.Builder dialog = new AlertDialog.Builder(this);     LayoutInflater inflater = getLayoutInflater();     View dialogView = inflater.inflate(R.layout.register, null);     dialog.setView(dialogView);      nomeCad = dialogView.findViewById(R.id.nomeCad2);     apelidoCad = dialogView.findViewById(R.id.apelidoCad2);     passwordCad = dialogView.findViewById(R.id.passwordCad2);     passwordConfCad = dialogView.findViewById(R.id.passwordConfCad2);     emailCad = dialogView.findViewById(R.id.emailCad2);     cadastroCad = dialogView.findViewById(R.id.cadastroCad2);     txtInLayoutRegPassword = dialogView.findViewById(R.id.txtInLayoutRegPassword);      cadastroCad.setOnClickListener(new View.OnClickListener(){         @Override         public void onClick(View view) {             String nome = nomeCad.getText().toString();             String apelido = apelidoCad.getText().toString();             String email = emailCad.getText().toString();             String senha = passwordCad.getText().toString();             String senhaConf = passwordConfCad.getText().toString();             String URL = HOST + "cadastrar.php";                 if (nomeCad.getText().toString().trim().isEmpty())         {                 nomeCad.setError("Por favor, preencha este campo");             }  if (passwordCad.getText().toString().trim().isEmpty())     {                 passwordCad.setError("Por favor, preencha este campo");             }  if (apelidoCad.getText().toString().trim().isEmpty())      {                 apelidoCad.setError("Por favor, preencha este campo");             }  if (emailCad.getText().toString().trim().isEmpty())        {                 emailCad.setError("Por favor, preencha este campo");             }  if (passwordConfCad.getText().toString().trim().isEmpty()) {                 passwordConfCad.setError("Por favor, preencha este campo");             }                 if (senhaConf.equals(senha)){                 if (nome.trim().isEmpty() || apelido.trim().isEmpty() || email.trim().isEmpty() || senha.trim().isEmpty() || senhaConf.trim().isEmpty()) {                     Toast.makeText(LoginActivity.this, "Por Favor verifique se os campos estão preenchidos corretamente.", Toast.LENGTH_LONG).show();                 }else {                     if (termosUso.isChecked()) {//está é a linha 178 no java e aparecentemente a que está errada!                          Ion.with(LoginActivity.this)                                 .load(URL)                                 .setBodyParameter("nome_app", nome)                                 .setBodyParameter("apelido_app", apelido)                                 .setBodyParameter("email_app", email)                                 .setBodyParameter("senha_app", senha)                                 .asJsonObject()                                 .setCallback(new FutureCallback<JsonObject>() {                                     @Override                                     public void onCompleted(Exception e, JsonObject result) {                                         try {                                             //   Toast.makeText(cadastroActivity.this, "Nome: " + result.get("NOME").getAsString(), Toast.LENGTH_LONG).show();                                             String RETORNO = result.get("CADASTRO").getAsString();                                              if (RETORNO.equals("EMAIL_ERRO")) {                                                 Toast.makeText(LoginActivity.this, "Ops! Este email já está cadastrado", Toast.LENGTH_LONG).show();                                             } else if (RETORNO.equals("SUCESSO")) {                                                 // Toast.makeText(cadastroActivity.this, "Cadastrado com sucesso", Toast.LENGTH_LONG).show();                                                 Intent abreHome = new Intent(LoginActivity.this, homeActivity.class);                                                 startActivity(abreHome);                                             } else {                                                 Toast.makeText(LoginActivity.this, "Ops! Ocorreu um erro", Toast.LENGTH_LONG).show();                                             }                                         } catch (Exception erro) {                                             Toast.makeText(LoginActivity.this, "ops! Ocorreu um erro, " + erro, Toast.LENGTH_LONG).show();                                          }                                     }                                 });                     }else{                         Toast.makeText(LoginActivity.this, "Para continuar é preciso concordar com os termos de uso!", Toast.LENGTH_LONG).show();                     }                 } //fecha else dos camposvazios             }else {                 Toast.makeText(LoginActivity.this, "Senhas Diferentes!", Toast.LENGTH_LONG).show();                    passwordConfCad.setError("Por favor, preencha este campo");             }         }     });     dialog.show(); } 

}

Boolean switch with a third state


Note: everyone has seemed to have misunderstood this question. Literally, everyone. I am not creating some sign-up form, I am not collecting personal data. The form of which this is a part is used to filter a large list of people by certain conditions.

I have a query creator form that helps the user to create a SQL query. All the possible variations of the query are listed and the user has to pick their required variations and run the query.

Problem

For an individual, the user can choose the Gender. From the outside it seems like a Boolean operation (Male or Female) but it has one more variations.

  1. Individual is MALE
  2. Individual is FEMALE
  3. Individual’s gender should not be considered (Can be MALE or FEMALE)

I have replaced radio buttons with a Switch like this:

Screenshot of widget

How do I represent the 3rd state?

Code Design: Repeatedly doing the same Boolean check [on hold]

I have several areas in a program where I am doing the following check on the same two booleans, but each spot has different actions being taken based on the value of the booleans.

Example

if (bool1 && bool2) {   Do something;  } else if (bool1)  {   Do something else  }  else if (bool2)  {   Do something else entirely.  } 

The thought process is, if both Booleans are true, do things this way. Else if only bool1 is true, then do this bool1 specific thing. Else if only bool2 is true, then do this bool2 specific thing.

There are at least 3 places in my program where I’m doing this comparison, with the “do something” based on the Boolean values being different in each place.

Is there a way to standardize this kind of Boolean logic?

Note: The “something” that I’m doing in all of these places is several calls to StreamWriter.WriteLine() with different contents in each place, depending on the Boolean values. I’ve considered writing a method that takes in the 3 do something’s, but they are each several calls to write line, so I’m struggling with how to pass those calls as proper parameters.

Polynomial size Boolean circuit for counting number of bits

Given a natural number $ n \geq 1$ , I am looking for a Boolean circuit over $ 2n$ variables, $ \varphi(x_1, y_1, \dots, x_n, y_n)$ , such that the output is true if and only if the assignment that makes it true verifies

$ $ \sum_{i = 1}^{i = n} (x_i + y_i) \not\equiv n \bmod 3$ $

I should specify that this I am looking for a Boolean circuit, not necessarily a Boolean formula as it is usually written in Conjunctive Normal Form (CNF). This is because when written in CNF, a formula like the one before has a trivial representation where the number of clauses is approximately $ \frac{4^n}{3}$ , as it contains a clause for every assignment $ (x_1, y_1, \dots, x_n, y_n)$ whose bits sum to a value which is congruent with $ n \bmod 3$ . Constructing such a formula would therefore take exponential time.

I have been told that a Boolean circuit can be found for this formula that accepts a representation of size polynomial in $ n$ . However, so far I have been unable to find it. I would use some help; thanks.

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Yup Boolean Validation for Checkbox

I am trying to write a form using React Bootstrap and Formik, and validate the form using Yup. I want to disable a submit button until a checkbox is checked. I currently have tried .required(), but false counts as required. I have also tried .oneOf([true], 'Field must be checked'), but for some reason, this just turns the text green instead of displaying the message. I have tried .test('agree','You have to agree with our Terms and Conditions!', value => value === true) but this also passes for some reason and allows the submit button to be enabled when it is unchecked. Am I doing something wrong here, or is there another way?

import React from "react"; import { render } from "react-dom"; import { Formik, Form as Form1, withFormik } from "formik"; import * as Yup from "yup"; import { OverlayTrigger, Tooltip, Row, Col, Button, Form as Form2, Container} from 'react-bootstrap'  const schema = Yup.object().shape({   fname: Yup.string()     .max(100, "First name must be less than 100 characters")     .required("Required"),   lname: Yup.string()     .max(100, "First name must be less than 100 characters")     .required("Required"),   email: Yup.string()     .email("Must be a valid email with [name]@[domain].[com/org/net/etc]")     .required("Required"),   password: Yup.string()     .min(6, "Password must be longer than 6 characters")     .max(100, "Password must be less than 100 characters")     .required("Required"),   reenter: Yup.string()     .required("Required")     .oneOf([Yup.ref("password"), null], "Passwords must match"),   agree: Yup.boolean()     //.required("You must agree with our Terms and Conditions")     // //.test(     //   'agree',     //   'You have to agree with our Terms and Conditions!',     //   value => value === true     // )     .oneOf([true], 'Field must be checked') });  function SignUp() {   return (     <Formik       validationSchema={ schema }       onSubmit={         values => {           // same shape as initial values           console.log(values);         }       }       initialValues={{         fname: '',         lname: '',         email: '',         password: '',         reenter: '',         agree: ''       }}     >        {({         handleSubmit,         handleChange,         handleBlur,         values,         touched,         errors,       }) => (         <Container>           <Row className="justify-content-md-center">             <Col md="6">             <h1>Sign Up</h1>             <Form2 noValidate onSubmit={handleSubmit} style={{backgroundColor: 'lightgray', padding: '20px', 'borderRadius': '5px'}}>               <Form2.Group controlId="fname">                 <Form2.Label>First Name</Form2.Label>                 <Form2.Control                   type="text"                   name="fname"                   value={values.fname}                   onChange={handleChange}                   onBlur={handleBlur}                    isValid={touched.fname && !errors.fname}                   isInvalid={touched.fname && errors.fname}                   placeholder="John" />                  <Form2.Control.Feedback type="invalid">                     {errors.fname}                 </Form2.Control.Feedback>               </Form2.Group>                <Form2.Group controlId="lname">                 <Form2.Label>Last Name</Form2.Label>                 <Form2.Control                   type="text"                    name="lname"                   value={values.lname}                   onChange={handleChange}                   onBlur={handleBlur}                    isValid={touched.lname && !errors.lname}                   isInvalid={touched.lname && errors.lname}                   placeholder="Smith" />                   <Form2.Control.Feedback type="invalid">                     {errors.lname}                   </Form2.Control.Feedback>                           </Form2.Group>                <Form2.Group>                 <Form2.Label>Email address</Form2.Label>                 <Form2.Control                    type="text"                    name="email"                   value={values.email}                   onChange={handleChange}                   onBlur={handleBlur}                    isValid={touched.email && !errors.email}                   isInvalid={touched.email && errors.email}                   placeholder="example@example.com"                  />                 <Form2.Control.Feedback type="invalid">                   {errors.email}                 </Form2.Control.Feedback>                </Form2.Group>                  <Form2.Group>                   <Form2.Label style={{display:'flex'}}>                     Password                     <OverlayTrigger                       key="tooltip"                       placement="right"                       overlay={                         <Tooltip id={`tooltip-right`}>                           Password must be at least 6 characters but no more than 100 characters.                         </Tooltip>                       }                     >                     <p style={{                      width: '25px',                     height: '25px',                      'marginBottom': '0px',                     'marginLeft': '5px',                     'borderStyle': 'solid',                      'borderColor': 'black',                      'borderRadius': '50%',                     'borderWidth': '1px',                     'textAlign': 'center',                     }}>?</p>                     </OverlayTrigger>                   </Form2.Label>                     <Form2.Control                      type="password"                      name="password"                     value={values.password}                     onChange={handleChange}                     onBlur={handleBlur}                      isValid={touched.password && !errors.password}                     isInvalid={touched.password && errors.password}                     placeholder="Password"                   />                   <Form2.Control.Feedback type="invalid">                     {errors.password}                   </Form2.Control.Feedback>                 </Form2.Group>                <Form2.Group>                 <Form2.Label>Re-Type Password</Form2.Label>                 <Form2.Control                    type="password"                    name="reenter"                   value={values.reenter}                   onChange={handleChange}                   onBlur={handleBlur}                    isValid={touched.reenter && !errors.reenter}                   isInvalid={touched.reenter && errors.reenter}                 />                 <Form2.Control.Feedback type="invalid">                   {errors.reenter}                 </Form2.Control.Feedback>               </Form2.Group>                <Form2.Group>                 <Form2.Check                   required                   name="terms"                   onChange={handleChange}                   onBlur={handleBlur}                   isValid={touched.agree && !errors.agree}                   isInvalid={touched.agree && errors.agree}                   label= {["I agree to the ", <a href="">Terms of Use</a>,  " and ", <a href="">Privacy Policy</a>]}                   feedback={errors.agree}                   id="agree"                 />               </Form2.Group>                <Button                  type="submit"                 disabled={!touched.fname || errors.fname ||                    !touched.lname || errors.lname ||                   !touched.email || errors.email ||                   !touched.password || errors.password ||                   !touched.reenter || errors.reenter ||                   errors.agree                   }>Sign Up               </Button>             </Form2>             </Col>           </Row>         </Container>       )}     </Formik>   ); }  const MyEnhancedForm = withFormik({   mapPropsToValues: () => ({      name: '',     lname: '',     email: '',     password: '',     reenter: ''   }),    // Custom sync validation   validate: values => {     const errors = {};      if (!values.name) {       errors.name = 'Required';     }      return errors;   },    handleSubmit: (values, { setSubmitting }) => {     setTimeout(() => {       alert(JSON.stringify(values, null, 2));       setSubmitting(false);     }, 1000);   },    displayName: 'BasicForm', })(SignUp);  export default SignUp; 

Link to image of turning text green: https://gyazo.com/fa38b67fca1af90554f4fd325a8f4773

Rich data types – boolean object


Context

You can probably skim most of this, it’s unlikely to be useful for a review and is just for background info. Also download the files


I have a project which requires a caller to pass flag values to child procedures; these procedures may wish to edit the value of the flags, and the caller should have these changes reflected in its own copies of them. Ordinarily a perfect candidate for such a flag would be a ByRef Boolean – the parent creates an array of truthy flags and passes them ByRef to the procedures.

However this approach is messy when the number of children is dynamic; ideally a VBA.Collection of flags would be held by the parent – but collections can only add value types (like Booleans) ByVal – the changes the child procedures make to the flags will not be reflected in the content of the Collection. A workaround would be to use pointers directly, or do some clever array ReDimming, but the solution I went with was to use a Bool object in place of the Boolean flags – these can always be passed as references.


Anyway, I appreciate that’s all a bit theoretical, in fact my precise motivation isn’t really necessary right now and will be up for scrutiny in a later post with the class in use, for now though there’s only one more thing to add:

Separately, I’ve been planning to replace many of the mundane data types in VBA with some more jazzy object-y ones – a bit like python has – which will eventually allow me to create classes which determine their own responses to operations. For now though I’m mostly focusing on the data storage aspects; how my class can be used in place of the datatype it encapsulates, and later I’ll look at stuff like operator overloading and inheritance.

Here’s the main class – which can be seen as a foundation for what’s described above

Bool.cls

'@Folder("API.Utils") '@ModuleDescription("Boolean object that can be passed byRef") '@PredeclaredID Option Explicit  'NOTE RtlCopyMemory would be faster (as source and dest won't overlap) but is not exposed to VBA ''@Description("API: Destination and Source can be byVal pointers or byRef variables, length is LenB(dataType)") #If Win64 Then     Private Declare PtrSafe Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)     Private Declare PtrSafe Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByRef destination As Any, ByVal length As Long) #Else     Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)     Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByRef destination As Any, ByVal length As Long) #End If  Private Type tBool     Value As Boolean End Type  Private this As tBool  '@Description("Truthy encapsulated value") '@DefaultMember Public Property Get Value() As Boolean     Value = this.Value End Property  Public Property Let Value(ByVal newVal As Boolean)     this.Value = newVal End Property  '@Description("Create instance of Bool class from objPtr") Public Function FromPtr(ByVal pData As LongPtr) As Bool 'TODO fails in VB6 as no LongPtr     Dim result As New Bool     CopyMemory result, pData, LenB(pData)     Set FromPtr = result     ZeroMemory result, LenB(pData)               ' free up memory, equiv: CopyMemory result, 0&, LenB(pData) End Function  '@Description("Class Constructor takes Boolean or Boolean-like values") Public Function Create(ByVal initialValue As Variant) As Bool     Dim result As New Bool     result.Value = CBool(initialValue)     Set Create = result End Function 

Worth noting;

  • '@PredeclaredId; I’m using this class as a factory for instances of itself – it’ll probably go into an addin as PublicNotCreatable so requires a factory of some sort. It has 2 constructor methods, Create and FromPtr
  • No .Self; I like using With New Blah statements in the constructors like in this answer, but I thought the additional .Self method or equivalent would clutter the interface and lead to additional confusion given the next point
  • '@DefaultMember; going against all of Rubberduck’s advice, I’ve used a default member which is not a .Item method. But here I think it’s justified, as the class is meant only to be a wrapper for actual data; the class must have an intrinsic encapsulated value in order to operate correctly. And that value is all that is required to Create an indistinguishable instance of the class. I feel a default member should represent what a class is – a Bool is the value of the encapsulated variable, the point in a Collection specified by a key/ index is the item located there. A Range is not simply the value in the cell, it is also the address and the formatting and … that’s why Range’s default member is so confusing.

As well as feedback on the approach and functionality of the class, I’d really appreciate some insight on best practices regarding layout, documentation and structure of the project, as such I’ve included all the comments/attributes and here are some unit tests:

UnitTests.bas

Option Explicit Option Private Module  '@TestModule '@Folder("API.Utils.Tests")  Private Assert As Rubberduck.PermissiveAssertClass Private Fakes As Rubberduck.FakesProvider  '@ModuleInitialize Private Sub ModuleInitialize()     'this method runs once per module.     Set Assert = New Rubberduck.PermissiveAssertClass     Set Fakes = New Rubberduck.FakesProvider End Sub  '@ModuleCleanup Private Sub ModuleCleanup()     'this method runs once per module.     Set Assert = Nothing     Set Fakes = Nothing End Sub  '@TestInitialize Private Sub TestInitialize()     'this method runs before every test in the module. End Sub  '@TestCleanup Private Sub TestCleanup()     'this method runs after every test in the module. End Sub  '@TestMethod("Uncategorized") Private Sub DefaultPropertyLetGet()     On Error GoTo TestFail      'Arrange:     Dim b As New Bool     b.Value = False      'Act:     b = True      'Assert:     Assert.AreEqual True, b.Value     Assert.AreEqual True, (b) 'should just be b - this is an issue with the assert class  TestExit:     Exit Sub TestFail:     Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description End Sub  '@TestMethod("Uncategorized") Private Sub ClassConstructor()     On Error GoTo TestFail      'Arrange:     Dim a As Bool, b As Bool, c As Bool      'Act:     Set b = Bool.Create(True)     Set a = Bool.Create(False)     Set c = Bool.Create(a)                       'implicit conversion with CBool      'Assert:     Assert.AreEqual True, b.Value     Assert.AreEqual False, a.Value     Assert.AreEqual a.Value, c.Value     Assert.AreNotSame a, c                       'c only has the same value as a  TestExit:     Exit Sub TestFail:     Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description End Sub  '@TestMethod("Uncategorized") Private Sub AssigningByReferenceCanOverwrite()     On Error GoTo TestFail      'Arrange:     Dim base As Bool, copy As Bool      'Act:     Set base = Bool.Create(True)     Set copy = Bool.FromPtr(ObjPtr(base))     copy = False      'Assert:     Assert.AreEqual False, base.Value     Assert.AreSame base, copy  TestExit:     Exit Sub TestFail:     Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description End Sub  '@TestMethod("Uncategorized") Private Sub InvalidConstructionRaisesTypeMismatchError()     Const ExpectedError As Long = 13             'type mismatch     On Error GoTo TestFail      'Arrange:     Dim b As Bool      'Act:     Set b = Bool.Create("Not a boolean!")  Assert:     Assert.Fail "Expected error was not raised"  TestExit:     Exit Sub TestFail:     If Err.Number = ExpectedError Then         Resume TestExit     Else         Resume Assert     End If End Sub 

I’m not sure if I’m using these quite right; I wrote them all after I’d written the class itself. Additionally, I’ve had to qualify the default member explicitly with b.Value in the tests; I believe this is a bug/ incorrect behaviour in the Rubberduck.PermissiveAssertClass (I made a comment to that effect in the repository)