6 ms·
Same people who shame other's work for not being modular enough for their taste, would worship a one-line module[0] that is modular down to every subroutine. [
by imslavko 12y ago
Same people who shame other's work for not being modular enough for their taste, would worship a one-line module[0] that is modular down to every subroutine.
[0]: https://github.com/blakeembrey/is-upper-case/blob/master/is-upper-case.js https://github.com/blakeembrey/is-upper-case/blob/master/is-...
- cmpb 12y agoThat's intense and really quite silly. It makes sense to modularize large or complex (or some better modifier?) portions of the code base, but there's a point at which it just becomes too deep of a rabbit hole. I don't believe there is a formal definition of how deep down the rabbit hole that mark is, but I'm sure it would be a function of the module's (and the project's) size, readability and complexity.
- mkal_tsr 12y agoWhen the rabbits become turtles, you've gone too deep.
- vog 12y agoLewis and Fowler provide a nice definition in their Microservices article. [1] They drive modularity through the pattern of change, so their judgement is based on the development, rather than the code itself. "You want to keep things that change at the same time in the same module. Parts of a system that change rarely should be in different services to those that are currently undergoing lots of churn. If you find yourself repeatedly changing two services together, that's a sign that they should be merged." Although that article is about services, believe it can be applied to any type of modules. [1] http://martinfowler.com/articles/microservices.html http://martinfowler.com/articles/microservices.html
- geetee 12y agoI thought this was a joke library. Then I checked the NPM stats. 6,597 downloads in the last day 28,883 downloads in the last week 134,084 downloads in the last month
- imslavko 12y agoI found it following this tweet: https://twitter.com/Raynos/status/551243347994497024 https://twitter.com/Raynos/status/551243347994497024
- brandonbloom 12y agoI thought https://github.com/ljharb/is-object https://github.com/ljharb/is-object was a joke too, but... 37k downloads in the last month. Here's the full source code: 'use strict'; module.exports = function isObject(x) { return typeof x === 'object' && x !== null; }; Frankly, copy/paste is a superior code reuse mechanism at this scale. The part that really blows my mind? This project has had 57 commits to it! That's basically proof that the project management overhead exceeds a sane cost/benefit tradeoff.
- willyg302 12y ago> Frankly, copy/paste is a superior code reuse mechanism at this scale. The one advantage I see to having borderline-ridiculous packages such as this is that they do One Thing Well [1]. Yes you may copy/paste an isObject() function or roll your own, but then it becomes your responsibility to make sure it works for your project, and arguably far fewer eyes on it when it doesn't. As long as the project's maintainer is dedicated to making this the best way to determine whether a variable is an object, I have no problem using it. Although, I do find the 57 commits irksome. Most of them are just upgrading dependencies (code style checkers, etc.), "fixing" indentation, and in one case 7 separate tweet-sized diffs to the README on the same day, as if this guy has git commit/push bound to Ctrl+S in his editor. [1] http://www.catb.org/esr/writings/taoup/html/ch01s06.html http://www.catb.org/esr/writings/taoup/html/ch01s06.html
- mwhite 12y agoWow. I bet these could even be grouped into one module with minimal size overhead by using some higher-order functions or something. https://github.com/blakeembrey/swap-case https://github.com/blakeembrey/swap-case https://github.com/blakeembrey/is-upper-case https://github.com/blakeembrey/is-upper-case https://github.com/blakeembrey/title-case https://github.com/blakeembrey/title-case https://github.com/blakeembrey/snake-case https://github.com/blakeembrey/snake-case https://github.com/blakeembrey/dot-case https://github.com/blakeembrey/dot-case https://github.com/blakeembrey/path-case https://github.com/blakeembrey/path-case https://github.com/blakeembrey/camel-case https://github.com/blakeembrey/camel-case https://github.com/blakeembrey/param-case https://github.com/blakeembrey/param-case https://github.com/blakeembrey/upper-case-first https://github.com/blakeembrey/upper-case-first https://github.com/blakeembrey/lower-case https://github.com/blakeembrey/lower-case https://github.com/blakeembrey/upper-case https://github.com/blakeembrey/upper-case https://github.com/blakeembrey/pascal-case https://github.com/blakeembrey/pascal-case https://github.com/blakeembrey/is-lower-case https://github.com/blakeembrey/is-lower-case https://github.com/blakeembrey/constant-case https://github.com/blakeembrey/constant-case
- theverything 12y agoThey are - https://github.com/blakeembrey/change-case https://github.com/blakeembrey/change-case
- mattdesl 12y agoTo illustrate the problem: my dom-css module[1] needs a method to convert to camel case. I could copy-paste from stack overflow, but I would have to maintain/test that function. I'd rather depend on something. I could depend on a big "string-utils" library, but that would probably carry some useless baggage, and its scope may change or grow over time. Further, maybe it has a competitor module with a vehement following (like lodash vs underscore), which makes my module less appealing to them. This sucks for my module because I just want that one function. The better alternative is just to depend on the exact, clearly named "to-camel-case" function which is very unlikely to ever change or grow in scope. [1]https://npmjs.com/package/dom-css https://npmjs.com/package/dom-css
- mattdesl 12y agoI replied in another thread about some of the reasonings behind it: https://news.ycombinator.com/item?id=8830058 https://news.ycombinator.com/item?id=8830058 It's an alternative approach to software design which may feel alien if all you've ever used is copy-pasting for code re-use, or relying on large standard libraries and utility grab-bags.
- williamcotton 12y agoFirst, you've purposefully picked the smallest module that you could find. And can you back up your claim that "the same people who shame other people's work worship and publish one-line modules"? Can't you see how using terms like "shame" and "worship", which poor Blake never used no accused anyone of, is inflammatory? Second, so what? So it's alright to copy and paste the function? It is alright if a coworker wrote the function and presented you with an interface? Would you have a problem if a single module that was "designed in isolation, documented in isolation and can be used in isolation" but was published internally?