Skip to content

Consider adding nil guards in intermediate models #83

@fmartingr

Description

@fmartingr

Rant: Not sure if idiomatic or not, but I wonder if we should start considering nil in all these util functions around the project.

For example, this is completely valid code:

var foo *SlackPost = nil;
if (foo.IsPlainMessage()) {
    ...

But it will create a panic in execution.

If we were to add a line here like:

if p == nil {
    return false
}

There will be no panic in execution.

There are people that would claim that a panic in execution is fine, since it means we are using the function wrong, and it is better to "fail soon and fail hard".

Others may claim that a panic in execution cannot be accepted.

But then in many places (not the case here from what I saw) we have checks like foo != nil && foo.IsPlainMessage(). So I wonder if it is a pattern we should start using.

Originally posted by @larkox in #75 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions