-
Notifications
You must be signed in to change notification settings - Fork 295
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
CODINGCONTRACT: Move internals to a separate folder #1932
CODINGCONTRACT: Move internals to a separate folder #1932
Conversation
High-level comment: If we aren't going to have all the contacts in one big file (and that seems reasonable), then we should do one per file, with the possible exception of contacts that are tightly related to each other. And name them according to the contract name (or an appropriate representative, in the case of multiple.) |
That should be all errors ironed out. I tested every contract for functionality just in case using this script. |
One thing that I am not super enthused about is the amount of boilerplate that is accumulating here. Originally, if you wanted to add a contract type, you just added it to the file. The name and impl were in one place, done. |
I get what you mean. Defining the type-signature in the nsdefs removes the need for Now, the split could be designed a bit differently, if the boilerplate is too much. The barrel file is not needed, since all of the types should probably never be used somewhere other than Currently, adding a new contract would require these changes:
The main pain point is probably step 3, since all others are basically the same, just not all in file. Your call here, I'm fine with all approaches honestly. |
If we could autogen the barrel (import * from contracts/) that would be the biggest win. The rest is mostly minor. See if you can think of something clever, otherwise I guess this is fine (the benefits to reading outweigh the boilerplate in writing) |
So, I played around with auto-gen stuff for a bit. IMO it's not really worth it, it just doesn't feel right to me. Instead, I removed the barrel file entirely, since the only place where these definitions are needed is the ContractTypes.ts file. If any file, like a test file or anything else wants to use all solvers, they can just import all solvers via that file. |
Currently, all of the cct code is scattered all over the place. Now all relevant parts are in one folder.
I also moved the contract types into sub-categories, since working with one big file is pretty messy. If this change isn't desired, I can revert that commit.
Also, the categories the types have been moved to are up for debate. Some categories are not really self-explanatory and some contracts don't really fit in their categories IMO.
Things like "optimizations" is a really broad term, so I'm not sure if it really fits?
And contracts like "Total Ways To Sum" aren't really optimization problems. I moved them there, since most of those problems are dynamic programming problems. Suggestions are always welcome!
Side node: git mv didn't really work on the
data/codingcontracttypes
file. Not sure if I messed that up somehow?