I have been reading the book Clean Code
and it says that function arguments should not more than 2, anything more than that is confusing for anyone using my function. My question is, how does this apply to immutable classes?. Lets say for example that I have something like the following:
public class Song
{
private readonly string name;
private readonly double price;
private readonly string owner;
private readonly int id;
public string Name{get{return name;}}
public double Price{get{return price;}}
public string Owner{get{return owner;}}
public int Id{get{return id;}}
public Song(string name, double price, string owner, int id)
{
this.name = name;
this.price = price;
this.owner = owner;
this.id = id;
}
}
I have 4 parameters in my constructor and this does not look clean, is there a better way to create an immutable class? or maybe im putting too much thought into it and should not worry about this.