|
Here's my headache for today. I have a DataGridView where I want certain columns centered, but changing the Alignment property seems to have no effect. After the DataGridView is populated I can alter the alignment of the column headers, but not the subsequent rows.code:
edit: I needed a fresh mind to figure this out... code:
Crazy Mike fucked around with this message at 17:47 on Jul 1, 2013 |
# ? Jun 28, 2013 23:42 |
|
|
# ? Apr 28, 2024 03:41 |
|
Aside from AppHarbor, where can I get some Jenkins style build machines and unit tests in the cloud without having to throw my IT staff at it? I'm using .NET 4.5 and NUnit
|
# ? Jun 28, 2013 23:54 |
|
Mr.Hotkeys posted:What's the best way to indicate when writing a virtual method that overriding is fine but that you need to call the base version of the method as well? Or is there a better pattern for this? I know Dispose's pattern uses two methods but even there unless the extending class defines a third to mimick the second for anything that might extend from there, you'll still run into the problem somewhere down the line if your inheritance goes that far. C# code:
|
# ? Jun 29, 2013 04:45 |
|
That would work, but only for sealed classes; it just means I'd have to keep repeating that pattern in each extending class just in case anything wants to extend it and do the same thing.code:
|
# ? Jun 29, 2013 05:14 |
|
this problem you've encountered is pretty normal - the fact is that if you want a class to be safely extensible by inheritance, you're going to have to design it that way. that means explicitly making-inheritable your intermediate subclasses, and so on. or giving up some safety. if you want things to be more composable, why not create an IFooer interface instead- your current base class could be a BasicFooer, then what are currently intermediate subclasses could *contain* a BaseFooer, having a Foo() implementation of their own which uses myIFooer.Foo(). no stage of this would have to care how deep in the hierarchy it was. Gul Banana fucked around with this message at 06:01 on Jun 29, 2013 |
# ? Jun 29, 2013 05:59 |
|
Gul Banana posted:the fact is that if you want a class to be safely extensible by inheritance, you're going to have to design it that way. Well I mean yeah that's the goal Gul Banana posted:if you want things to be more composable, why not create an IFooer interface instead- your current base class could be a BasicFooer, then what are currently intermediate subclasses could *contain* a BaseFooer, having a Foo() implementation of their own which uses myIFooer.Foo(). no stage of this would have to care how deep in the hierarchy it was. So basically sub encapsulation for inheritance? That would work, it'd be gross conceptually (for what I'm doing specifically and what the classes represent) and code (a lot of repeated methods or methods that just call other methods) but it would definitely work, and I might fall back on it depending on whether or not this looks like it's going to be a problem.
|
# ? Jun 29, 2013 06:25 |
|
Honestly I think trying to enforce this is rather unnecessary, if you write "When overriding this make sure to chain to the base class implementation" in your docs and then someone doesn't do that, it's not like they have anyone to blame but themselves. Alternatively if you're writing a components library or something you could do something like: code:
|
# ? Jun 29, 2013 07:56 |
|
Mr.Hotkeys posted:What's the best way to indicate when writing a virtual method that overriding is fine but that you need to call the base version of the method as well? I think that in the early days of object oriented programming, it was axiomatic that "call the base method" was the first thing you do when overriding. But it was never enforced, and thus fragile, and I reckon this fragility was one of the (many) nails in the "full-on OOD coffin". I still shudder when I see a library that forces you to call the base method LAST. Anyway, I'm not aware of how to force this, and I don't think there exists a standard annotation, and I think you should refactor your library to avoid this fragility.
|
# ? Jun 30, 2013 07:24 |
|
Overrides make more sense when your APIs are pure/less focused on side effects.C# code:
|
# ? Jun 30, 2013 17:34 |
|
When it looks like calling a base implementation of a method is always a prerequisite, I prefer to refactor so that I have something likecode:
|
# ? Jun 30, 2013 17:57 |
|
zokie posted:namespace provider property Ithaqua posted:
|
# ? Jun 30, 2013 21:26 |
|
I'm not sure if this would do better in the jQuery thread but I'm running into a problem with Microsoft's MVC4 and Unobtrusive validation, and jquery blockUI. I have a form with two jquery datepickers that validate remotely through an attribute on the model. This works fine as is, but I want to add a modal loading window while the processing for the submission is happening on the back end but obviously only when the form is valid. The issue I'm running into is that on initial submit of the form, the form is valid until the remote validation finishes, so something like this makes the modal loading window never go away, as the initial submit's valid is always true: code:
|
# ? Jul 1, 2013 16:23 |
|
I'm using a timer object to perform some code 2 seconds after the windows form loads, but then after that it only needs to be done once every 2 minutes or so. Right now, in the Elapsed event I'm just re-setting its Interval property, which seems pretty lovely. Is there a more proper way to do this?
|
# ? Jul 2, 2013 16:08 |
|
Sab669 posted:I'm using a timer object to perform some code 2 seconds after the windows form loads, but then after that it only needs to be done once every 2 minutes or so. Right now, in the Elapsed event I'm just re-setting its Interval property, which seems pretty lovely. Is there a more proper way to do this? You can use tasks to do this sort of thing. Timers are pretty lovely in general.
|
# ? Jul 2, 2013 16:19 |
|
Is anyone here using InstallShield 2012 LE with Visual Studio 2012? I just updated from InstallShield 2011 LE and Visual Studio 2010 (where everything was working fine, of course), and now the IS installer projects are not building. The errors are sitting in a StackOverflow question I posted earlier today. Basically it says things like "Could not find file" and "Verify that the file exists in the specified location". The files IS is complaining about DO exist in the specified location, so I'm at a loss here. How exactly am I supposed to generate my precious Setup.exe file? By selecting the SingleImage configuration and running Build Solution (this is how I always did it in VS 2010)? Or some other way? I get the feeling that it's building my projects out of order, and at the time IS tries to run, the assemblies it wants don't exist yet. epswing fucked around with this message at 18:16 on Jul 2, 2013 |
# ? Jul 2, 2013 18:14 |
|
Dietrich posted:You can use tasks to do this sort of thing. Timers are pretty lovely in general. Is there a task-based way to have a callback guaranteed to run on the UI thread? Because I'm using a timer right now only because the callback method runs on the UI and it's consistent timing. It is an IO intensive method. Basically, I read some (roughly 48) digital outputs off a card and turn some indicator lights on/off in the UI based on their value. At peek idleness with the rest of my code it runs every 200ms and in some cases every 60ms when only monitoring a single value during a procedure. It's ok if it's blocked for a second or two during certain times because it is mostly visual cues and not time-critical operations but, it needs to be able to accelerate back to normal operating speed pretty quickly after something cpu-intensive. If a task can guarantee me that in some way, I'll gladly switch.
|
# ? Jul 2, 2013 18:21 |
|
crashdome posted:Is there a task-based way to have a callback guaranteed to run on the UI thread? Because I'm using a timer right now only because the callback method runs on the UI and it's consistent timing. It is an IO intensive method. Basically, I read some (roughly 48) digital outputs off a card and turn some indicator lights on/off in the UI based on their value. At peek idleness with the rest of my code it runs every 200ms and in some cases every 60ms when only monitoring a single value during a procedure. It's ok if it's blocked for a second or two during certain times because it is mostly visual cues and not time-critical operations but, it needs to be able to accelerate back to normal operating speed pretty quickly after something cpu-intensive. If a task can guarantee me that in some way, I'll gladly switch. async methods. If you call the method from the UI thread, it will run on the UI thread. I've used a DispatcherTimer in conjunction with async methods in WPF before for periodically polling a web service and it worked great.
|
# ? Jul 2, 2013 18:49 |
|
Uh... It is a DispatcherTimer. The read operation is in the tick event. I guess I am not seeing why or where the async comes in? edit: Let me elaborate a bit so you can tell me if there is a different way. The read operation is a single method call on a device object. timer_Tick -> object.PerformRead(); this.UpdateThoseFourPeskyControls(); This method loops through 24 properties in blocks of 8 (the card can read a single value or values in blocks of a byte for Boolean outputs). Each read is roughly 5-6ms on a good day. So I loop 3 times and read 3 bytes worth of data in less than 60ms. I then also read 3 analog (basically a byte) values. Then, I update bound properties on the object doing the usual "if (prop == value) return;" so I don't fire off my OnNotifyProperty unless absolutely needed. After calling this method, way back in the tick method, I have to update some UI controls manually which are not data-bound to the object directly. Not many. Maybe 4. If I didn't use a DispatcherTimer, and I tried a few other options, I would always get the 'accessing UI on separate thread' warnings. crashdome fucked around with this message at 19:14 on Jul 2, 2013 |
# ? Jul 2, 2013 19:03 |
|
crashdome posted:Uh... So you don't block the UI thread during your IO intensive operation.
|
# ? Jul 2, 2013 19:12 |
|
You replied just as I edited in some details. I see your point. Should I just make the object.PerformRead() do the asyncing so my UI(WinForm) doesn't have to? edit: wait, but I can't update my UI until that method is done. I have to do the async/await in the tick event no matter what. Correct? VVVV OK, that's what I thought. I'll probably even throw in something to prevent the 'ticks' from stacking in the event something horrible goes wrong and it takes 5 years to do a read operation. crashdome fucked around with this message at 19:38 on Jul 2, 2013 |
# ? Jul 2, 2013 19:16 |
|
crashdome posted:You replied just as I edited in some details. Yes. Your event handler will be async, and then you make your PerformRead method async and await it. I'd expect it to look something like this: code:
|
# ? Jul 2, 2013 19:26 |
|
Can anyone think of a reason that this function inside a mixed DLL:C++ code:
e: The problem doesn't happen if the function is free, rather than a member function. edit2: Okay, my repro case isn't staying consistent so I have no idea what the gently caress is going on. raminasi fucked around with this message at 21:03 on Jul 2, 2013 |
# ? Jul 2, 2013 20:11 |
|
GrumpyDoctor posted:Can anyone think of a reason that this function inside a mixed DLL: I've seen exceptions swallowed like that before, though admittedly in a straight C# application, not mixed. Are you calling this function from a form's "Load" event handler function? http://stackoverflow.com/questions/1583351/silent-failures-in-c-seemingly-unhandled-exceptions-that-does-not-crash-the-pr
|
# ? Jul 2, 2013 23:39 |
|
No, it's not called from there. I've already identified no fewer than three unrelated subproblems contributing to this weird behavior, and I still haven't solved the underlying bit. So far:
|
# ? Jul 3, 2013 08:29 |
|
So the project I'm in now WAS using Entity, now it's not, and I'm basically navigating my first ever big project with abstraction layers and hundreds of files, etc. It was 555 the first time I checked VS's count. Hah. Since I don't have the VS edition where I can just go "make me a call graph" I'm doing it myself, and I can't find very cleanly where the bubbling up from the controller for "make a drat record and put it in the goddamn db dammit" actually reaches the methods that actually touch the database oh so intimately. If it matters, the project is VB.net (The state that gave us the contract said so, not us!). Are there any free tools out there or do I just get to play "memorize key combos for definitions and references" and click methods all day and let it just coalesce? I know how each part works, but I can't find where the hell the business object is passed to the function that takes the properties of it and sticks them into command.Paramaters to send to the stored proc. It's like there's the business object generation track, and then just sitting elsewhere there's something waiting for it, but I can't find where it's actually passed
|
# ? Jul 3, 2013 16:36 |
|
NDepend. There's a 14 day trial. However, in my experience, a "big ball of mud" application that wasn't properly designed (which may very well be what you're working on) will generate a hideous dependency graph, and you'll be just as confused after as you were before. New Yorp New Yorp fucked around with this message at 17:03 on Jul 3, 2013 |
# ? Jul 3, 2013 17:00 |
|
You sure there isn't some sort of dependency injection going on?
|
# ? Jul 3, 2013 17:02 |
|
Yeah frankly if F12 (Go to definition) and Shift+F12 (Find all references) don't cut it, the easiest way to actually dig through the execution path is to attach the debugger and step through it all, which will cover you in the cases of dependency injection and any other sort of indirection.
|
# ? Jul 3, 2013 17:08 |
|
Dietrich posted:You sure there isn't some sort of dependency injection going on? I'm pretty sure there is a good object model behind there, since my team lead was big on making sure I knew that before making big changes, and would be mentoring if he didn't get sick-as-a-dog. I also say this because there's some pretty clear this->that->the_next_thing going on, it's just that I see two chains which don't 'talk'. No Safe Word posted:Yeah frankly if F12 (Go to definition) and Shift+F12 (Find all references) don't cut it, the easiest way to actually dig through the execution path is to attach the debugger and step through it all, which will cover you in the cases of dependency injection and any other sort of indirection. Gonna do that! Thanks! Ithaqua posted:NDepend. There's a 14 day trial. Gonna do that after I try it the step-thru way, thanks for the find!
|
# ? Jul 3, 2013 17:51 |
|
Ithaqua posted:NDepend. There's a 14 day trial. I have some terrible dependency graphs in an application I wrote last year before I wizened up to DI and the factory pattern. I'd like to think every developer has those projects that have a pretty UI and a disastrous backend. Especially with a bastardized mvvm implementation. Fortunately for you 2banks, . Net makes it easy to navigate a cluster gently caress.
|
# ? Jul 3, 2013 18:21 |
|
2banks1swap.avi posted:I'm pretty sure there is a good object model behind there, since my team lead was big on making sure I knew that before making big changes, and would be mentoring if he didn't get sick-as-a-dog. Do you know what dependency injection is? It's a way of implementing inversion of control, which is vital for creating loosely-coupled, testable architectures. When you write code like this: code:
One method (and there are others) to avoid this is to use dependency injection. In DI, your Frobbler doesn't instantiate FrobbleDb. Instead, it's provided an implementation of the IFrobbleDb interface, which can be a real database object, or a mock object that returns only a specific set of data for testing. It would look like this: code:
|
# ? Jul 3, 2013 18:27 |
|
Dirk Pitt posted:I have some terrible dependency graphs in an application I wrote last year before I wizened up to DI and the factory pattern. It has a feel for my newbie self to be more than decent. The only thing that makes me go "WTF?" is two files named (A_Thing_I_dunno_if_I_can_talk_about)Repository.vb, though one is a business object, and the other is a service, and in totally different parts of a BIG project.
|
# ? Jul 3, 2013 18:28 |
|
That is probably a good sign on some levels -- they have at least made an attempt to separate concerns.
|
# ? Jul 3, 2013 18:57 |
|
Even with NDepend I can't manage to get a graph from the controller going "HEY, MAKE THIS AND PUT IT IN THE DB " and a chain of calls to where a method goes "OKAY! LOADING PARAMETERS AND CALLING THAT STORED PROC! " Now, on the other hand, I CAN do this with step-in debugging. Maybe I'll just do it by hand? Ugh.
|
# ? Jul 3, 2013 19:32 |
|
Just wait until you hit some multithreaded code that behaves differently when you're gumming up one thread with step-through debugging
|
# ? Jul 3, 2013 19:37 |
|
It's kind of shocking that only by running the drat program that I can see the bubbling up of calls until it actually puts the drat data into the db for "create a goddamn note." Truly it is the future. I'm just going to take notes and then MSPaint this so I can get out by four without having an aneurysm.
|
# ? Jul 3, 2013 19:40 |
|
JawnV6 posted:Just wait until you hit some multithreaded code that behaves differently when you're gumming up one thread with step-through debugging Would multi-thread-debugging allow you to manually trigger the likes of spinlocks or mutexes or whatever? Or would you have separate "step throughs" for each thread?
|
# ? Jul 3, 2013 19:42 |
|
Are they using an IOC container like Ninject, Unity, Castle Windsor, StructureMap, or Autofac?
|
# ? Jul 3, 2013 20:09 |
|
I ran the step-thru (more like step in ) debugger and employed my copy and paste skills to show what is involved for the controller to put stuff in the DB. Tell me if this is just the results of using an ORM or some generator, or a good attempt at separating concerns, or bad separation, or a horror, please. Please note I replaced certain things with $PROJECT and $TASK, since while I'm not under an NDA, given that this is being done for a state government, I don't want it to be too easy for some goon to figure out what I'm working on. code:
I literally had to go for a walk around the entire office building to get calmed down after doing this whole thing. Is this normal or is something really wrong? Ithaqua posted:Are they using an IOC container like Ninject, Unity, Castle Windsor, StructureMap, or Autofac? None of the devs know; the lead is sick as hell and at home. I'll ask him next week. Fuck them fucked around with this message at 21:43 on Jul 3, 2013 |
# ? Jul 3, 2013 20:23 |
|
|
# ? Apr 28, 2024 03:41 |
|
That all looks like good, well-factored code. I think what you're missing is the implementation in the base classes. [edit] I take that back, there's definitely weird/bad stuff. code:
[edit2] Also, based on some of variable names I can still tell what the software is intended for, so you might want to redact it further. New Yorp New Yorp fucked around with this message at 20:37 on Jul 3, 2013 |
# ? Jul 3, 2013 20:31 |