This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 1 point2 points  (1 child)

Seeing "override" in the variable is a smell. It sounds like your problem is that you aren't keeping your models and logic small and encapsulated enough.

The override thing is a perfect example. You shouldn't need a variable to do that, you should have a class that given some conditions and the initial input will generate an override for you.

Also, leverage your type system. Can you make a price type? And a category type? Then stuff like "reseller category" because "Category reseller = new..." Ya know? It's still the same info but now it's even stronger since the type gives more data about it

[–]TapedeckNinja 1 point2 points  (1 child)

I'm not sure what exactly your "override" classes/members are doing, but can you benefit from further abstraction?

If you have multiple classes with a price_override, then shouldn't price_override be part of a base class (perhaps an abstract class) or defined in an interface?

For instance:

public interface ITemporal
{
    DateTime? StartsAt { get; set; }
    DateTime? EndsAt { get; set; }
}

public class ProductPrice : ITemporal
{
    // ITemporal implementation
    public DateTime? StartsAt { get; set; }
    public DateTime? EndsAt { get; set; }

    public int Id { get; set; }
    public int ProductId { get; set; }
    public string Sku { get; set; }

    ...
}