My-OpenPeriscope icon indicating copy to clipboard operation
My-OpenPeriscope copied to clipboard

Splitting the source code

Open kewalsk opened this issue 6 years ago • 6 comments

Is it possible to split the one big file Periscope_Web_Client.user.js into several smaller? The best would be one main menu function per file. Just for better maintenance. However, I don't know the consequences.

kewalsk avatar Aug 11 '19 16:08 kewalsk

It is possible, I like one big file though 😎

gitnew2018 avatar Aug 11 '19 19:08 gitnew2018

Splitting parts of API is in pull request: https://github.com/gitnew2018/My-OpenPeriscope/pull/39

Max104t avatar Aug 12 '19 20:08 Max104t

I don't have enough experience to judge if splitting the code is good or not. What are the benefits? While reviewing the Pull request, I noticed that it makes it harder to read because many variables and functions are undefined, my linter is mad about it 🙄 and I can't easily jump to function definition etc. I guess it was a lot of work to split it and i don't want to close this PR without hearing why you did it.

edit: I decided to let you lead on this, still hoping for explanation.

gitnew2018 avatar Aug 16 '19 11:08 gitnew2018

Usually a serious software source code is maintained in separate files. In Java for example you have to keep each class separately - there is no other possibility. The one big file is not good for maintenance especially when more than one programmer is working on development. Each commit will cause conflicts which has to be manually resolved. That's why I suggest to do that. However I'm not JavaScript expert so I could not know all the consequences in this case.

What is "linter" and what do you mean by "mad about it"?

I'm using IDE (InteliJ but I'm sure Eclipse or other will do the work also) and there is no problem to jump into definition (Ctrl-B) even if the definition is in different file.

kewalsk avatar Aug 16 '19 22:08 kewalsk

During the code breaking, things may be hard, but once we reach a good state the MVC model, and separation of shared code it will be much easier to navigate.. Breaking the code also hides irrelevant details like the re-implementation of GM_xmlhttpRequest for Node.js in PeriscopeApiWrapper.js the callers should not bother with such details (if possible) and just call Periscope api they need.. the work is not done yet.. I rather have a logical abstraction of Periscope APIs instead of doing the HTTP calls.

Max104t avatar Aug 17 '19 02:08 Max104t

@kewalsk

Wikipedia:

Generically, lint or a linter is any tool that detects and flags errors in programming languages, including stylistic errors.

I'm using visual studio code and because of the way it is split it doesn't let me jump into definition etc. I'm going to investigate if I can do something about it.

Thanks to both of you!

edit: Added jsconfig.json file and it detects functions from other files now 🎉

gitnew2018 avatar Aug 17 '19 06:08 gitnew2018