|
Shy posted:Why? I never used it but I thought it pretty much does the same job as C# almost as easily. I cannot abide by a language that uses () for both function calls and array indexing.
|
# ? Jan 26, 2012 00:58 |
|
|
# ? Apr 23, 2024 13:03 |
|
Ithaqua posted:I'm not a huge fan of the VB syntax, but I can work with it in a pinch. It's mostly different names for the same concepts, but in some cases, the syntax is just ugly as gently caress, especially generics and LINQ. My day job is language designer for VB. There are lots of places where it's ugly, but this example actually showcases some of its neat syntax features once you write it in idiomatic VB rather than C#... code:
code:
ljw1004 fucked around with this message at 01:34 on Jan 26, 2012 |
# ? Jan 26, 2012 01:29 |
|
ljw1004 posted:My day job is language designer for VB. There are lots of places where it's ugly, but this example actually showcases some of its neat syntax features once you write it in idiomatic VB rather than C#... Yeah, I was aware of the "SQLy" LINQ syntax, which C# also uses. I'll usually try a complex LINQ expression both ways and see which is more readable. The second I hit a GroupBy(), I'll do it "SQL" style. As for the second thing, that's pretty neat. Is it different under the hood from something like code:
|
# ? Jan 26, 2012 01:54 |
|
Ithaqua posted:As for the second thing, that's pretty neat. Is it different under the hood from something like That's more or less what it's doing. The differences: * There are two IL strategies that the compiler can use to implement the above statement. It could generate a new array and then stick elements in it one at a time by code. Or it could have a flat set of bytes in the EXE and call a different IL instruction to slurp them up all at once. C# will use the second strategy for large enough arrays. In the end it doesn't make for an observable perf win... the different IL has to basically to the same things anyway! * For "new[] {...}", C# uses solely the dominant type of the elements; if there are no elements or no dominant type then it's a compiler error. Thus, "new[] {}" will always be an error in C#. VB first takes into account the target type of the array. The following is allowed: "Dim x As IEnumerable(Of String) = {}". More generally, C# has striven to be a language where the meaning of an expression is determined solely by the expression. Sticking to this principle makes it easier to read and understand. VB has a few more exceptions to the principle than C#. PUZZLE: There are three kinds of expression in C# where, to know the meaning of the expression, you need to know the type that this expression is expected to be. What are they? (by "meaning" I mean things like what IL will be generated, or what type the sub-expressions have.)
|
# ? Jan 26, 2012 02:11 |
|
I actually quite like VB (and not VB6 obviously). It is very verbose, but it also scans the clearest for me when trying to figure out what's going on. This relates more to other people's code than mine. Where it does fall down is those crazy (x) level deep dom-style calls, but the same is true of the other .Net languages.
|
# ? Jan 26, 2012 02:35 |
|
I'd like to set up a system with this kind of structure: SolutionName -> MainProject -> ToolsProject such that when you mash F5 the ToolsProject builds (if needed) and executes before the MainProject is run. The idea is that ToolsProject will pick up some files and transform the data into something that MainProject can use, and for a release version you'd only give out the build of MainProject and the pre-digested data files. The inspiration for this setup is XNA's content pipeline system. They have a Content project that you can stuff all your models, textures, sounds, etc. into and at build time it packs everything into a binary format that is ready for the XNA game to just grab and run with. I've never played with fancy build setups in VS, so I'm not sure where to start. Even just a 'Google for term X' hint would be great. I've looked at the project pre/post build events but it doesn't feel like I'm going down the right path there. ljw1004 posted:PUZZLE: There are three kinds of expression in C# where, to know the meaning of the expression, you need to know the type that this expression is expected to be. What are they? (by "meaning" I mean things like what IL will be generated, or what type the sub-expressions have.) Is something like code:
|
# ? Jan 26, 2012 03:11 |
|
PDP-1 posted:I've never played with fancy build setups in VS, so I'm not sure where to start. Even just a 'Google for term X' hint would be great. I've looked at the project pre/post build events but it doesn't feel like I'm going down the right path there. Nope, that's the right path. You need to do something post-build, it sounds like. The downside of that is that it's going to run on EVERY build, so if it takes a while to run, it's going to suck.
|
# ? Jan 26, 2012 04:17 |
|
OK, good to know, thanks! Hopefully runtime shouldn't be a problem - if I can figure out how to get it working I'd scan the source directory for changes/additions/deletions and just let any other existing processed data stay where it is.
|
# ? Jan 26, 2012 05:49 |
|
PDP-1 posted:I'd like to set up a system with this kind of structure: Expand MainProject in the Solution Exlporer, right-click References, Add Reference..., I don't remember the exact interface from here because I use an extension that replaces it, but you want to add a project reference and not a DLL reference. If you already have a DLL reference (likely, otherwise why would you care if it's built or not), remove it.
|
# ? Jan 26, 2012 07:18 |
|
I just hate working on mixed language solutions where my brain has to bounce back and forth. I also hate VB.Net projects because most of the time they are set up without "Option Strict" or whatever which makes certain types of refactoring a huge pain in the rear end. And having to explicitly specify which interface member I'm implementing sucks.
|
# ? Jan 26, 2012 16:43 |
|
Another quick question: Is there anyway I can take data from a GridView row and use it to populate text boxes? Right now I'm using this code: code:
However for record updates, I want to be able to do something like this: code:
edit: I have a terrible workaround, and it presents a different problem. I used a completely new search method to populate the textboxes, and that's all well and dandy, using similar code to the above, but instead of binding it to the grid, I loop through it and populate the textboxes accordingly. The problem arises when we have sites of similar name (e.g., our bigger sites have 2 separate connections, one for intranet and one for internet), the textboxes will only populate with the first one. Is there some sort of if statement I can use to check whether the number of records returned >= 2, and provide an intermediate popup that allows the user to select which of these possible records they want to edit? aBagorn fucked around with this message at 22:02 on Jan 26, 2012 |
# ? Jan 26, 2012 20:09 |
|
PDP-1 posted:PUZZLE: There are three kinds of expression in C# where, to know the meaning of the expression, you need to know the type that this expression is expected to be. What are they? Yeah, that's one. The others: code:
|
# ? Jan 26, 2012 20:49 |
|
This is pretty neat (from Hidden Features of C#?:code:
|
# ? Jan 26, 2012 22:42 |
|
aBagorn posted:
I would just like to point out that you've mixed your presentation and data layers together, which is a no-no. Your presentation layer shouldn't have any sort of data access code in it whatsoever. Luckily, you're using an ORM, so at least it's a little bit better than calling SqlCommands directly from the page. I'd recommend looking into ObjectDataSource for what you're doing, because I can almost guarantee it will make your life easier. You define an ODS, tell it what methods to call and what parameters to provide the methods for your CRUD, and then it calls those methods as appropriate. [edit] Check this out! Editable gridviews If you're using ASP .NET webforms, you might as well leverage the stuff that's built-in. New Yorp New Yorp fucked around with this message at 23:33 on Jan 26, 2012 |
# ? Jan 26, 2012 23:27 |
|
Ithaqua posted:I would just like to point out that you've mixed your presentation and data layers together, which is a no-no. Your presentation layer shouldn't have any sort of data access code in it whatsoever. Ah, cool. Yeah this is the kind of stuff I need to know. My code is all over the place, and I'm just worried about "does it work" rather than "best practices", and I should be concerned with both. FWIW I have 2 WebForms with almost identical data access code on it because I was too stupid to use session data to pass values, and didn't create a new class to contain the data methods cause I'm dumb
|
# ? Jan 27, 2012 00:34 |
|
aBagorn posted:Ah, cool. You're asking the right questions and learning the good stuff along the way, which is pretty much the best you can hope for. My first production application was a true horror. Write unit tests where you can and don't be afraid to refactor.
|
# ? Jan 27, 2012 02:39 |
|
boo_radley posted:This is pretty neat (from Hidden Features of C#?: That people would consider many of those features "hidden" saddens me. yield? Seriously?
|
# ? Jan 27, 2012 03:01 |
|
Ithaqua posted:You're asking the right questions and learning the good stuff along the way, which is pretty much the best you can hope for. My first production application was a true horror. Write unit tests where you can and don't be afraid to refactor. Ithaqua I don't want to poo poo up the thread anymore with stupid questions but if you're up for it, I do have more stupid questions. No PMs but my email is in my profile
|
# ? Jan 27, 2012 16:41 |
|
Zhentar posted:That people would consider many of those features "hidden" saddens me. yield? Seriously? Of all the things on that list, you think yield is the least appropriate? They have using and var on that list which is in dozens of code samples. At least yield is come what obscure and situational. but yeah, agree with you that "hidden" is not the right term for those features.
|
# ? Jan 27, 2012 17:00 |
|
Zhentar posted:That people would consider many of those features "hidden" saddens me. yield? Seriously? The only appropriate thing on that list are the undocumented keywords, but they really are of little practical value.
|
# ? Jan 27, 2012 17:29 |
|
akadajet posted:The only appropriate thing on that list are the undocumented keywords, but they really are of little practical value. Yeah, if you're thinking of hidden as really hidden, that's true. But as a tips/ tricks/ "did you know?" thread, it's interesting reading. There's things on that list that I use every day, but as SharePoint developer I rarely touch multithreaded code, so things like volatile and multithreaded code are kinda foreign to me.
|
# ? Jan 27, 2012 18:08 |
|
aBagorn posted:Ithaqua I don't want to poo poo up the thread anymore with stupid questions but if you're up for it, I do have more stupid questions. I emailed you, but I'd say that asking questions about .NET development isn't making GBS threads up the thread, it's the purpose of the thread.
|
# ? Jan 27, 2012 18:26 |
|
Quick question. I am writing a small web quiz for internal use at my company. I want to scrape the windows user name and add it with the results and dump them to a db. Currently in my testing (Microsoft Visual Web Developer 2010 Express) when I run my webpage, I can properly pull my domain\username. When I upload it to my webserver (Server 2008 R2, IIS 7.5) and use it, it is pulling a service account? I will get this instead of the user name IIS APPPOOL\DefaultAppPool. Is this a problem with my code to get the username, or a setting for my Application Pool? code:
|
# ? Jan 27, 2012 19:40 |
|
Moey posted:Quick question. That code won't work for web apps. Use something like System.Web.HttpContext.Current.User.Identity.Name instead. And make sure that you disable anonymous access to the website.
|
# ? Jan 27, 2012 20:11 |
|
uXs posted:That code won't work for web apps. Use something like System.Web.HttpContext.Current.User.Identity.Name instead. And make sure that you disable anonymous access to the website. That did it. Thanks! Building on this note, not sure if this is an .Net question or what. When I have Anon Access disabled, IE will scrape my windows login info and connect without any user intervention needed. With Firefox, it prompts for username/pw. Is there any way to get this/Firefox to play nicely (no user input needed)? Moey fucked around with this message at 00:02 on Jan 28, 2012 |
# ? Jan 27, 2012 21:35 |
|
Moey posted:That did it. Thanks! You're looking for NTLM authentication configuration. http://sivel.net/2007/05/firefox-ntlm-sso/ To expand, Windows does it natively if the site is in the trusted zone. You will have to use a group policy to get Firefox to do it automagically.
|
# ? Jan 28, 2012 03:30 |
|
Nurbs posted:You're looking for NTLM authentication configuration. Exactly what I was looking for, thanks. No more users locking themselves out by hamfisting passwords trying to pull up our internal wiki in FF.
|
# ? Jan 28, 2012 15:07 |
|
I'd like to attend some conferences or seminars this year since I completely neglected my training budget last year and I might lose it if I don't use it. What conferences and seminars do you guys attend/find awesome?
|
# ? Jan 28, 2012 16:35 |
|
Dietrich posted:I'd like to attend some conferences or seminars this year since I completely neglected my training budget last year and I might lose it if I don't use it. I went to TechEd a few years ago and came away with some really neat insights.
|
# ? Jan 28, 2012 18:17 |
|
Dietrich posted:I'd like to attend some conferences or seminars this year since I completely neglected my training budget last year and I might lose it if I don't use it. CodeMash was great the past 2 years, although it's in January so you already missed it for 2012. Tickets go on sale in October usually. It's in Ohio in January!
|
# ? Jan 28, 2012 19:20 |
|
At this point this year I'm planning to hit WWDC and whatever Microsoft has this fall to replace MIX / BUILD. I think WWDC makes sense, even for non-iOS devs, as that is driving so much that you've got to understand that platform and where it is going. And the MS thing is probably going to be the Win8 RC0 party.
|
# ? Jan 28, 2012 20:02 |
|
Ok goons ready for more crappy code that will make you cry? As mentioned before, my app works. I've actually gotten it to work better than I originally hoped, even. But as it sits there on the intranet, being really useful to the net admins and the help desk, I came back to what Ithaqua had said about best practices, and keeping my data access out of my presentation layer. So in that vein I decided to rewrite it from scratch as a test to myself. It doesn't work for poo poo. It compiles ok, but no data gets passed. Using the debugger I can't exactly tell where it's going from the value I have in a textbox to 'null'. Some relevant code. On the search page, I declare a string variable and then have a button click method. code:
The method invoked is in my fancy new data accessor class, NhsSitesData, which looks like this: code:
As you can of course gather, what is supposed to happen is the db should be queried according to the text in the searchbox, selecting only the address property of each record, throwing it into a list, and populating a dropdown with that list. But nothing happens. Not a drat thing. Am I missing something with session info here?
|
# ? Jan 28, 2012 20:45 |
|
aBagorn posted:You're not passing any search criteria into your class, it looks like. Your class shouldn't have public properties for setting the search criteria and getting results. All that does is introduce unnecessary state into your class, which can cause weird bugs and general headaches. The method you're calling should take parameters and return its result. Also, use using blocks around your data access stuff... it's a language construct that is equivalent to code:
code:
Anyway, back to your problem... Try this: code:
New Yorp New Yorp fucked around with this message at 21:10 on Jan 28, 2012 |
# ? Jan 28, 2012 20:59 |
|
I have a WinForms application where I am trying to attach a Form to a class to serve as a UI view. The class has some input values and some output values that I'm trying to connect to TextBoxes on the Form using Binding and INotifyPropertyChanged to get two-way interaction. The issue I'm runing into is that the class' output values can change at random times, and when one of them changes and fires PropertyChanged it causes *all* of the TextBoxes on the Form to update instead of just the one thing that changed value. If you happen to be midway through typing a new input value and some output value happens to change the input value TextBox gets reset to it's initial value and you lose your work. I've tried to re-create this scenario in the code below. In this case OutputProperty gets periodically changed by a Timer. If you happen to be trying to modify the InputValue by changing the inputTextBox text, everything gets reset and you lose your data. Is there any way to make it so only the things that actually change cause updates in their associated TextBox? code:
|
# ? Jan 30, 2012 03:29 |
|
PDP-1 posted:http://stackoverflow.com/questions/2820447/net-winforms-inotifypropertychanged-updates-all-bindings-when-one-is-changed-b
|
# ? Jan 30, 2012 04:30 |
|
Ithaqua posted:Thank you thank you thank you! It makes so much sense now. Don't ask me why I was doing it (or trying to do it) the other way before and making it needlessly complicated. Last question about this project, I promise. I want to have a popup do a confirm/cancel dialog when a site is updated/deleted/added. In WinForms I would just do a MessageBox.Show and be done with it. I'm assuming it's not so simple with web. Do I need to use JavaScript? or something like: <asp:Button ID="deleteButton" runat="server" Text="Delete" OnClientClick = "return confirm('Are you sure you want to delete?');"/> aBagorn fucked around with this message at 14:38 on Jan 30, 2012 |
# ? Jan 30, 2012 05:54 |
|
Nurbs posted:I went to TechEd a few years ago and came away with some really neat insights. When do they typically post their course catalog? My boss is gonna wanna see exactly what they're paying for. Ithaqua posted:CodeMash was great the past 2 years, although it's in January so you already missed it for 2012. Tickets go on sale in October usually. It's in Ohio in January! I'm already in Ohio all year around, Maybe I'll try to attend this in 2013.
|
# ? Jan 30, 2012 15:36 |
|
aBagorn posted:<asp:Button ID="deleteButton" runat="server" Text="Delete" OnClientClick = "return confirm('Are you sure you want to delete?');"/> That sounds about right.
|
# ? Jan 30, 2012 15:44 |
|
Ithaqua posted:http://stackoverflow.com/questions/2820447/net-winforms-inotifypropertychanged-updates-all-bindings-when-one-is-changed-b Thanks for the link, it explains what's going on here and why the default DataBindings setup is not the way to go in this case. As an alternate solution I tried setting up and extension method to 'bind' things together. It still needs some cleanup but at least it provides the behavior I wanted and all the get/set operations are separated out individually. Worst idea, or merely a bad idea? e: OK, there is a pretty bad flaw here - if I want to change the dataSource object repeatedly there is no way to clean up the existing event handlers. e2: Actually it looks like you can clear the events from outside the class via reflection. It's not pretty since it clears *all* event listeners, but maybe within the limited context of this application that'd be something I could live with. e3: Screw this idea. Messing with eventhandler lists is a mess and breaks the whole way that events are supposed to work. code:
PDP-1 fucked around with this message at 22:49 on Jan 30, 2012 |
# ? Jan 30, 2012 17:00 |
|
|
# ? Apr 23, 2024 13:03 |
|
Ithaqua posted:That sounds about right. Yeah that worked pretty well. Now for the icing on the cake. Integrating it with our off the shelf ticketing software if I can. (not completely necessary, but I'm going to try to do it anyway. Who wants to make everyone's lives easier? this guy ) Edit: Tiny rant incoming: some smarmy as gently caress douche at the company tells me today, "I don't know why you bothered to code all that, it will be obsolete when we migrate to SharePoint" Please tell me there's a way to import an existing ASP.NET application into SharePoint so I can shut his smug rear end up. aBagorn fucked around with this message at 00:35 on Jan 31, 2012 |
# ? Jan 30, 2012 20:15 |