greeduomacro / pandorasbox3

Automatically exported from code.google.com/p/pandorasbox3
0 stars 0 forks source link

Refactoring Pandora.cs #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The are subclasses that can be better in own .cs files.
Like a ProfileManager or the StaringContex

Original issue reported on code.google.com by Tarion86 on 23 Feb 2009 at 2:43

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I thought about the refactoring of the Pandora.cs because it's very unclear and 
many
parts should be in own capped classes. So here is the result :)
I think the best way is to "re"implement the subsystems in their own classes, 
step by
step.

With this report I commit the StartingContext.cs which already contain the
StartingContext class that was placed in the Pandora.cs

Targets of refactoring:
Loose GUI dependencies - Here is much more to do.
Cleanup Pandora.cs for a better code overview
Modularization of the program parts

Pandora.cs refactoring
======================
Note: Alle current props and functions of Pandora.cs are listet here.

Format:
<System Name>: <System description> 
[-> <what to do with this system>]
<part in Pandora.cs> [[- <description>] [-> <what to do with it>]]

Pandora.cs: Things that should be available in this file
-> Should contain static references to reach all Main program parts plus 
everything
listed here
Main() - The main function
Folder -> User a better way use the assembley!
ApplicationDataFolder
BoxForm -> Maybe the only form that could be referred in Pandora.cs check if 
it's
really needed
Version
ClosePandora()
Restart()
ProfilesFolder -> needed in Pandora.cs? Or better at profile manager

BoxLog: Error logging
Log

PropertyManager: Small Tab in Box.cs
Prop -> child of Box.cs (better in a "smallTab" control )

MapViewer: Small Tab in Box.cs
Map -> child of Box.cs (better in a "smallTab" control )

ArtViewer: Small Tab in Box.cs
Art -> child of Box.cs (better in a "smallTab" control )

Hues: Hue selection and management
Hues

Localisation: Localization of the whole Program
-> Build one class to manage localization and static link in Pandora.cs
TextProvider -> should not contain a try catch block and function call on get
SupportedLanguages -> build a Localization class
LocalizeControl() -> Localization class
LocalizeMenu() -> Localization class

ToolTip: Provide tooltips for the GUI
ToolTip -> Every form should have it's own ToolTip class

GUI Functions:
-> should not be in Pandora.cs build a helper class for this or find a better 
place
UpdateLinks() -> extra helper class, or manage it with the VS Designer
ShowBuilderControl()

Single instance: Make sure we can only start one instance
-> to an extra class that manage this behavior
ExistingInstance

BoxServer:
Connected -> move to another class that manage the BoxServer connection
SendToServer()
OnlineChanged

UOClient Communication:
SendToUO() -> move to an extra class for the Communication with the UO Client

Profiles: create an Profile Manager
ExistingProfiles
CreateNewProfile()
DeleteCurrentProfile()
ProfilesFolder
MoveProfiles()
Profile - Gets the profile currently loaded
DefaultProfile
ImportProfile()
ExportProfile()

ProgrammData: all the data stuff
-> create a new class to hold and manage all the data stuff
-> handle Data.dll / DefaultButtons.dll
DataAssembly - reference to Data.dll
TravelAgent - Travel Data
Buttons - Custom Buttons
BoxData - Items, Mobiles, Notes
Mobiles - Scripted mobile stuff (whats that?)
m_Mobiles_Saving -> should not be in Pandora.cs
Items - Scripted items stuff (whats that?)
m_Items_Saving -> should not be in Pandora.cs
SpawnGroups
m_SoundData
SoundData
m_Skills
Skills
m_Lights
Lights
m_Doors
Doors

Command Modifiers: The modifier contexmenu and actions
-> build a class for this
m_cmModifiers
RefreshModifiersMenu()
MakeModifiersMenu()
OnModifierMenu()
cmModifiers
OnModifiersChanged()

ToDo after and while refactoring Pandora.cs:
- Cleanup and check local Variables in Pandora.cs after refactoring
- Check references to the GUI elements and make them still available :)

Original comment by Tarion86 on 24 Feb 2009 at 10:30

GoogleCodeExporter commented 9 years ago
Added ProfileManager as a singleton that implements:

ProfilesFolder
ExistingProfiles
CreateNewProfile()
DeleteCurrentProfile()
ProfilesFolder
MoveProfiles()
Profile - Gets the profile currently loaded
DefaultProfile
ImportProfile()
ExportProfile()

There are still wrappers in the Pandora.cs for:
Profile
CreateNewProfile()
DeleteCurrentProfile()

Original comment by Tarion86 on 3 May 2009 at 12:00

GoogleCodeExporter commented 9 years ago
Namespaces should be equal to the directory of the source file.

Original comment by Tarion86 on 26 Apr 2010 at 9:36

GoogleCodeExporter commented 9 years ago
Localization refactored. Now available under Pandora.Localization
TextProvider now sperated in TheBox.Common.Localization.TextProvider
It's used by the PandorasBox and Localizer project. Not two files for the
TextProvider anymore.

Original comment by Tarion86 on 26 Apr 2010 at 10:31

GoogleCodeExporter commented 9 years ago
There are many hard connections between classes. One attempt to solve some hard 
connections and static references is to use a IoC / DI Framework. I will try to 
use LightCore, a very simple and basic framework to improve the code quality. 

See:
http://lightcore.ch/default.aspx

Original comment by Tarion86 on 19 Jul 2010 at 7:18

GoogleCodeExporter commented 9 years ago
ProfileManager no longer a normal singleton, it's now injected by the LightCore 
container.

About the warppers in Pandora.cs
CreateNewProfile()
DeleteCurrentProfile()
Are wrappers for the OptionsForm, will be thrown away when the OptionsDialog 
has access to the ProfileManager

See: Comment 3

About LightCore:
It seems to be very successful to implement LightCore to the current code. That 
will open the doors to unit testing. It may be overkill to apply unit tests to 
all components, but for bugs we fix and sensitive functions like the program 
startup it can be very useful.

I change the state to Discussion, if there is no reply in a few days I will 
commit the LightCore implementation.

Original comment by Tarion86 on 20 Jul 2010 at 7:57