openrails icon indicating copy to clipboard operation
openrails copied to clipboard

Refactor TrainCar part 1

Open twpol opened this issue 2 years ago • 3 comments

Refactor TrainCar

Roadmap: https://trello.com/c/rA9gu11Q/526-refactor-traincar-to-simplify-inheritance Discussion: http://www.elvastower.com/forums/index.php?/topic/36050-refactor-traincar-to-simplify-inheritance/

For the first refactoring I have chosen a couple of small parts: animated couplers and animated air hoses

Statistics

These statistics will be included with each refactoring part to demonstrate the improvements to the code (less code, same or more comments), which have been calculated using the scc (https://github.com/boyter/scc) tool

Bytes Comments Code File
+756 +5 +7 Source/Orts.Parsers.Msts/STFReader.cs
+160 0 +2 Source/Orts.Simulation/Orts.Simulation.csproj
-988 +1 -28 Source/Orts.Simulation/Simulation/Physics/Train.cs
+1,238 +16 +17 Source/Orts.Simulation/Simulation/RollingStocks/Coupling/AnimatedAirHose.cs
+1,129 +16 +15 Source/Orts.Simulation/Simulation/RollingStocks/Coupling/AnimatedCoupler.cs
-3,783 +4 -52 Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs
-1,847 0 -37 Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs
-385 0 -7 Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs
-3,720 +42 -83 Total

Note

I am starting the PR with the not-for-unstable label because it will likely conflict with #569 until that one is merged

twpol avatar Aug 10 '22 20:08 twpol

I am starting the PR with the not-for-unstable label because it will likely conflict with https://github.com/openrails/openrails/pull/569 until that one is merged.

#569 was merged a few days ago :-)

cjakeman avatar Aug 11 '22 07:08 cjakeman

For the first refactoring I have chosen a couple of small parts: animated couplers and animated air hoses

Comparing "before" and "after" is going to be interesting. Hoping to see see what professional practice looks like, so thanks for sharing.

cjakeman avatar Aug 11 '22 07:08 cjakeman

Comparing "before" and "after" is going to be interesting. Hoping to see see what professional practice looks like, so thanks for sharing.

This is simple extraction of repetitive data, but things will get more interesting with time :)

twpol avatar Aug 12 '22 18:08 twpol