Skip to content

Conversation

@Jakz
Copy link
Collaborator

@Jakz Jakz commented Jun 26, 2018

This PR includes some refactors aimed to have a more modular code and be able to integrate the stdout of DIC process inside DICUI itself in the short future.

  • Tasks class has been created to implement all the dump single tasks
  • Result class has been created to managed a generic success/failure value with optional message and convertble to bool
  • extensions have been added for MediaType and KnownSystem enums to reduce the amount of static function calls around (and keep code more object oriented)
  • StartDumping has been split into many smaller chunks of code which are then invoked one after the other
  • EnsureDiscInformation has been split into EnsureCorrectInformationForSystemAndMediaType which takes care of checking system and media type
  • working proof of concept: cmb_MediaType combobox model now stores a List<MediaType?> instead that a List<KeyValuePair<string, MediaType>>, the display name is now rendered through a converter which is bound to the data template of the combobox itself. This simplifies the code a lot and it's extensible to KnownSystem too in the short term if we like it


private DumpEnvironment _env;


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since we have a lot of locals now, might be worth reordering them and grouping them for clarification.
Secondary even more minor nit: generally don't have double lines between stuff. If grouping is needed, we can use the #region and #endregion tags

private List<KeyValuePair<string, MediaType?>> _mediaTypes { get; set; }
private Process childProcess { get; set; }
private List<MediaType?> _mediaTypes { get; set; }
//private Process childProcess { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why childProcess is being kept around? Or will that be removed in a future update?


// Paths to tools
env.subdumpPath = _options.subdumpPath;
env.psxtPath = _options.psxtPath;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After my change goes in, all references to psxt can go away 👍

/// <summary>
///
/// </summary>
private Result EnsureCorrectInformationForSystemAndMediaType(KnownSystem? system, MediaType? type)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to something like GetSupportStatus? The full info can go in the summary

Tasks.cs Outdated

namespace DICUI
{
class Result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, default visibility of classes is internal. It's not an official thing, but I tend to like to explicitly put access modifiers on everything. In this case, I'd call it public. Not necessary, but fun.

Tasks.cs Outdated
public static implicit operator bool(Result result) => result.success;
}

class DumpEnvironment
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on access modifier here.

Tasks.cs Outdated
}
}

class Tasks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on access modifier here.

using System;
using System.ComponentModel;
using System.Reflection;
using System.Globalization;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Good practice for namespace ordering is alphabetical, except that all System.* and Microsoft.* go first

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never add an using directive by hand so I guess MSVS did it wrong.


public static class KnownSystemExtensions
{
public static bool DoesSupportDriveSpeed(this KnownSystem? system)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you also going to add a Name extension here (for this PR)? Or will that be coming later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the idea was to move Name (and all related infos) but we don't need to do it at once. I was waiting to see if we all like the change.

@mnadareski
Copy link
Collaborator

Looks good!

@mnadareski mnadareski merged commit 2cf083e into SabreTools:master Jun 27, 2018
@Jakz Jakz deleted the tasks_refactor branch June 27, 2018 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants