question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor helper methods: utils class vs command classes

See original GitHub issue

Discussed in https://github.com/pnp/cli-microsoft365/discussions/2979

<div type='discussions-op-text'>

Originally posted by appieschot January 25, 2022 Discussion started here: https://github.com/pnp/cli-microsoft365/pull/2918#issuecomment-1019300287

We currently have some base methods that provide helper functionality in that base class. We also use the getAppObjectId in the m365 aad app commands. We could pick to have a an abstracted AppCommand class so we can have 1 implementation instead of the multitude we have now (used in app-get, app-role-add, app-role-delete, app-role-list and app-set commands (as well as this one but this might be a bit of an odd duck as this in the future should inherit from whatever we decide in #2961.

Yet discussing that @waldekmastykarz pointed out it makes more sense to revisit and refactor or extend our Utils and provide (grouped) helper methods there. It feels like we should design both how our Utils should work and to research what we could move there for a V1. </div>

  • identify how to break up utils from the global Utils class but also service-specific utils
  • agree on new structure
  • refactor code

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
waldekmastykarzcommented, Feb 20, 2022

WIP: https://github.com/waldekmastykarz/cli-microsoft365/tree/utils-modules

The Utils class is no more and all methods are split into functions divided over multiple modules. Code compiles, but there are still some broken tests. I got rid of a few base classes but still need to do another pass. Last part left will be the removal of ItemsListCommand with the special getAllItems method which is now a part of the odata utils.

2reactions
garrytrindercommented, Feb 5, 2022

In favour 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get rid of helper and utils classes - Java Code Geeks
Let's refactor that helper class · Find the target class to which a certain static method should belong or · Find the target...
Read more >
What are the differences between Helper and Utility classes?
A Helper class has common code which can be re-used within a project and has dependencies within the project.
Read more >
Introduce Local Extension - Refactoring.Guru
Problem: A utility class doesn't contain some methods that you need. But you can't add these methods to the class. Solution: Create a...
Read more >
Refactoring: This class is too large - Martin Fowler
My overall aim is to break this large class down into smaller classes. In steps 1 and 2 above, I used regions and...
Read more >
java - How to deal with static utility classes when designing for ...
What I like about this approach is that it keeps the utility methods static, which just feels right to me when I am...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found