-
Notifications
You must be signed in to change notification settings - Fork 396
Refactoring Passes
amirroth edited this page Apr 21, 2022
·
8 revisions
We have been working in the C++ version of EnergyPlus for almost ten years now, but the code still has a lot of "Fortran" in it. There have been a few targeted refactoring efforts focused on specific areas (e.g., plant) and there will be more, but a few sweeps through the code to remove some old idioms and replace with new and better ones will create a better environment in which to perform those future efforts and establish new patterns that new and updated code can mimic. I estimate that we need to do about 12-15 passes of various "sizes". The way I would characterize the size of a pass is:
- small: can be done by one person in two months or less.
- medium: can be done by two people in one iteration or less.
- large: requires more than two people and/or more than one iteration. Here are the passes that I am thinking of along with my effort estimates, which may be completely off. I've tried to order them "topologically", i.e., the ones that don't depend on other passes first.
-
Enum. Medium. This pass is already underway and about 60% completed. It consists of three sub-passes. The first converts collections of
constexpr int
constants intoenum class
enumerations with a standard format in which the first item isInvalid = -1
and the last item isNum
. This part may require some thinking and rejiggering (technical term) as in several places the code exhibits an undue reliance on the actual values of enumerations rather than on their symbolic names. The second sub-pass creates aconstexpr std::array<std::string_view, static_cast<int>(ec::Num)> = ecNamesUC = {};
array of upper-cased names for eachenum class ec
that appears in the IDF and replaces theif-else
ladders used to convert the enumeration strings to their values with calls tostatic_cast<ec>getEnumerationValue(str, ecNamesUC);
. The third sub-pass replaces theSELECT_CASE_var
if-else
ladders that use these enumerations withswitch
/case
statements. - EPVector. Small.
- Namespace. Small.
- epJSON. Large.
- Insensitive. Small.
- Initialization. Large.
- Unstring. Medium.