|
Official congratulations!
|
|
|
|
|
|
It's Hell getting old!
But you keep it up.
And Happy Birthday to you.
The good guys need to stick together!
|
|
|
|
|
Happy Birthday Paul!
|
|
|
|
|
Remember:
Time is not your enemy;
Gravity is.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
There was some piece of C# code I am refactoring (+ fixing small bug) where, at some stage, an expression like a.b.c is replaced by (private method) GetBc(A a) . When I refactored that, I ignored GetBc(a) and wrote a.b.c instead, because I like it better that way.
One of the code reviewers complained I was not using GetBc(a) . Whatever, I updated my code to use GetBc(a) again. Now I wonder, mm.. how many people would care about that kind of detail and what kind of expression they would prefer?
|
|
|
|
|
How would that work?
GetBC(A a) => (a.b, a.c);?
GetBC(A a) => new { a.b, a.c };?
In both cases I'd prefer a.b.c.
I don't see the added value of GetBC
|
|
|
|
|
C GetBc(A a) => a.b.c;
The only "real advantage" (in the day of yore before intellisense) is that it's more like
SomeClass GetBc(AnotherClass a) => a.LongPropertyName.OtherLongPropertyName;
|
|
|
|
|
Super Lloyd wrote: C GetBc(A a) => a.b.c; This is just ridiculous
Send that reviewer over to this thread so he can read that I find him ridiculous.
Judging from the other replies on this thread I'm not the only one
Super Lloyd wrote: The only "real advantage" (in the day of yore before intellisense) is that it's more like In those instances I don't make a function, but I simply use a variable.
var shortName = a.LongPropertyName.OtherLongPropertyName;
|
|
|
|
|
In most cases it's ridiculous, yes. It's not a construct I think I've used myself. However...
What if b is null? Suppose b is a lazy-loaded property which is only instantiated as/when referenced, but a does not support that functionality? Or - in the circumstances where you use the GetBC function you need a default value returned if b or c are null.
I'd agree that if GetBC does nothing more than return b.c then yes, it's pointless; but if there's code in that function (even just exception handling) then maybe... though a more descriptive/specific name than simply GetBC might be appropriate.
|
|
|
|
|
I take the liberty to slightly defend that code reviewer. It is a matter of blackboxing: When you reference that bc property of a, you should be unaffected by how the a object structures its attributes, i.e. whether it has a single bc attribute (and maybe bc1, bc2, bc3, ...) or groups all the b<*> attributes into a b object with subfields.
C# lets the a object provide a .bc property, so that is can map it to a .bc or a b.c field at its own discretion. Maybe that is nowadays available in C++ as well (it wasn't when I switched from C++ to C#). I have become very fond of blackboxing and need-to-know: You should need to know as little as possible about the inner structure of the objects you interact with. a.b.c does reveal an inner structure that you shouldn't care about.
But I most certainly would prefer a .bc property to a GetBc(A a) method!
|
|
|
|
|
trønderen wrote: When you reference that bc property of a, you should be unaffected by how the a object structures its attributes
If you use the data of the object outside the object then you have exposed the internal details of the object.
The specifics of how the data is exposed is not relevant.
This comes about because people confuse the idealization of 'object' and 'message' and the implementation to 'class' and 'method'. They then think incorrectly that it must mean that it goes the other way so 'method' => 'message'. And certainly ignore that the first is a ideal which can never and should never be rigidly enforced.
|
|
|
|
|
I would ask the code reviewer, why not GetC(GetB(a)) as that is really the logical extreme he/she is going to and points out the ludicracy of not doing a.b.c
|
|
|
|
|
Only problem with that is the reviewer might be one of those "letter of the law" people who would then demand that exact thing. Considering they had the problem in the first place, I wouldn't bet against their desire for the extreme.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
I was thinking the same thing with Get…
|
|
|
|
|
Is this a coding standard to use regular Methods such as in your example? Is this really not up to the code reviewer, but more in line with enforcing consistency and standards that your dev shop has?
|
|
|
|
|
Only the idgit what wrote GetBc would care. Mark the method and its writer as Obsolete.
On the other hand, it may help when using "Find all references" if you ever want to see where a.b.c is used.
But, as presented, I see no logical reason to use the method.
|
|
|
|
|
GetBc is a wrapper. As posted, it could be doing something else, or has done something else in the past. Or it was a stub from development. Do you just clean it out or replace it when "done"? (and maybe introduce side effects). Mixing and matching isn't the solution.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Gerry Schmitz wrote: Mixing and matching isn't the solution.
True, consistency is desirable, but in this case, having the method means the method may be used in some places and not in others, which is inconsistent. Remove the method and all code will have to use use the a.b.c syntax consistently.
Writing a method and then having to root out all of the instances of the old syntax is less than ideal.
|
|
|
|
|
Wordle 615 5/6
⬛⬛🟨⬛⬛
🟩⬛⬛⬛⬛
🟩🟩🟨🟩⬛
🟩🟩⬛🟩🟩
🟩🟩🟩🟩🟩
Are they getting harder?
|
|
|
|
|
Wordle 615 4/6
🟩⬜⬜⬜⬜
🟩🟩⬜🟩⬜
🟩🟩⬜🟩🟩
🟩🟩🟩🟩🟩
All green, but never heard of this word.
|
|
|
|
|
Wordle 615 5/6
🟩⬜⬜⬜🟨
🟩⬜⬜🟩⬜
🟩⬜⬜🟩⬜
🟩🟩⬜🟩⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 615 3/6*
🟩🟩🟨⬜⬜
🟩🟩⬜🟩🟩
🟩🟩🟩🟩🟩
Not if you have a good starter!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 615 6/6
⬛⬛🟨⬛⬛
⬛🟨🟨🟨⬛
🟨🟨⬛⬛🟨
🟨⬛🟨🟨⬛
🟩🟩⬛🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
⬜🟩🟨⬜⬜
⬜🟩⬜🟨⬜
🟩🟩🟩🟩🟩
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|