|
GrumpyDoctor posted:You mean pulling information off the GUI? I've never had a problem with it before, and usually problems with that kind of thing cause crashes, not mystery no-ops. If I'm not mistaken, you still shouldn't reference UI elements in a background worker (or in any non-UI thread, really). I forget if it just outright blows up or behaves in an unpredictable fashion, though. You can specify an object as a parameter in the DoWorkEventArgs, so just make a struct that holds the UI parameters and pass it in when running the background worker.
|
# ¿ Nov 19, 2010 04:02 |
|
|
# ¿ May 22, 2024 06:56 |
|
epswing posted:5) Is Linq to Sql bad for an N-tier environment/application? Am I an idiot for not using Entity Framework, or something else? I've read this Linq to Sql vs Linq to Entities article, and it seems like Linq to Sql matches what we want better than EF. I wouldn't use LINQ to SQL simply because Microsoft isn't developing it any further; it's a dead end. I like nHibernate, but I haven't really played with EF so I can't speak to the advantages or disadvantages of one versus the other.
|
# ¿ Nov 19, 2010 04:13 |
|
epswing posted:While I know my UI will map 1-1 with my DB (I'm designing both)...I'm starting to understand the benefits of decoupling the two. I obviously don't know how the particular application you're working on relates to your entire business, or how much of this you already know, so I'm just going to lay it all out. Typically, you'll end up with three tiers: - Presentation - Business Logic - Data Access There can be more tiers as necessary, but that's the three-tier baseline. Your data access layer handles all the data retrieval, whether it's from the file system, a database, a stone tablet, whatever. This gives you the benefit of being able to swap out the data access layer later on, which is vital for unit testing. You don't use a concrete implementation of your DataAccess component, you use something that implements IDataAccess, which could be anything! If you realize that you hate nHibernate and want to use an ODBC driver to a Foxpro database, or store all your poo poo in flat files, you can do it without dicking around with anything else. Your business logic layer does all the boring businessy poo poo. If you have a customer database and your data access layer returns a List<Customer>, but your application only needs customers that are over the age of 30, your business logic layer strips out everyone younger and returns a nice, simple list. Then, you just tie whatever your business layer is spitting out to a UI. Your UI doesn't give a rat's rear end where the data comes from or how it was shaped, it just takes what it's given. Same goes for putting stuff back into the database. You change one of your customers? Great! Shove it through your business logic, which validates that the changes are okay and passes it along to the data layer. There are some pretty obvious benefits to designing software like that, the biggest one (in my opinion) being testability. You can test all of your business logic until you're sure that your software behaves properly and doesn't explode the second something unexpected happens. You can also test the poo poo out of your data access layer to make sure that, given a database containing <X>, when I ask for <Y>, I get the <Z> that I'm expecting. The presentation layer is the most difficult to test, and that's why you've decoupled everything to the point where the presentation layer has practically no code in it! Also, look into unit testing frameworks if you haven't already. I've used MSTest and Nunit, and I have no strong preference for one versus the other. Ripping out a huge chunk of business logic out for refactoring isn't anywhere near as terrifying when you know it's under test. New Yorp New Yorp fucked around with this message at 02:32 on Nov 20, 2010 |
# ¿ Nov 20, 2010 02:27 |
|
epswing posted:E: Oh snap, don't get me wrong, thanks for your help/reply, I don't at all mean to downplay your post. Especially the testing bit...it's a world of difference to know the major thing you just modified hasn't broken something on the other side of the system. I should write more unit tests Yeah, maybe it will enlighten someone else! At my job, we get absolutely torn apart in code reviews if we don't have decent test coverage, so writing good unit/integration tests is becoming a way of life. I've been dabbling in TDD/BDD, but it's drat hard to get your brain wrapped around it. While I'm here, anyone have any experience with Reactive Framework? I've been messing around with writing an event-driven IRC engine in C#, and Rx looks like it would be useful.
|
# ¿ Nov 20, 2010 04:41 |
|
We're interviewing for a .Net developer position at my job right now and we encountered a woman who was doing pretty well right up until we asked her to code up a string reversal, in Visual Studio, on the spot. 20 minutes later, we had to stop her because she still hadn't gotten it. We weren't looking for cleverness; a for loop would've been fine. She just outright couldn't figure out how to reverse a string. It didn't help that the first 5 minutes were her looking at "StringBuilder str = "";" and being very confused as to why it was showing up as an error. [edit] My solution was "new string(stringToReverse.Reverse().ToArray());" and it took me about 45 seconds to figure out; I wasn't even 100% sure that there was a LINQ Reverse method. New Yorp New Yorp fucked around with this message at 03:15 on Jan 23, 2011 |
# ¿ Jan 23, 2011 03:10 |
|
Dromio posted:I have given that exact answer in interviews and accepted it as an interviewer. A matter of taste I suppose. Of course if pressed I could do a loop to reverse it, but why? I'd rather spend my time using the tools I have been given to solve a problem. Exactly! We're interested in seeing how easily the person arrives at the solution and if they can arrive at it at all.
|
# ¿ Jan 23, 2011 16:08 |
|
PhonyMcRingRing posted:If she couldn't figure this out, I'm curious as to what was on her resume and how she was doing well in the interview up to that point. She was on the fence after the phone tech screening, but she was doing okay with the business logic-y in-person questions. She also had successfully completed another simple coding task in a highish but reasonable amount of time.
|
# ¿ Jan 23, 2011 19:40 |
|
JerrysMom posted:I've been tasked with finding out why a web page is slow sometimes (yay...) Easy question: You're hitting a database. Are the database tables you're hitting properly indexed? How big is the dataset you're retrieving?
|
# ¿ Jan 25, 2011 02:47 |
|
Scaramouche posted:The second part is, do you feel it's better to maintain existing web forms projects than just rewriting them? It's never better to rewrite just for the sake of rewriting. You rewrite when you have a pressing need to do so. If you have a bunch of pages that work perfectly well and have no glaring problems, why tempt fate? Leave them the hell alone! If you need to add a huge swath of new features, then you weigh the pros and cons and possibly rewrite it.
|
# ¿ Feb 8, 2011 05:06 |
|
Horse Cock Johnson posted:Can anyone recommend an alternative drawing API to System.Drawing? What I need to be able to do is load up an image from disk, resize it, and draw rectangles on it - kind of like Facebook's tagging functionality. We currently do this just fine using System.Drawing but the whole thing will periodically poo poo itself with errors from GDI+ like "out of memory" or "a generic error occurred in GDI+". You can check out Leadtools, although the licensing is fairly pricey. I hate the "generic error occurred in GDI+" message. It's so loving useless.
|
# ¿ Feb 24, 2011 02:14 |
|
Jethro posted:Because you really shouldn't depend upon your customers (or employer) installing a test version of C# that could be buggy as hell, may change without warning, and isn't even legal to use in a non-faffing about environment. There's no "could be" about it (as evidenced above). When I saw it demoed at Codemash back in January, I was duly impressed, and I've played with the CTP in my spare time. The new async stuff is awesome, but it's not ready for production quite yet.
|
# ¿ Mar 19, 2011 06:14 |
|
fankey posted:I need to persist what's effectively a Dictionary<string,byte[]>. My naive implementation was to create a class and then use the BinaryFormatter to persist I don't see any problem with your current approach. Why does it "suck"? Performance? You could look into a nosql database, but I'm not going to recommend any because I have very little practical experience with them, and that seems like a pretty heavy solution to your problem.
|
# ¿ May 14, 2011 01:10 |
|
Peao posted:2) Can you name a few things which you would expect a junior dev to be able to do from memory, without looking up the correct syntax or .NET classes and methods? It would help me rate myself. I'd expect a junior dev to be conversant with the language. Knowing abstract classes vs interfaces, virtual methods, boxing and unboxing, is all good. Brush up on LINQ/lambdas, too. It's pretty awesome stuff. Mega bonus points (to me, at least) for being familiar with unit testing and dependency injection. Knowing minutae about every language feature is not necessary, and no one is going to care that you don't know that a using() block translates to a try{} finally{} in IL (although they might be impressed that you do!). Oh, and don't try to bullshit an interviewer. We know. We're not asking the question because we're not sure what the answer is. quote:3) In development teams, is a junior given time to bed in with the project, or is he expected to be productive immediately? If he's eased in, what sort of tasks is he given at first? For me, it's pretty much the same no matter what your skill level... when you come in, you're lobbed a few easy tasks to get you familiar with our codebase, database schema, source control organization, and all that little stuff that comes with getting settled in. After that, it's "here's a non-critical but reasonably-sized task that needs to be done: ___. Here's how I'd approach it: _____. Go nuts, ask me if you have any questions." It's critical to ask questions when you're not sure about something. If you don't, you're going to gently caress something up, guaranteed. And then during code review, someone is going to tear you a new rear end in a top hat, and then you'll feel bad and they'll feel bad and everyone will feel bad.
|
# ¿ May 15, 2011 20:32 |
|
Here's my weirdness for today, with a solution even! I was trying make a generic version of an existing method that acts on one specific object that implements an interface. Here's the problem condensed down to some classes and interfaces. Given a setup like this: code:
code:
Here's a solution that looks like it works (with due credit to one of my co-workers): code:
|
# ¿ Jun 2, 2011 01:38 |
|
Thanks npe, that was very enlightening!rolleyes posted:Funnily enough I've just been digging a bit further into covariance (and contravariance), in particular the use of the "in" and "out" keywords when defining a generic interface. In summary, it made my head hurt for a bit but once you understand the reasons behind it (and can remember which is which ) it is indeed cool. Yeah, that's on my increasingly long list of things to really study.
|
# ¿ Jun 2, 2011 11:33 |
|
brainwrinkle posted:I'm working on a new ASP MVC 3 website for analyzing data from an existing MySQL database. I've been working on getting Entity Framework 4 and LINQ to SQL to play nicely, but it seems there's a pretty bad bug in the MySQL connector that breaks group statements. Are there any good alternatives? Preferably I would like to use EF and/or LINQ, but if there are other good practices I'm not aware of (I'm new to .NET) I'd love to hear about them. nHibernate is an option, but I've never done nHibernate to MySQL. There's also SubSonic, but I've never even used it and I have no clue about getting it to work with MySQL, so I'm leaving it up to you to evaluate it. Also, what the gently caress is wrong with your DBA that he won't let you use stored procedures? Are you supposed to use inline SQL if you can't get an ORM to work?
|
# ¿ Jun 4, 2011 00:05 |
|
brainwrinkle posted:Fortunately, there was a patch that worked with some tweaking, and I recompiled the connector and got around the problem. Thanks for the suggestions. I might still check those out because I'm having some difficulty translating these moderately complex SQL queries to LINQ. At least with nHibernate, I've had good experiences with making a view that returns the exact data I'm looking for and working with that. Keep in mind, the ultimate goal here is to have the actual SQL be as simple as possible and let your code handle the logic. The thing I like about nHibernate is that it operates on plain C# classes without any need for attributes or anything nHibernate-specific. I could decide "gently caress nHibernate!" tomorrow and re-implement the data access part, and nothing else in my codebase would have to change.
|
# ¿ Jun 4, 2011 02:26 |
|
I'm going to take the sane, rational approach and not flip the gently caress out over a demo showing one aspect of one of the new things they have planned for Windows 8. I strongly doubt .NET as a platform is going anywhere. At worst, they'll start really pushing WPF/Silverlight. [edit] And that's a "worst" that's not even really a bad thing. The little I've done with WPF, I've liked.
|
# ¿ Jun 15, 2011 00:52 |
|
boo_radley posted:Hey, take a look at this Visual Studio Extension: Debugger Canvas. Fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuck, that's awesome. I have VS2010 Ultimate at home, but not at work. It's going to spoil me.
|
# ¿ Jun 17, 2011 02:35 |
|
Hoborg posted:I must apologise for refusing to stop living in 2005 (.NET 2.0 forever!) but can someone explain, very quickly, what Rx is and what it enables/allows developers to do that they couldn't do before? What your friend is probably talking about is the Parallel task library, which is new in .NET 4 and is awesome. I mean, what's going to be easier to maintain and debug? Writing a shitload of concurrency code, or doing Parallel.ForEach()? Rx is for doing work asynchronously without starting up a new thread. Also, I hope you're kidding. .NET 3.5 and 4.0 have some awesome, awesome features and if you're not familiar with them, you should be. New Yorp New Yorp fucked around with this message at 22:51 on Jul 1, 2011 |
# ¿ Jul 1, 2011 22:48 |
|
Milotic posted:nHibernate ... It's also beginning to feel like an amazingly crufty piece of poo poo nowadays. How so? I'm not disagreeing, just curious. I've recently realized that although I've been using nHibernate for a year or so, I've barely scratched the surface of what it can do.
|
# ¿ Jul 3, 2011 04:18 |
|
Scaramouche posted:I know exam-chat has already passed, but thought I'd share. Back in the late 90s they had basically what is MCITP now but I forget what it was called then (think it was just generically MCSE with a desktop specialization). One of the questions was "How many floppy disks are used for the standard Windows 95 installation?", which totally sucked because it could be either 15 or 31 at the time. And of course it's absolutely vital to know that.
|
# ¿ Jul 26, 2011 01:49 |
|
Monkeyseesaw posted:^^ oh yeah and dynamic which is pretty cool but like the generic covariance etc only comes up if you really need it. There's also the parallel task library and about a million other things of varying levels of usefulness. In general, if you have the option to go with .NET 4 in a new project, do it! Obviously, for learning the language, 3.5 vs 4.0 isn't going to make too much of an impact.
|
# ¿ Aug 14, 2011 18:43 |
|
Rocko Bonaparte posted:I have another GUI question. I'm still trying to write some unit tests for a GUI. I was hoping to find out a way to tell if the GUI has finished starting, so I can start sending events to it. Currently I can let it sleep 5 seconds and get lucky, but that means at least 5 seconds per test that spawns a new GUI. I was wondering if there's a standard way to tell if a GUI is up and finally responsive. If it helps, the main control I test is a text box. You don't want to write tests for your GUI, you want to write tests for the underlying logic. Optimally, as little code as possible is in your GUI. If you want to test GUI interaction, look into something like Coded UI.
|
# ¿ Aug 19, 2011 12:25 |
|
Orzo posted:I disagree, GUI code should be tested just like everything else. Agree that it should be kept thin, but real things happen in a GUI that need to be tested. Even if you're using the best possible abstractions and a really clean model-driven UI, you should still be testing that the model and the UI are properly wired, i.e. clicking this button should trigger some service and also trigger a model refresh. Fair enough. That's where tools like Coded UI come in!
|
# ¿ Aug 19, 2011 23:52 |
|
I'm playing around with EF4.1 tonight, and I've got to admit that it's pretty slick. My only other ORM experience is with nHibernate, and EF feels like a lot less effort to get up and running. Of course, I won't be getting my current employer to move to an ORM anytime soon. I'm fighting an uphill battle to get them on board with unit testing.
|
# ¿ Aug 20, 2011 03:48 |
|
mik posted:I've noticed that while doing some performance profiling, the first linq query takes 5 times longer than the equivalent loop, but if I run the query again, it takes essentially an identical amount of time. Are Linq queries cached? In my experience, LINQ performs worse than a non-LINQ equivalent, but it really shines for making readable code. For example, code:
code:
|
# ¿ Sep 3, 2011 00:35 |
|
gariig posted:Can you post the timings? From what I've seen the difference is pretty small It is a tiny difference, and I was wrong, anyway. My last test was with Enumerable.Sum(x=>x) instead of Enumerable.Sum(). Turns out Enumerable.Sum() is way faster, which probably shouldn't have surprised me but did. I generated a list of 50,000 random numbers and summed them 10,000 times with LINQ and 10,000 times with a foreach. I don't do much in the way of measuring performance on a regular basis, so I can't speak to whether this is actually accurate! Total run times are: LINQ: 33 seconds (33071 ms) Foreach: 34 seconds (34606 ms) And here's my code so someone can tell me how I'm measuring performance all retarded-like and educate me. I also took this as a chance to play around with Actions and Funcs! code:
|
# ¿ Sep 3, 2011 03:29 |
|
Fiend posted:http://msdn.microsoft.com/en-us/library/3det53xh.aspx#Y57 But be aware that if you want to write unit tests, using a singleton makes it a big pain in the rear end. There are other ways to make an operation thread safe.
|
# ¿ Sep 10, 2011 16:50 |
|
rolleyes posted:
Try this: code:
|
# ¿ Sep 10, 2011 17:34 |
|
rolleyes posted:Ah, so it does come down to a lot of nesting then. I was hoping there was some way to 'bracket' different types of object within the same using scope but I guess not. You can do code:
If you want some more fun, look at doing the file processing in parallel!
|
# ¿ Sep 10, 2011 17:51 |
|
rolleyes posted:I think I'll save the combination of unmanaged resources and thread safety for another day thanks! Stream.Synchronized() will give you a thread-safe stream.
|
# ¿ Sep 10, 2011 17:54 |
|
Nurbs posted:switch to project references and use visual studio to get the latest version from tfs? This.
|
# ¿ Sep 23, 2011 12:19 |
|
Milotic posted:Whether you should just propagate the classes created by Entity Frameworks right up the stack to your presentation layer is an interesting one. On the one hand it makes development a lot faster. On the other hand you could argue the Database isn't always structured quite right for Business objects. I've seen both sides, and I prefer the latter option. I'd rather retrieve a database-shaped representation of my data and then mold it into a presentation model / business object that contains exactly the information I need, structured exactly the way it's needed for the task at hand. You still have to be careful, of course, lest you end up with half a dozen slightly different models of the same data. Milotic posted:One thing I would suggest is some sort of repository pattern or interface for routing the bit where you actually hit the database - even if you just pass the objects returned straight through. Oh god yes, do this. New Yorp New Yorp fucked around with this message at 03:51 on Oct 1, 2011 |
# ¿ Oct 1, 2011 03:44 |
|
Nurbs posted:Use the task parallel library in .net 4, I believe it will manage the work better than simply queueing the items directly on the threadpool Well, the TPL uses the threadpool behind the scenes if I'm not mistaken, but yes for the love of god use the TPL. It makes life so much better.
|
# ¿ Oct 12, 2011 03:13 |
|
gariig posted:Ok I have a Visual Studio solution question. We are in the process of rewriting an application that a framework. We will have about 75 projects that use the framework. Should the projects that use the framework live within the framework solution? If it does live in the framework solution should it use a project or file reference? Your framework should have its own solution. Anything that uses your framework should include necessary project files from the framework.
|
# ¿ Oct 14, 2011 01:13 |
|
Kreeblah posted:If there are any WCF gurus out there who have seen this, I'd very much appreciate some help. Post the app.configs from both the client/service end, obviously with any sensitive information (server names, credentials) redacted. WCF is awesome, but getting the endpoints set up properly can be a real pain in the rear end.
|
# ¿ Oct 24, 2011 12:44 |
|
GrumpyDoctor posted:I have a C application that receives a FILE * and writes stuff to it, and I want to use this functionality from .NET (4.0). I know how to do basic platform invoke, but I can't figure out what to use for the FILE * in the call into the native application. I tried using the unsafe handle from an anonymous PipeStream but I'm not receiving any data (even after I turned buffering off on the C side - I couldn't see how to try that on the C# side). I feel like I should be using an UnmanagedMemoryStream but I can't figure out how to set it up. Any reason why you can't just run a completely separate C# application that reads the file?
|
# ¿ Oct 30, 2011 23:57 |
|
Paul MaudDib posted:I want to make a property do something, then return its wrapped value. i.e. i want to replace Be careful with having a property call a method like that, especially since it seems like "DoStuff()" has a side-effect of mutating the value of "value". Read this and then reconsider your design.
|
# ¿ Nov 8, 2011 14:03 |
|
|
# ¿ May 22, 2024 06:56 |
|
Sedro posted:VS without R# is like using notepad to me now. Here's some stuff I use all the time: Also, the Extract Method feature is amazing. Highlight a chunk of code, click "Extract Method", and bam! It figures out what needs to be passed in as an argument and what to return. Extract Interface is similarly rad. I just love that it has a lot of really great features that work right out of the box with no research, configuration, or digging through menus, but also has a ton of depth and usefulness beyond that. Lack of enthusiasm about ReSharper is one of the things that made me realize the team I just joined sucks. They won't even install the trial version.
|
# ¿ Nov 10, 2011 05:48 |