Reputation: 2416
I have a simple C# ctor, which initializes some variables:
public RSSSourceData()
{
RSSVersion = "";
ChannelTitle = "";
ChannelLink = "";
ChannelDescription = "";
Category = "";
Copyright = "";
Language = "";
PubDate = "";
ManagingEditor = "";
FileToProcess = "";
OnlineSource = "";
}
All the variables are string
variables.
When I ran the Code Metric for the entire project, for this ctor I get a Maintainability Index of 57. I expected it to be much higher, because there is nothing so complex that requires too much maintenance work in attributing values to variables.
What am I doing wrong here?
Later edit: the declaration of the class fields is:
class RSSSourceData
{
public string RSSVersion;
public string ChannelTitle;
public string ChannelLink;
public string ChannelDescription;
public string Category;
public string Copyright;
public string Language;
public string PubDate;
public string ManagingEditor;
public List<string> NewsTitle = new List<string>();
public List<string> NewsLink = new List<string>();
public List<string> NewsDescription = new List<string>();
private string OnlineSource;
private string FileToProcess;
private List<string> FileContent = new List<string>();
(...methods come here)
Upvotes: 1
Views: 261
Reputation: 7036
A quick answer is that it's affected by lines of code.
A long answer is that it's really hard to maintain.
Upvotes: 1
Reputation: 765
Fields has been initialized with contsants. In your example they are empty. In common case they will have some values.
So if you need to change initial values you will need to dive into source code.
That is why maintainability is high.
Upvotes: 1