How do you decide whether to use a library or write your own implementation

后端 未结 7 2160
栀梦
栀梦 2021-01-31 18:40

Inspired by this question which started out innocently but is turning into a major flame war.

Let\'s say you need to a utility method - reasonably straightforward but no

7条回答
  •  不要未来只要你来
    2021-01-31 19:09

    Keep it in balance

    You should keep several criteria in balance. I'd consider a few topics and ask a few questions.

    Developing time VS maintenance time

    Can I develop what I need in a few hours? If yes, why do I need a library? If I get a lib am I sure that it will not cause hours spent to debug and documentation reading? The answer - if I need something obvious and straightforward I don't need an extra-flexible lib.

    Simplicity VS flexibility

    If I need just an error wrapper do I need a lib with flexible types and stack tracing and color prints and.... Nope! Using even beautifully designed but flexible and multipurpose libs could slow your code. If you plan to use 2% of functionality you don't need it.

    Dig task VS small task

    Did I faced a huge task and I need external code to solve it? Definitely AMQP or SQL operations is too big tasks to develop from scratch but tiny logging could be solved in place. Don't use external libs to solve small tasks.

    My own libs VS external libs

    Sometimes is better to grow your own library because it is for 100% used, for 100% appropriate your goals, you know it best, it is always up to date with your applications. Don't build your own lib just to be cool and keep in mind that a lot of libs in your vendor directory developed "just to be cool".

提交回复
热议问题