I'm putting together some classes as a model for some information (that I'm currently pulling from a website).
The classes are implemented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (Because I like F#, and it works nice for webscraping.)
So since I'm working functionally (I seems to always work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil).
So all there data fields have only private setters but this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is a lot. And I don't think F# supports object property initialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
Also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? Or is that not actually a thing you can do?
Related questions:
I'm putting together some classes as a model for some information (that I'm currently pulling from a website).
The classes are implemented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (Because I like F#, and it works nice for webscraping.)
So since I'm working functionally (I seems to always work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil).
So all there data fields have only private setters but this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is a lot. And I don't think F# supports object property initialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
Also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? Or is that not actually a thing you can do?
Related questions:
I'm putting together some classes as a model for some information (that I'm currently pulling from a website).
The classes are implemented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (Because I like F#, and it works nice for webscraping.)
So since I'm working functionally (I seems to always work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil).
So all there data fields have only private setters but this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is a lot. And I don't think F# supports object property initialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
Also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? Or is that not actually a thing you can do?
Related questions:
Immutable Purepure data classes. with public Setterssetters on properties
Ok, so I'm putting together some classes as a Modelmodel for some information (that I'm currently pulling from a website).
The classes are implimentedimplemented in C# - because in the current version of F# there are no autoimplemented properties. The The logic to fill these classes from the website is going to be writen in F#. (becauseBecause I like F#, and it works nice for webscraping).)
So since I'm working functionally (I seems to alwayalways work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil) So.
So all there data fields have only private setters. But but this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is alot)a lot. And I don't think F# supports object property intitialisersinitialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is Is this good practice? Am I thinking this right?
alsoAlso: I I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? orOr is that not actually a thing you can do?
Related questions:immutability-and-public-readonly-fields how-to-avoid-too-many-parameters-problem-in-api-design
Immutable Pure data classes. with public Setters on properties
Ok, so I'm putting together some classes as a Model for some information (that I'm currently pulling from a website)
The classes are implimented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (because I like F#, and it works nice for webscraping).
So since I'm working functionally (I seems to alway work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil) So all there data fields have only private setters. But this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is alot) And I don't think F# supports object property intitialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? or is that not actually a thing you can do?
Related questions:immutability-and-public-readonly-fields how-to-avoid-too-many-parameters-problem-in-api-design
Immutable pure data classes with public setters on properties
I'm putting together some classes as a model for some information (that I'm currently pulling from a website).
The classes are implemented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (Because I like F#, and it works nice for webscraping.)
So since I'm working functionally (I seems to always work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil).
So all there data fields have only private setters but this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is a lot. And I don't think F# supports object property initialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
Also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? Or is that not actually a thing you can do?
Related questions:
Ok, so I'm putting together some classes as a Model for some information (that I'm currently pulling from a website)
The classes are implimented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (because I like F#, and it works nice for webscraping).
So since I'm working functionally (I seems to alway work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil) So all there data fields have only private setters. But this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is alot) And I don't think F# supports object property intitialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? or is that not actually a thing you can do?
Related questions: immutability-and-public-readonly-fields how-to-avoid-too-many-parameters-problem-in-api-design
Ok, so I'm putting together some classes as a Model for some information (that I'm currently pulling from a website)
The classes are implimented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (because I like F#, and it works nice for webscraping).
So since I'm working functionally (I seems to alway work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil) So all there data fields have only private setters. But this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is alot) And I don't think F# supports object property intitialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Related questions: immutability-and-public-readonly-fields how-to-avoid-too-many-parameters-problem-in-api-design
Ok, so I'm putting together some classes as a Model for some information (that I'm currently pulling from a website)
The classes are implimented in C# - because in the current version of F# there are no autoimplemented properties. The logic to fill these classes from the website is going to be writen in F#. (because I like F#, and it works nice for webscraping).
So since I'm working functionally (I seems to alway work functionally there days even in C#). I don't want these objects to be mutable. Setting mutable fields is ugly in F# (and for good reason, mutable objects are evil) So all there data fields have only private setters. But this makes my constructors long. I planned to be using named arguments in them anyway, but still 5 arguments is alot) And I don't think F# supports object property intitialisers anyway.
public class PopularitySplitClassOptionSet : IClassOptionsSet
{
public PopularitySplitClassOptionSet (string description, IEnumerable<ClassOption> popularClasses, IEnumerable<ClassOption> unpopularClasses, int reqPreferences, int minUnpopularPreferences)
{
PopularClasses = popularClasses;
UnpopularClasses = unpopularClasses;
RequiredPrefereces = reqPreferences;
MinUnpopularPrefereces = minUnpopularPreferences;
}
public IEnumerable<ClassOption> Classes
{
get
{
return PopularClasses.Concat(UnpopularClasses);
}
}
public int RequiredPrefereces { get; private set; }
public int MinUnpopularPrefereces { get; private set; }
public int MaxPopularPrefereces {
get
{
return RequiredPrefereces - MinUnpopularPrefereces;
}
}
public IEnumerable<ClassOption> PopularClasses { get; private set; }
public IEnumerable<ClassOption> UnpopularClasses { get; private set; }
}
Edit: Is this good practice? Am I thinking this right?
also: I wonder if:
public readonly int RequiredPrefereces { get; private set; }
would be better? or is that not actually a thing you can do?
Related questions: immutability-and-public-readonly-fields how-to-avoid-too-many-parameters-problem-in-api-design