Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

I have a web filter that I only want to execute when debug level is enabled. I was trying to implement a dummy filter to return to conform to Null Object pattern but I was getting many errors and lost ...
MilaHalina's user avatar
1 vote
0 answers
60 views

Im trying to write a simple code to implement the Singleton and object null patterns. the code should check if the new customer has a name, if yes put it in the real customer, and if not in the ...
Felix Hajj's user avatar
1 vote
1 answer
174 views

TL;DR : Should we use fn(Interface* pMaybeNull) or fn(Interface& maybeNullObject) -- specifically in the case of "optional" function arguments of a virtual/abstract base class? Our code ...
Martin Ba's user avatar
  • 39.4k
0 votes
0 answers
53 views

I have a method that returns a List. E.g. List<Foo> getItems(Bar bar, X x) I don't want the method to return null to avoid null pointer exception and do something like: List<Foo> getItems(...
Jim's user avatar
  • 4,529
2 votes
2 answers
1k views

Suppose I wanted to implement a null object pattern of a model so as to guarantee an object that will do nothing, without requiring null checks on nullable fields. interface Model( val textId: Int,...
Adam Munro's user avatar
0 votes
0 answers
65 views

My main activity (MainActivity) contains Recycler view with list of images and text in cardview. I am trying to put separate onCLick listener on each cardview so that when any card view is clicked, ...
summyia haris's user avatar
24 votes
18 answers
50k views

I am creating a object of Microsoft.Web.WebView2.WinForm.WebView2 but the sub obect of this coreWebView2 is null Microsoft.Web.WebView2.WinForm.WebView2 webView = new Microsoft.Web.WebView2.WinForm....
Abbas Tambawala's user avatar
0 votes
2 answers
3k views

I am trying to serializing a POCO object into an update request. My unset values are serialized as null, which causes them to be updated to null. If I set IgnoreNullValues to true this fixes the ...
Julie Anne Moore's user avatar
17 votes
2 answers
18k views

Is there any way to do Null Objects with Java Records? With classes I'd do it like that: public class Id { public static final Id NULL_ID = new Id(); private String id; public Id(String id) { ...
atamanroman's user avatar
  • 11.9k
1 vote
1 answer
327 views

I am using value objects as identities and would like to know how to best deal with nulls in EF core. For example if I have an employee with an optional title (mr, mrs, etc): public class Employee : ...
Newm's user avatar
  • 1,423
0 votes
2 answers
101 views

Let's say we have following DTO object which is representation of a record in a database: public class UserDto { public int Id { get; set; } public DateTime? ExpireOn { get; set; } } So Id ...
Rok's user avatar
  • 805
0 votes
1 answer
95 views

I am trying to only slightly change the poison of an object that is whipped to a null thisComp.add(125,250).layer("Null 1").transform.position and it wouldn't work. right now a null is making sure ...
Zachary Blumstein's user avatar
0 votes
1 answer
299 views

In javascript re-introduction, I went through 2 examples that I have no clue when or where to use them. Below a quote: The && and || operators use short-circuit logic, which means whether ...
Mohammad Mhsoun's user avatar
1 vote
3 answers
587 views

class Foo(val param1: String, var param2: Int) { // class body companion object { val NULL = Foo("", 0) } } Is the NULL object valid in Kotlin? Although ...
Extreme Programming's user avatar
-1 votes
1 answer
120 views

It says that my getOutletId() is null references and i already declared, i think. So basically this is a booking step 4. For the first step, user need to choose outlet from firestore and choose which ...
Shotnox's user avatar
3 votes
3 answers
376 views

Which is most efficient: using a null object, or a branch on nullptr. Example in C++: void (*callback)() = [](){}; // Could be a class member void doDoStuff() { // Some code callback(); ...
user877329's user avatar
  • 6,296
1 vote
2 answers
336 views

I found this question which implements a null object pattern in Kotlin in a certain way. I usually do it a little different in Java: class MyClass { static final MyClass INVALID = new MyClass(); ...
Bart Friederichs's user avatar
0 votes
1 answer
485 views

I have some DTO object for transfer data with WCF. public class Foo { //Many fields } WCF service method returns this object, and I have the valid case when this object should be null. I want to ...
nuclear sweet's user avatar
0 votes
0 answers
65 views

I have a problem with my code, where sometimes I get a null object reference and sometimes not (on the same thing) and I cant understand whats the problem because as I said, one time its working fine ...
JTT511's user avatar
  • 23
0 votes
0 answers
40 views

Sometimes users prefer not to disclose marital status, which is fine in my domain. So I have data where user is either married or not and I have data where I don't know the status. My goal is to make ...
Waku-2's user avatar
  • 1,206
3 votes
2 answers
2k views

First of all, I’m not sure whether the topic belongs to StackOverflow or not. However, I’ve found some discussions regarding other programming languages that addresses the topic on StackOverflow but ...
Mani's user avatar
  • 783
3 votes
4 answers
7k views

I have a Kotlin data class: data class PaymentAccount( val accountId: Int, val accountNumber: String, val title: String ) This is what I'd do in Java: Create an abstract class: public ...
Johnny Five's user avatar
  • 1,018
2 votes
1 answer
1k views

public class ShowBPGraphActivity extends AppCompatActivity { public GraphView graphView; public LineGraphSeries <DataPoint>lineGraphSeries; public String systolicbp; public String diastolicbp; ...
Sibtain's user avatar
  • 33
3 votes
2 answers
449 views

interface Parent{ void process(); } class Child1 implements Parent{ void process(){ //process by method 1 } } class Child2 implements Parent{ void process(){ //process ...
prakhar3agrwal's user avatar
3 votes
1 answer
2k views

Using Typescript for an Angular ngrx application, i have to do a lot of checks wether a value i access or get passed is null/undefined, eg calling .map() on a list that might exist. What is the way ...
SchreiberLex's user avatar
1 vote
5 answers
1k views

I'm using the Null Object pattern in my Rails application to implement the concept of a guest user account. Like many apps, I have a method on ApplicationController called current_user. In the case ...
metahamza's user avatar
  • 1,475
-1 votes
1 answer
531 views

So really happy with connecting to the DB and all that. My Grid object is fine and showing all records etc. Really happy with SQL. And the concept "DBs are all about sets" My issue is: I create an ...
AlwaysLearning's user avatar
2 votes
0 answers
808 views

I have a class Person with an Enum for a property. It is a non-nullable Enum. I have some new requirements and I can easily take care of them by introducing a Null Object NullPerson with all the ...
Robotronx's user avatar
  • 1,818
-1 votes
1 answer
338 views

I know I could wrap the entire foreach loop in an if statement, but I'm wondering if there's some object literal value replacement for new List<string>() so that the foreach skips executing when ...
Zachary Scott's user avatar
2 votes
1 answer
76 views

I was wondering if the null object pattern could actually make debugging more difficult in certain cases. For example, if a method returns an "empty" object rather than a null then it will not throw ...
Samuel Jones's user avatar
8 votes
3 answers
7k views

After Reading: Effective Java (See Item 43) - Joshua Bloch Clean Code (Don't Return Null) - Uncle Bob Avoiding != null statements Null Object pattern I was looking for an answer to the question ...
Ye Win's user avatar
  • 2,118
1 vote
2 answers
82 views

Suppose we have Book class which contains year_published public field. If I want to implement NullObject design pattern, I will need to define NullBook class which behaves same as Book but does not do ...
Mahdi's user avatar
  • 2,355
2 votes
2 answers
523 views

The Interface Segregation principle states that: Clients should not be forced to depend on methods that they do not use. In the Null object pattern the Null class that implements the interface does ...
Mahmut's user avatar
  • 33
6 votes
2 answers
4k views

I'm not even sure if I have a problem, but I just don't like that my text_fields and text_areas get saved in the db as empty string instead of nil. I'm playing with the null object pattern and just ...
Sean Magyar's user avatar
  • 2,380
0 votes
2 answers
53 views

I coded this little Template-NullObject in Java and wanted to ask you wether it would be considered a sin to use one of these. When creating a NullObject, you typically make one which was specifically ...
Jan Schultke's user avatar
  • 43.7k
2 votes
1 answer
2k views

Till now I have seen everywhere that the steps to create Null Object Pattern, for example in BST to remove null checks, are as follows: Create an interface Node Create two classes implementing the ...
Nazgul's user avatar
  • 83
-1 votes
2 answers
122 views

I'm building an Entity-Component system using template metaprogramming. I keep getting either Cannot convert from [base type] to [type user requested]& or Cannot convert NullComponent to [type ...
Casey's user avatar
  • 11k
1 vote
2 answers
2k views

I have a model that has several attributes that are optional when the model is being saved. I have several instance methods that use these attributes and perform calculations but I would like to ...
Sam Mason's user avatar
  • 1,037
4 votes
1 answer
161 views

Yea, that may sound a bit ambitious but here is what I want to achieve: I have class which holds my hot Observable, it takes some time for class to prepare it correctly (create it in another place ...
Than's user avatar
  • 2,769
5 votes
1 answer
223 views

For rails applications: does there exist a naming convention for naming your null objects that are mapped to model objects? Example: #app/models/blog.rb class Blog < ActiveRecord::Base end #app/...
Neil's user avatar
  • 4,740
4 votes
0 answers
768 views

We've implemented the null object pattern in our domain model. We're using code first with fluent api to persist our domain model. One of our entities has a navigation property - this navigation ...
Steve's a D's user avatar
  • 3,821
25 votes
6 answers
8k views

There seems to be a growing community of people saying that you should never return null and should always use the Null Object Pattern instead. I can see the usefullness of the NOP when using a ...
TigerBear's user avatar
  • 2,894
2 votes
3 answers
2k views

Using Constructor Injection, a dependency gets injected to a consumer like this (at least I hope I understood it correctly): public class SomeConsumer { private IDependency someDependency; ...
Thaoden's user avatar
  • 3,600
1 vote
1 answer
4k views

I'm writing tests for a rails view, lets say the view is something like: show.json.rep r.element :user, @user do |u| r.element :id, u.id r.element :somefield1, u.somefield1 // a lot of ...
Freewind's user avatar
  • 199k
0 votes
2 answers
178 views

I'm trying to use the Null-Objects from guava in the following method: private void display(Optional<String> message) { ... } The method in which I am calling the method display(..) looks ...
Mirco Widmer's user avatar
  • 2,149
2 votes
3 answers
119 views

The problem I'm having has already been asked before: How to implement an interface with an enum, where the interface extends Comparable? However, none of the solutions solve my exact problem, which ...
durron597's user avatar
  • 32.4k
0 votes
1 answer
155 views

I'm trying to use the null object pattern in a doubly linked list in c++, but I can't seem to find a way to use it while keeping the code clean. The problem lies in the following piece of code: node-...
Danny Shemesh's user avatar
3 votes
1 answer
171 views

I’m currently building a generic state machine and I’m using the constructor of the StateMachine with a generic parameter to set the fallback state at creation, in the event that there is nothing for ...
10001110101's user avatar
2 votes
1 answer
279 views

I have something like this: boost::function<void(void)> redStyle = boost::bind(colorStyle, "red"); boost::function<void(void)> blueBlinkingStyle = boost::bind(animatedStyle, "blue", ...
Baz's user avatar
  • 13.3k
2 votes
1 answer
510 views

I'm trying to write a NullObject creation method, where I pass in a class name that implements an ICreateEmptyInstance interface (that is empty) and it walks it's properties looking for other classes ...
CaffGeek's user avatar
  • 22.2k