Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Unify CRUD in dialog diff #2

Draft
wants to merge 69 commits into
base: upstream-master
Choose a base branch
from

Conversation

zhixzhan
Copy link
Owner

@zhixzhan zhixzhan commented Apr 23, 2020

Description

By unify lg/lu CRUD in dialog, could significantly decrease knowledges extensions need aware, only focus on *.dialog file, let shell handle rest related resource like *.lg *.lu file.

Workable checklist

Visual Editor

  • DELETE action via '...' flyout
  • ADD action via '+' flyout
  • PASTE action via '+' flyout

Form Editor

  • UPDATE action
  • UPDATE trigger
  • UPDATE dialog

Shell - Toolbar

  • COPY action selection
  • CUT action selection
  • MOVE action selection + ADD target trigger via modal
  • DELETE action selection

Shell - ProjectTree

  • ADD trigger via 'New Trigger...' modal
  • ADD dialog via 'New Dialog...' modal
  • DELETE trigger via '...' flyout
  • DELETE dialog via '...' flyout

Resource types X Operations

  • Dialog x Add | Update | Delete
  • Trigger x Add | Update | Delete
  • Action x Add | Update | Delete | Copy | Paste | Move

Task Item

refs microsoft#2699
refs microsoft#2699

Screenshots

Untitled1

@github-actions
Copy link

Pull Request Test Coverage Report for Build 85640374

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 85544820: 0.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

IStopper,
defualtJSONStopComparison,
getWithJsonPath,
} from './jsonDiff';

Choose a reason for hiding this comment

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

I think you used a lot of interfaces, showing you trying to think this as a more general level, which is a good design thinking.

But there are two things that are as important as a generic mindset

  1. if you are thinking from a generic perspective, make sure the concepts in this layer are consistent, which means, make sure they are all high-level concept or low-level concepts. Check your abstractions, are they mixing high-level and low level concept, are they mixing interface and implementation, are we have very similar things.
  2. Both less engineering and over engineering is not good, but usually over engineering hurts more than less engineering. This is usually a result of 1.

IJSONChangeDelete,
IJSONChangeUpdate,
IComparator,
IStopper,

Choose a reason for hiding this comment

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

In this case, Comparator is a generic thing, which make sense, but Stopper feels weird, stopper is just a sepecifc process in your walker, if i understand correctly.

preValue: any;
}

export interface IJsonChanges {
Copy link

@boydc2014 boydc2014 Apr 30, 2020

Choose a reason for hiding this comment

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

This is not a good interface, usually you don't see changes as interface name, because you can use built-in array or dict to capture the abstraction of a container.

I think if you want to make it generic,

you would expect a Differ will diff two json and returns a set of changes.

interface JsonDiffer {
differ(jsonA, jsonB) :=> JsonDiff[]
}

in this definiton, there is only minimal concept that, a json differ diff json into diffs. that's it, as high level.

at low level, is you may have different type of Diff, that's totally a low level differend kind of type of JsonDiff.

all those above is just showing what mean by high-level vs low-level abstraction. But in our case, we probabaly don't need any of them.

updates: IJSONChangeUpdate[];
}

export type IComparator = (json1: any, json2: any, path: string) => { isChange: boolean; isStop: boolean };
Copy link

@boydc2014 boydc2014 Apr 30, 2020

Choose a reason for hiding this comment

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

In this comparator interface, too much concept here, there is a path, there is IsChange and isStop and no result returned, which is weird.

what a comparator should represent? in almost any programming language, it usually takes two object of same type, and result in a true\false comparasion result.

if (path === JsonPathStart) return true;
const objPath = jsonPathToObjectPath(path);
return has(value, objPath);
}

Choose a reason for hiding this comment

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

Those 3 jPath related functions, what's the difference with standard jpath library provided and we must provide at here?

* @param list2
* @param comparator // value comparator
*/
export function ListDiff(list1: any[], list2: any[], comparator?: IComparator): IJsonChanges {

Choose a reason for hiding this comment

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

This is a similar conceptual question, what the top-level abstraction.

If i as a user, see a JsonDiff, and ListDiff, it's confusing, because list is a valid json. So JsonDiff is a super set of listDiff, listDiffer maybe make sense, but it's a "implemantation details" of how you achieve JsonDiff.

@zhixzhan zhixzhan changed the title feat: DialogDiff feat: Unify CRUD in dialog diff May 9, 2020
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.

4 participants