I'm writing a structural detailing (CAD) software for concrete buildings in C#. I have defined like hundreds of static
classes each with one public method
and if needed some private methods
. Each one of these methods in these static classes does part of the job. They are called from one God static class named Building.cs
.
For example one class looks like this:
public static partial class GetMainRebars
{
public static void GetMainRebars()
{
}
// other possible variables and private methods
}
The program is running very very fast compared to other similar programs. But deep in my heart, looking at the above code I feel that something still may be wrong with this design pattern. Maybe I will encounter problems in terms of maintenance, or ...? I've taught myself programming, so I may have missed many core principles during the fast self teaching process. Can you elaborate the cons and pros of the above pattern?
And one very rookie question relevant to the pattern. Let's say I define a static variable inside such a class, will it remain in memory during the life time of the program? No disposing and whatsoever? Is it OK?
Update: When the program starts I'm loading the required variables in relevant fields and properties in the Building.cs for example listOfBeams, listOfColumns, listOfRebars, listOfConnectivities and etc. Now that these variables are in place, I used the methods in static classes to do various operations on these. Let's say I get the listOfRebars and listOfColumns in one static class and generate some variables to output. Then I get listOfRebars and listOfBeams and do some other stuff.
Update2: From what I have learned based on the answers and comments, I have come up with the below pattern. I was wondering if I'm on the right path?
I have one static class: Building.cs
When I create/or load a project this class holds all the properties of the building like list of columns, beams, points, etc. All of these are stored as private fields. I can access these using the class's public methods like GetColumns or GetPoints ...
Now I also have non-static classes. They contain 2-3 public methods. and do some stuff on various parts of the building.
public static class Building
{
private static List<Column> columns;
private static List<Beams> beams;
private static List<Points> points;
public static List<Column> GetColumns()
{
return Columns;
}
}
public class ColumnsService()
{
private List<Columns> columns;
public GroupColumns(List<Columns> columns)
{
this.columns = columns;
}
public void Group()
{
// group columns
}
}
var columns = Building.GetColumns();
var columnsService = new ColumnsService(columns);
columnsService.Group();