Timeline for Rationale to prefer local variables over instance variables?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 8, 2019 at 0:15 | comment | added | user88637 | @imel96 it's funny that you're probably one of the few people here who noticed that the coupling between ServiceClient and CryptoService makes it worthwhile to focus on injecting CS into SC instead of into SBP, solving the underlying problem at higher architectural level... that's IMVHO the main point of this story; it's too easy to keep track of the big picture while focusing on the details. | |
Mar 6, 2019 at 2:47 | comment | added | imel96 | @JoopEggen Yes, abstractions make sense. In the example, the private methods don't give any abstractions anyway, users of the class don't even know about them | |
Mar 6, 2019 at 2:43 | comment | added | imel96 | @Flater I agree with your comments, we don't want to apply this everywhere. I edited my answer to clarify my practical position. What I want to show is that in practice we only apply rules when it's appropriate. Chaining method call is fine in this instance, and if I need to debug, I'd invoke the tests for the chained methods. | |
Mar 6, 2019 at 2:38 | history | edited | imel96 | CC BY-SA 4.0 |
Add code review as factor
|
Mar 5, 2019 at 10:30 | comment | added | Flater | One clear issue with chaining it all into one method call is sheer readability. It also doesn't work if you need more than one operation on a given object. Also, this is nigh impossible to debug because you can't step through the operations and inspect the objects. While this works on a technical level, I would not advocate for this as it massively neglects non-runtime aspects of software development. | |
Mar 5, 2019 at 10:20 | comment | added | Joop Eggen | My upvote, though many will hesitate here. Of course some abstractions, make sense. (BTW a method called "process" is terrible.) But here the logic is minimal. The OP's question however is on an entire code style, and there the case may be more complex. | |
Mar 5, 2019 at 9:18 | history | answered | imel96 | CC BY-SA 4.0 |