October 30, 2019 at 1:22 pm
With .NET Core there's finally a way for Sql programmers to get out from under the yoke of C#'s type conversions.
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
October 30, 2019 at 1:46 pm
Haha Jeff. I do spend a lot more time than I would like writing managed code. But this is the same third party vendor's code who has this as a message. Not sure if this is an error message or they are telling that the update failed successfully. And yes this is an actual screenshot from production.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 30, 2019 at 2:17 pm
With .NET Core there's finally a way for Sql programmers to get out from under the yoke of C#'s type conversions.
I haven't played with net core, do you have any info on the type conversion differences? I can't find anything, weak google fu I guess.
October 30, 2019 at 4:08 pm
I think many of the issues with the code sample or screenshot above are from many more people coding that just don't have good skills or habits. They make poor decisions. In that sense, some of the .NET stuff is taking the place of VB6, where people that didn't know how to structure things wrote lots of app.
However, I think there are lots of .NET apps that do work very well, and have powered lots of the apps we use for banking, e-comm, and more. The quality of code, overall, seems to have gone up. I see fewer and fewer crashes and more stability, as well as a higher rate of change.
October 30, 2019 at 4:14 pm
I haven't played with net core, do you have any info on the type conversion differences? I can't find anything, weak google fu I guess.
In C# since 5 years ago whether .NET Full Framework or .NET Core the type safe way to handle data coming from Sql Server is to cast/convert to objects in the System.Data.SqlTypes namespace. From the docs:
The System.Data.SqlTypes namespace provides classes for native data types in SQL Server. These classes provide a safer, faster alternative to the data types provided by the .NET Framework common language runtime (CLR). Using the classes in this namespace helps prevent type conversion errors caused by loss of precision. Because other data types are converted to and from SqlTypes behind the scenes, explicitly creating and using objects within this namespace also yields faster code.
Regarding what's possible with .NET Core. It's easiest to show how it works. Here is an example of a .NET Core 2.2 Web API POST method which executes a stored procedure to create (and return) an encrypted user access token:
[HttpPost("sh/login")]
[AllowAnonymous]
[TypeFilter(typeof(JsonResourceResultsHandler), Arguments = new object[] { "fc.api_user_email_login_post" })]
public void PostLoginAsync() { }
This POST method within the API Controller takes no parameters, has no body, and returns void. The stored procedure follows a common pattern for all Sql Inserts (or Restful POST, or Create CRUD, etc...). The generic class JsonResourceResultsHandler handles the Sql request in the lowest overhead way (bypassing UI/CLR binding and type conversions) while still making use of .NET Core Authentication and Authorization. Json is used for all inputs and outputs. All that's necessary to wire up a new API end point is to map a stored procedure to a route.
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
October 30, 2019 at 4:45 pm
I think many of the issues with the code sample or screenshot above are from many more people coding that just don't have good skills or habits. They make poor decisions. In that sense, some of the .NET stuff is taking the place of VB6, where people that didn't know how to structure things wrote lots of app.
However, I think there are lots of .NET apps that do work very well, and have powered lots of the apps we use for banking, e-comm, and more. The quality of code, overall, seems to have gone up. I see fewer and fewer crashes and more stability, as well as a higher rate of change.
In the case of the software I am talking about poor decisions, bad habits and just a clear total missing concept about how software should work is prevalent. I can't even begin to explain the number of times I have screamed obscenities while looking at their code. I mean real gems like stored procedures named "sp_curd_customers". And yes they spelled it "curd" instead of the more common "CRUD". And yes the procedure will create, read, update and delete all from the same table in a single procedure. And it does awesome stuff like require sending every column's value so you can delete the row. Not because it checks the rows, but because the parameters are all required. And then to add to the level of "are you kidding me", instead of using the typical multiple path type of logic each path is using dynamic sql (not parameterized either). So everything in the system is wide open to sql injection.
This is NOT the fault of .NET. This is the fault of education systems around the world providing education and degrees to totally incompetent people because the education process is a joke. In this system the problem is not limited to the managed code. It is the front end (which runs in flash so you are forced to use IE), the back end code (.NET) and the database (sql server). Every aspect of this is a joke and full of logical flaws everywhere you turn. But we stick with it because they paid a LOT of money for this software. The upside is that it does about 30% of the stuff that was promised. And of that 30% it works close to 90% of the time.
If I sound a little bitter...well...imagine being the guy stuck trying to unravel problems in this.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 30, 2019 at 5:02 pm
Likely have some job security though. With uneducated staff, always need to keep a few people around that do know something.
October 30, 2019 at 5:34 pm
Haha Jeff. I do spend a lot more time than I would like writing managed code. But this is the same third party vendor's code who has this as a message. Not sure if this is an error message or they are telling that the update failed successfully. And yes this is an actual screenshot from production.
BWAAAAA-HAAAAA-HAAAAAA! Back when I was a Front-End Developer, the only concern that people would express is "Ummm, ok... the text above the button isn't centered about the button. Please move it 23.5 pixels to the left" (yeah... half a pixel). Of course, I'd save the relative position as a variable so that when they said to move it back because the combination of the check mark and the text was no longer centered, it was a piece of cake in a config file so I wouldn't even have to do a recompile.
So glad I don't work with any of that any more and feel really bad for those that have to... especially those that have to fix "OPS-Code", which is a politically correct abbreviation for "Other People's S41T Code". 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2019 at 6:00 pm
For the meat cookers: https://www.engadget.com/2019/10/25/harvard-barbecue-desora-kamado-joe-cinder-grills/
October 30, 2019 at 6:11 pm
The Update Failed message reminds me of when I was a database developer some time ago working with Oracle, and the DBA's there programmed some automated job that would e-mail me with the message:
"Error: Job completed successfully."
...so was it supposed to fail but it didn't?
October 30, 2019 at 6:24 pm
Oh boy how I love vendor code. I am not exaggerating to say I just saw this.
try
{
OneLineOfCode;
try
{
AnotherLineOfCode;
try
{
ThirdLineOfCode;
}
catch(Exception ex) {}
}
catch(Exception ex) {}
}
catch(Exception ex) {}It is bad enough that they used the try/squelch anti-pattern but seriously...what is the point of nesting them three deep? Do they actually not realize that the outer empty catch would also catch anything inside? And why did they bother to name the Exception? I guess they don't care about compiler warnings either. The compiler does not like these types of lazy things. There were about 4 more levels of nested try-squelch around all this garbage. But the outer code had a try/catch that displayed an error if one happened. Too bad the class logic prevented the error from getting back. Sigh...I am going to have a stiff drink now.
I just tried something similar and it seems that the outer catch wouldn't catch anything that the inner catch eats. I could be wrong, I just couldn't duplicate the outer catch catching the inner exception, course just using divide by 0 as the error. I seem to think it would have to be rethrown(????). I do get a nag about an unused variable (the exception). Obviously could be me %-)
October 30, 2019 at 6:47 pm
x wrote:I haven't played with net core, do you have any info on the type conversion differences? I can't find anything, weak google fu I guess.
In C# since 5 years ago whether .NET Full Framework or .NET Core the type safe way to handle data coming from Sql Server is to cast/convert to objects in the System.Data.SqlTypes namespace. From the docs:
The System.Data.SqlTypes namespace provides classes for native data types in SQL Server. These classes provide a safer, faster alternative to the data types provided by the .NET Framework common language runtime (CLR). Using the classes in this namespace helps prevent type conversion errors caused by loss of precision. Because other data types are converted to and from SqlTypes behind the scenes, explicitly creating and using objects within this namespace also yields faster code.
Ok that made sense.
Regarding what's possible with .NET Core. It's easiest to show how it works. Here is an example of a .NET Core 2.2 Web API POST method which executes a stored procedure to create (and return) an encrypted user access token:
[HttpPost("sh/login")]
[AllowAnonymous]
[TypeFilter(typeof(JsonResourceResultsHandler), Arguments = new object[] { "fc.api_user_email_login_post" })]
public void PostLoginAsync() { }This POST method within the API Controller takes no parameters, has no body, and returns void. The stored procedure follows a common pattern for all Sql Inserts (or Restful POST, or Create CRUD, etc...). The generic class JsonResourceResultsHandler handles the Sql request in the lowest overhead way (bypassing UI/CLR binding and type conversions) while still making use of .NET Core Authentication and Authorization. Json is used for all inputs and outputs. All that's necessary to wire up a new API end point is to map a stored procedure to a route.
So is the class JsonResourceResultsHandler your own class(?) or part of the api? Couldn't google it %^)
Don't bother explaining if it needs lots of work because it'll probably sail over my head LOL
Interesting stuff!
October 30, 2019 at 8:21 pm
For the meat cookers: https://www.engadget.com/2019/10/25/harvard-barbecue-desora-kamado-joe-cinder-grills/
Interesting article. Thanks for thinking of us Steve. I find it kind of funny that they talk about how Traeger and other pellet smokers aren't cheap. Traeger's run from about $450 - $1,200. The Kamada Joe (their cheapest) is $1,699 and the Pro Joe (the top model) is $3,699. They seem to have missed the part about being pricey. And my complaint about ceramic smokers is the cooking surface is microscopic. The Kamada Joe's cooking surface is an 18" circle. That means you can only fit a single slab of ribs on the smoker at a time. With a rib rack you can maybe 5. I like to feed a lot of people when I fire up my smoker. I typically smoke 3-4 different meats at a time. Last time I smoked 6 slabs of ribs, an entire pork belly of pork belly burnt ends, 8 beef short ribs and 2 chickens. I would need four of those big ceramic smokers to cook that much.
All my negative comments aside, the times I have cooked on ceramic smokers the results are mighty impressive. Super consistent heating and smoke penetration is great.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 30, 2019 at 8:25 pm
I just tried something similar and it seems that the outer catch wouldn't catch anything that the inner catch eats. I could be wrong, I just couldn't duplicate the outer catch catching the inner exception, course just using divide by 0 as the error. I seem to think it would have to be rethrown(????). I do get a nag about an unused variable (the exception). Obviously could be me %-)
That is really my point. What is the point of all those inner catches when the outer catch just swallows any exception. Removing all of the inner ones would result in the same result (a useless result) with a lot less code.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 15 posts - 64,111 through 64,125 (of 66,815 total)
You must be logged in to reply to this topic. Login to reply