ThexXTURBOXx / catcher_2

Flutter error catching & handling plugin. Handles and reports exceptions in your app!
https://pub.dev/packages/catcher_2
Apache License 2.0
23 stars 26 forks source link

Why the class name changes? #4

Closed bernd70 closed 1 year ago

bernd70 commented 1 year ago

I was using catcher for a while and changed to your implementation because it seemed the original project was no longer maintained.

I am just wondering why you changed the class names. You won't use both versions side by side and I find the Catcher2 and Catcher2... names a bit akward... :-)

Maybe you could reconsider this decision before more people migrated to the latest version...

Howver thank you for continuing the project!

Best regards Bernd

ThexXTURBOXx commented 1 year ago

I had thought about the class and package changes quite a bit and I thought it would make the whole naming scheme more consistent. Also, this way I can ensure that bug reports sent here are really about catcher_2 and not catcher. Furthermore, since I have removed all the native platform plugins from catcher_2, old plugin registrants might complain. Using other class names than the original catcher, these errors can be easily traced to the old catcher without catcher_2 looking suspicious.

I get why it is confusing at first that I renamed almost everything, but from the maintainer's side, this actually does make sense. However, thanks for elaborating your concern and you are more than welcome! :-)

Best regards, Nico

calcitem commented 1 year ago

Hi Nico,

Firstly, thank you for taking the initiative to maintain and continue the development of catcher. Your efforts are much appreciated by the community.

I understand your rationale behind renaming the classes in catcher_2 and agree that it's a prudent move to differentiate from the original project. However, considering the impact on existing users, it would be extremely helpful if you could provide some comprehensive migration documentation.

Furthermore, a migration tool could potentially automate the renaming process, reducing the burden on developers. Here's a simple Python script as an example that can replace old class names with new ones in the source code:

import os

def replace_class_names(file_path, mapping):
    with open(file_path, 'r') as f:
        content = f.read()

    for old_class, new_class in mapping.items():
        content = content.replace(old_class, new_class)

    with open(file_path, 'w') as f:
        f.write(content)

# Example Usage
mapping = {
    'OldClassName1': 'NewClassName1',
    'OldClassName2': 'NewClassName2',
    # add more mappings
}

for root, dirs, files in os.walk('./your_project_directory'):
    for file in files:
        if file.endswith('.dart'):
            replace_class_names(os.path.join(root, file), mapping)

By doing so, you'd be facilitating a smoother transition for existing users to adapt catcher_2.

ThexXTURBOXx commented 1 year ago

Hi @calcitem, first: Thank you for your code snippet. Maybe I will populate it with the relevant replacements in the near future. I have already written a small migration guide which covers all the needed changes. However, considering that most people just need to update class names in a few places, it should not be too much of a burden - for example see my other maintained project flutter_web_auth_2 which went through the same transition in the past or even breaking changes in other projects such as analyzer which require undocumented changes in many places.

calcitem commented 1 year ago

Hi @ThexXTURBOXx,

Thank you for taking the time to explain your reasoning behind the class name changes in catcher_2. After reading your explanation, I can see why these changes are not just arbitrary but serve a clear purpose, especially for easier bug tracking and separating concerns between the old and new versions. Your perspective as the maintainer certainly sheds light on why such a decision was necessary.

I appreciate your willingness to consider community feedback and I'm pleased to hear that you've already developed a migration guide. It's reassuring to know that you've thought this through so carefully.

Again, thank you for your hard work and dedication to the project. Your efforts are highly valued by the community.

Best regards, Calcitem

calcitem commented 1 year ago

Migration Guide Incompleteness and Compilation Failure

I am writing in reference to the migration guide provided for the implementation of catcher_2. It appears that the guide may not be fully comprehensive, as I encountered a compilation error during the process.

The specific error generated by Flutter was as follows: "[ +135 ms] lib/main.dart:42:6: Error: Error when reading 'lib/shared/services/catcher_2_service.dart': No such file or directory". This suggests that there might be missing files or incorrect paths specified in the guide.

I would appreciate it if you could review the migration guide and provide clarification or amendments where necessary, especially concerning the 'catcher_2_service.dart' file, which seems to be missing or misplaced.

Your prompt attention to this matter will greatly assist in the smooth continuation of the migration process. Thank you for your understanding and support.

ThexXTURBOXx commented 1 year ago

Actually, I don't remember or even see a file called catcher_2_service.dart. I think, this might be specific to your project. Try to either change this specific import back to catcher_service.dart or rename the file inside your project accordingly :)

calcitem commented 1 year ago

Actually, I don't remember or even see a file called catcher_2_service.dart. I think, this might be specific to your project. Try to either change this specific import back to catcher_service.dart or rename the file inside your project accordingly :)

Sorry! It's my fault. It is a new file created by me...

calcitem commented 1 year ago

By the way, I found that the compilation fails after switching to catcher2. I have raised an issue to the author of FlutterToast: https://github.com/ponnamkarthik/FlutterToast/issues/465.