« first day (1291 days earlier)      last day (2858 days later) » 

2:05 PM
waves
 
2:52 PM
Good morning!
What's a best-practices way to return an error from a method? As a string? If string is blank, no errors occurred, else display error
I think I found the answer.... stackoverflow.com/questions/15873470/…
 
@Alex Is the error actually an exception? If so, you could just throw.
Otherwise, you could just use BOOL DoStuff(ref string szError);
Or, just write a result class that you return, that has a bool and a string member.
 
3:08 PM
@LynnCrumbling It's a violation of business rules, so in a sense, it's an exception
 
maybe also have a look at the Either / Try monads (github.com/louthy/csharp-monad)
 
The user is trying to insert a duplicate into a table on the database
Now I'm wondering if I should enforce it through constraints on SQL Server... for a given test ID, the user cannot provide the same drug ID more than once
@franssu Interesting. Had never heard of monads
 
they're like burritos :D
it's a nice way to handle errors, but maybe not in C#
 
Didn't know folks had written extensions to C#. Nice :)
 
do you have services @Alex ?
some CanAddDrug(int testId, int drugId) function ?
 
3:36 PM
@franssu Yes, I'm using a data service to call AddDrugResult(...)
 
so maybe you should have the equivalent CanAddDrugResult
 
So first perform a check that we can add, then perform the add? I've combined the two into one method right now
But if they're separate, I can perform the check, show error, else do the add
 
well, in the domain (behind the layer service) you should have the 2 functions
the domain.Add calls domain.CanAdd, so your domain won't get corrupted
you should also have 2 functions in the services
so you can bind them to some Command in your VM
 
As a noob, what is domain in this context?
 
the model layer
 
3:44 PM
Oh, gotcha!
I'm using EF... so on the database, I'd create the functions? Then pull them into my domain? I've avoided doing anything with stored proc's and functions; just been doing everything through LINQ for SQL. Coming from a background where I did everything in stored proc's and UDF's, so it's been a steep learning curve
BTW, it's a database-first design
 
sorry, I don't know EF / Sql :p
 
It's OK :)
Heading out to lunch :D
 
enjoy
 
:)
 
 
4 hours later…
8:02 PM
Is there an easy way to replicate the C functionality of passing a char* into a function (such as a serial receive function) in order to have that function put data into the pointer so that when it returns your variable has been loaded with the new data? I'm passing a string into an Ethernet data receive function as a parameter and am having a hard time getting the data into that string
 
I think that StringBuilder does all of that magically under the hood
@SlashLP97 I think you can pass a StringBuilder.
Lemme verify
Yes - StringBuilder is commonly used as a char pointer for DLL functions.
 
Well, that makes things pretty easy... I think
 
Thank you! Now back to the lab to test this out
 
Sure thing :)
 
8:23 PM
Coming from a C background C# is pretty much cheating haha
 
well, almost anything but ASM is cheating :p
 
8:46 PM
Verilog? :D
 
8:57 PM
Is there a way to detect the change of a property on an object, not just the object itself changing? For example, Foo.SomeProp changes, can the class that contains an instance of Foo detect that?
 
9:21 PM
@Alex If an object implements INPC properly, it notifies of any of its properties changing.
Hence RaisePropertyChanged(string PropertyName)
The class containing the instance of Foo would just subscribe to Foo.PropertyChanged
 
10:09 PM
just avoid mutation :p
problem goes away
 

« first day (1291 days earlier)      last day (2858 days later) »