|
I wish the REPL for F# was as good as one for a scripting language or even as good as the immediate window for C#. I found it to be a struggle.
brap fucked around with this message at 03:29 on Oct 26, 2014 |
# ¿ Oct 25, 2014 23:34 |
|
|
# ¿ May 17, 2024 15:42 |
|
You can get the types of generic arguments via reflection, but I too wonder if there's a better way to do what you're doing.
|
# ¿ Oct 27, 2014 19:37 |
|
Most of the badness to do with global variables has to do with the fact that they are variables. If you want to bind an immutable value to a name to reference it from any function, there's nothing wrong with that.
|
# ¿ Oct 31, 2014 02:28 |
|
Honestly I'm mostly just interested in seeing the good parts of F# make it to C#-- pattern matching, discriminated unions and all that jazz.
|
# ¿ Nov 3, 2014 06:40 |
|
Munkeymon posted:I just wanted to drop in and mention that I just found out today that LINQPad can update the database which has inspired me to buy it because it made the most annoying part of parsing and updating a bunch of dates that SQL doesn't natively support writing C# half in VS and copying it into LINQPad. It was great to be able to slap together I believe that's made possible by the LINQ to SQL library straight from Microsoft. Your code is being turned into a SQL script.
|
# ¿ Nov 13, 2014 01:33 |
|
Mr. Crow posted:In the world of dumb micro-optimizations this is probably up there. There's a method written at my workplace of this nature: code:
|
# ¿ Nov 17, 2014 16:53 |
|
Isn't there just a general function to convert a string to html entities where necessary (i.e. use > instead of >)?
|
# ¿ Nov 26, 2014 08:08 |
|
Dietrich posted:Any time you feel like you have to write a comment to explain your code, it means you need to re-write your code. Overcommenting is terrible, and a code style that "documents" itself well is important, but it's too much to say that good code never warrants comments.
|
# ¿ Nov 29, 2014 08:34 |
|
Honestly there's not that much to it. Select to apply a function to the elements of a sequence, Where to filter down to elements that satisfy a predicate, First to get the first element that satisfies the predicate, FirstOrDefault to keep your program from blowing up if one isn't found, Last similarly gets the last item matching a predicate, OrderBy and ThenBy to sort a list, Any to see if any elements in the list satisfy a predicate, All to see if all items in a list match a predicate. Those are what you'll use like 90% of the time. There is some interesting SQL-like stuff you can do with GroupBy but I've found it pretty confusing in the context of C#.
|
# ¿ Dec 12, 2014 17:22 |
|
RICHUNCLEPENNYBAGS posted:So we are in agreement. Tests are only going to be perfect for simple and obvious functions, and it's funny when people act like code without automated tests is a time bomb. It's not that black and white. But the nice thing about tests is you get to be specific and literal about what the expected behavior of your code is. That's really handy when evaluating how well your program fulfills requirements and it's very useful for the poor sap maintaining your code in the future who needs to figure out what the gently caress it does.
|
# ¿ Dec 18, 2014 18:39 |
|
Why is "order by" in sql then
|
# ¿ Jan 7, 2015 07:25 |
|
Ideally a unit test suite should create whatever environment it needs to operate and that includes a test database.
|
# ¿ Jan 18, 2015 08:39 |
|
Dromio posted:I disagree. Most unit tests should never hit the database. Mock the results of your query and test the logic of your method alone. No need for an actual db. I only hit a database (in-memory) when writing integration tests, Yes and the stored procedures would benefit from tests too.
|
# ¿ Jan 19, 2015 02:54 |
|
I've got some legacy code with a whole lot of thiscode:
code:
|
# ¿ Feb 26, 2015 23:41 |
|
Maybe if each property directly followed the backing field. But I actually have a region of fields and a region of properties. It's not good.
|
# ¿ Feb 26, 2015 23:59 |
|
NihilCredo posted:...but that makes things even easier? Delete the fields, then replace the {get {return (.+?) } set {\1 = value} } pattern* with {get; set;}. Done. Good call. I didn't even think of it. Might try to whip that expression up next time I'm at work. I am tending to avoid resharper based on negative anecdotes and the assumption that if wont be that easy to turn off and on as needed. I am likely to be wrong on at least one of those points.
|
# ¿ Feb 27, 2015 09:18 |
|
Are you serious? EF entities don't just return null if you access a nullable property that contains null? Also, table is not a good name in that context. You are working with individual records, not tables, so it's better to say something like for chair in chairs or for butt in butts. You're treating this like the SQL database doesn't exist? What do you mean by that?
|
# ¿ Mar 2, 2015 21:18 |
|
Get just the capture group. Groups have automatic number identifiers or can be named. Google knows. Also, write \d{4} not \d\d\d\d.UberJumper posted:So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position. Make sure to check in with the coding horrors thread.
|
# ¿ Mar 7, 2015 01:12 |
|
code:
|
# ¿ Mar 8, 2015 03:49 |
|
God drat vb is messed up.
|
# ¿ Mar 12, 2015 04:14 |
|
GrumpyDoctor posted:& is a string concatenation operator in VB.NET. Did you mean to use AndAlso? Hahahahaha how do people use this loving language
|
# ¿ Mar 26, 2015 06:30 |
|
Find References to your interface's type if you want to be able to jump to your implementation. Also, check your spelling.
|
# ¿ Apr 27, 2015 06:55 |
|
Oh, shoot. Sorry about the smug.
|
# ¿ Apr 27, 2015 07:05 |
|
So I've got a WCF two way TCP service running in a WPF app, and clients to that service running in a Winforms tray icon app. Right now I have the client app set up to create a new service client and try to reconnect when the fault event occurs. This is supposed to make it so it automatically reconnects if there's a temporary issue communicating with the server. In practice though it causes my server app to freeze if I launch the client before launching the server. What should I be doing differently?
|
# ¿ May 1, 2015 19:42 |
|
Are you sure about the scopes? I'm pretty sure I've seen people just open up a block in some C# code so they could redeclare a variable or something. It's kind of nasty when it happens.
|
# ¿ May 6, 2015 21:44 |
|
Are there any trip reports out there of people's experience working on ASP.NET projects with Visual Studio Code?
|
# ¿ Jun 13, 2015 20:07 |
|
I use a Mac at home and PCs at work. I think I'm still inclined to spin up my Windows virtual machine with Visual Studio for .NET work.
|
# ¿ Jun 13, 2015 22:52 |
|
I'm working on an MVC 6 Web API project and I'd like to profile it to find out where my performance bottlenecks are. However, when I go to the Debug menu -> Start Diagnostic Tools without Debugging and go through all the steps there, I hit a wall. When it asks me which project I want to profile, the listing says "No launchable projects are available for profiling." What should I do? Would something like MiniProfiler work if I dropped it in?
|
# ¿ Aug 18, 2015 05:12 |
|
Yay Microsoft and version segmentation. You still have Source Control -> Annotate for what it's worth.
|
# ¿ Aug 18, 2015 23:37 |
|
This basically captures my point of view on DI. It's a good thing and a very simple thing. http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html I feel pretty similarly about "inversion of control." Frankly it feels to me like OO programmers discovered modularity and just had to come up with a special term for it. I think inversion of control is a categorically poor term because it only has meaning in the context of "the way we used to do things." edit: It's also possible I have no idea what the gently caress I'm talking about. brap fucked around with this message at 21:24 on Aug 26, 2015 |
# ¿ Aug 26, 2015 20:29 |
|
What property names? You haven't mentioned any object that has properties on it. Is your dictionary supposed to get converted to or interpreted by an object that has some properties in it?
|
# ¿ Aug 27, 2015 03:35 |
|
Ok, I found your post from last week. I think people are just so thrown by your database schema that they can't believe there's a problem here. I suggest you come up with a function for each model that consumes the dictionary, applies a set of keys to the dictionary and knows the conversion to apply on each value. Take your common stuff like address fields and just come up with functions that turn strings into addresses and addresses into strings for when it's time to convert back. Then call those functions as needed for each property. I don't think making every property on every model implement a certain interface will meaningfully reduce the amount of boilerplate involved in this. StringKeyValuePairable, NumberKeyValuePairable... then providing parameters in the constructor so they all know what database keys they use, it's still a lot of code to churn out.
|
# ¿ Aug 27, 2015 04:26 |
|
Anybody in here have experience with ASP.NET 5 beta apps on Azure? I'm getting chronic, nasty performance issues: 5 to 12 second response times when all I'm doing is reading a string from a Redis cache and shooting it on toward the client. I also get an occasional issue where my API puts out an empty web page instead of JSON. I'm not sure what to try, except maybe to downgrade to the current version of Web API.
|
# ¿ Aug 28, 2015 23:22 |
|
Honestly not sure. I'm about to get with my friend who's been hosting it using his free azure credit and poke at whatever tools Microsoft provides for profiling a running app. It actually started being responsive at midnight, kept being responsive until a few minutes ago, and is now back at 6 second or so response times.
|
# ¿ Aug 29, 2015 18:12 |
|
Yep, even suffering through "why does this have to be optional" type issues at compile time is much better than nullreferenceexceptions at runtime. And I want it to be an opt-out thing for new projects. You get nullability warnings by default. It's funny you call async a virus. I guess it does necessarily propagate through your call graph quite a bit--but how else could it work? The alternative is to block a thread at some point in the process. I find that much of the time it's easy to add the async keyword and wrap Task<> around my return type anyway--certainly easier than refactoring my function to consume a callback would be.
|
# ¿ Sep 5, 2015 16:35 |
|
Yeah it's an insanely stupid system. I think the ASP.NET 5 stuff doesn't do this. I also love returning a 503 by throwing a loving exception. Exceptions are maybe the most misused concept in high-level languages.
|
# ¿ Sep 9, 2015 00:59 |
|
These kinds of things are pretty much inevitable if you want c# code to basically compile into SQL at runtime and execute in your database. It's amazing they've made it as close as it is to the "real thing."
|
# ¿ Sep 22, 2015 07:26 |
|
Well, in practice you probably import Windows.System.UserProfile and then say UserProfilePersonalizationSettings.Current.
|
# ¿ Oct 21, 2015 18:05 |
|
I am really put off by the service locator/view model locator/big ball of singletons pattern. Am I crazy?
|
# ¿ Oct 25, 2015 03:20 |
|
|
# ¿ May 17, 2024 15:42 |
|
Ciaphas posted:Yet another reason I wish my work machine wasn't an internet-free security-lockdown hellhole. NuGet packages and other frameworks are a non-starter for me, which probably isn't helping matters as far as learning (at least at work) What industry are you working in, if I may ask?
|
# ¿ Oct 28, 2015 00:41 |