|
My cat likes to get on my shoulders when I'm in meetings. The other one likes to get on my desk, anything in the way be damned.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
After a nasty dog sitting episode a few years back, I know no longer allow live animals or pets in the house. It was my Father's rule when I was a kid. He was a microbiologist and understood some of the health issues. Birds especially.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Dogs are grosser than cats.
|
|
|
|
|
If you don't like the experience of changing the bed-sheets, turning your back for five seconds, then discovering a freshly-deposited "hair tampon" on the duvet, then don't get cats!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
To join the conversation, any animal or human can be gross, but to keep it between dogs and cats, a couple of individuals really stand out for disgusting behavior. One was a male (neutered) cat that belonged to a roommate. It repeatedly pissed/sprayed on my bed if the door was left open. The other was a cocker spaniel that belonged to my daughter and we kept for several months. When she dropped him off, he was almost a year old and still un-neutered. (she had been meaning to get it done...) Of course, he got clipped right away, but it never suppressed that male dog instinct of marking territory...even in the house...plants, furniture, guitar, computer, etc. I admit that I caught him in the act once and held him in the air by the back legs having evil thoughts about how to stop the leg lifting problem. ...but I didn't do it.
I've now got a 10y/o blond cocker who is the best dog I've ever had. I swear he tries to be good...except for last month when he repeatedly walked through hardwood flooring glue...that stuff doesn't come off!
"Go forth into the source" - Neal Morse
"Hope is contagious"
|
|
|
|
|
If you drift an electric car, are you doing the Electric Slide?
|
|
|
|
|
The trick is to be careful not to get the extension cord tangled around the wheels.
|
|
|
|
|
IMHO, in recent years, the best feature MS has added to the C# is Tuple. It helps make code cleaner and quicker to write.
It can be compared to Generic lists.
Behzad
|
|
|
|
|
Behzad Sedighzadeh wrote: It helps make code cleaner and quicker to write
Quicker to write, Okay!
Cleaner? I don't think so. Create a nested tuple and now you don't know which element you are referring to when you say Item2. It makes code difficult to maintain. So for simple return types that has like 2 or 3 primitive data types tuple is fine, otherwise just create a class.
|
|
|
|
|
GKP1992 wrote: Create a nested tuple and now you don't know which element you are referring to when you say Item2 Tuple "items" can be named, so:
var name = GetMyName(); where:
(string firstName, string lastName) GetMyName()
{
return ("Marc", "Clifton");
}
I can use name.firstName and name.lastName
Most of the time.
|
|
|
|
|
|
Yes
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
The slightly weird thing that disturbs me about that is that firstName and lastName behave/look a lot like members of a class/struct yet don't have Pascal Case naming.
name.firstName vs. name.FirstName
It reminds me of Javascript, and well you know what that can inflict on the soul.
Regards,
Rob Philpott.
|
|
|
|
|
Nice example. I fired up C# Repl and tried it out. ![Thumbs Up | :thumbsup:](https://www.codeproject.com/script/Forums/Images/thumbs_up.gif)
|
|
|
|
|
Yes, tuples are great, especially as a replacement for out string foo and I use them primarily for returning multiple things for rather low level methods when out or a C# class/struct is just overkill. The fact that the tuple parameters can be named was a huge advancement, rather than having to use Item1 , Item2 , etc.
That said, I use them judiciously and always ask myself, if I'm using a tuple here, is that the right approach or am I compensating for a possibly bad "design."
For example (this from code I have in a library):
public (HttpStatusCode status, string content) Get(string url, Dictionary<string, string> headers = null)
{
var client = RestClientFactory();
var request = new RestRequest(url, Method.Get);
headers?.ForEach(kvp => request.AddHeader(kvp.Key, kvp.Value));
RestResponse response = client.Execute(request);
return (response.StatusCode, response.Content);
}
Why am I parsing out the status code and content instead of just returning the response object? One answer is that returning response may probably require a using RestSharp and even a reference to the RestSharp package in the caller project.
OK, maybe that's a defensible argument, maybe not. After using this library of mine (REST is just one small part of this library) I'm not that thrilled with my initial wrapper implementation.
But because I started this "pattern", it continues, like:
public (T item, HttpStatusCode status, string content) Get<T>(string url, Dictionary<string, string> headers = null) where T : new()
{
var client = RestClientFactory();
var request = new RestRequest(url, Method.Get);
headers?.ForEach(kvp => request.AddHeader(kvp.Key, kvp.Value));
RestResponse response = client.Execute(request);
T ret = TryDeserialize<T>(response);
return (ret, response.StatusCode, response.Content);
}
And this illustrates mashing together various potentially bad implementation/designs. The tuple now returns three things, and the TryDeserialize catches exceptions silently, returning a null for T item , and what if I want the actual deserialization exception?
And now that I look at that code again after a couple years, what's with that AddHeader loop when there's a perfectly fine AddHeaders method?
Gads, I wish there were people smarter than me at work that could review my code!
Anyways, thanks for reading this longish post.
|
|
|
|
|
I think there are very few people smarter than you.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I don't use them much. I usually prefer to create a class. It kinda depends on how important the thing is.
|
|
|
|
|
I love them because sometimes it is convenient to return more than one value from a method, and the use case doesn't justify the overhead of creating and populating a POCO.
There are no solutions, only trade-offs. - Thomas Sowell
A day can really slip by when you're deliberately avoiding what you're supposed to do. - Calvin (Bill Watterson, Calvin & Hobbes)
|
|
|
|
|
Tuples and anonymous classes have drastically reduced the number of single-use classes in my code
|
|
|
|
|
I don't use C# much these days but totally agree. And, digging the positivity man.
Jeremy Falcon
|
|
|
|
|
Like (almost) everything in C#, they have their uses. Loving them? No!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Wordle 1,187 5/6
⬜⬜🟩⬜⬜
⬜⬜🟩⬜⬜
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,187 4/6*
⬜🟨⬜⬜⬜
🟨⬜⬜⬜⬜
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
Wordle 1,187 X/6*
⬜🟨⬜⬜⬜
🟨⬜⬜⬜⬜
⬜⬜🟩⬜🟩
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
![Dead | X|](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_dead.gif)
|
|
|
|
|
Damn I hate when it happens
GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
The shortest horror story: On Error Resume Next
|
|
|
|