« first day (2433 days earlier)      last day (2517 days later) » 

9:00 AM
@1_bug If it's just a question of the fields you mentioned here, you're fine. The problem arises when there's a big difference between the two cases.
Let's say, your first view needs only title and ID, and the Details view needs the full file contents, which can be large. In this case, it makes more sense to have separate viewmodels - don't load the full file contents if you only need the list.
Now, you're going to have to predict the future. If you choose to have a shared VM and your requirements change in the future, forcing you to split them, you're going to have to do more work to separate the two.
 
mr5
@AvnerShahar-Kashtan I do follow conventions based on what is established by the experienced majority but I am really referring to C# in this case :)
I also find myself hard to adapt into pascal casing when naming a function after been in Java for some years
and the bracket styling also. I think this is only popular in C#
 
I find underscores useful for stuff like
private int _myVar=0
public int myVar {get{return _myVar;} set{_myVar=value<20?value:20;}}
 
(of course, you can write using only properties, this is just a dummy example.)
 
If you choose to separate them now, you're adding more work now, adding more complexity to the design. If it never changes, it's unnecessary.
@satibel Yeah, that's the common standard for private fields.
@mr5 It's always a good idea to be familiar with more than one language. Hence, it's always a good idea to be able to switch between coding styles.
 
mr5
9:23 AM
I could use the same casing and bracket styling in C, C++, PHP, Java, JavaScript and they would still follow the majority syntax convention. C# and VB.NET are the only exception
*from the languages I know
 
I have one which use Pascal_Snakes.
 
mr5
@satibel I think, that is mixed of snake_casing and PascalCasing
 
9:46 AM
that is.
 
mr5
I didn't noticed you wrote Snakes. silly me
 
@mr5 it had to be Snakes.
 
Afternoon
 
mr5
10:02 AM
^ from east?
 
mr5
10:13 AM
this
175
Q: How do you stop yourself from refactoring working-but-awful code?

orjI have this problem. I can't stop myself from refactoring existing code that works but is, in my opinion (and perhaps objectively), badly designed or contains other "code smells". This can have a significant negative effect on my immediate productivity. But ultimately will be a big maintenance...

"I am that guy who always work on legacy codes"
 
C4u
11:07 AM
Hi everyone. I would like to let the user choose a condition out of 3 fields. Something complex like (1="something" AND 2="else") OR 3="something". Do you guys have any idea how to bring that ability to GUI?
The only thing I can imagine is creating a matrix out of textfields...
Columns would be ORs and rows would be ANDs. But thats not very user friendly I guess.
 
@mr5 Personal story: We gave several devs from india completely new projects, only the stack was given, no legacy whatsoever. We had to rewrite 90% of their code
 
enum Somethingcomplex {"something"=1, "else"=2, "somethingagain"=3}
 
var data0, data1, temp_data, tempData1 = 0
That's not to say that developers from india are bad or anything, I knew quite a few very talented folks from there
 
C4u
Well "something" was ment as a value of field 2
 
But making excuses like "I'm the guy who always works on legacy" is a bit weak.
 
11:10 AM
Dictionary<string,int> Somethingcomplex = new Dictionary<string,int>()
{ {"something",1},{"else",2},{"somethingagain",3} };
theres so many way to do, search it.
 
C4u
So I guess you mean enum ConditionalCheck { Field1 = 1, Field2 = 2, Field2 = 3 }. And then? Using binary operators?
I think you missunderstood that.
Imagine using a search engine for emails. The user should be able to choose something like (sender="mail@somewhere.de" AND subject="mySubject") OR text="Hi there".
 
@C4u Im answering this.
 
!!kieran
 
Feb 27 at 16:02, by Kieran
Thank you for confirming im an idiot c:
 
C4u
@nyconing Yep. And I was talking about a solution for GUI there. The user has to decide for the condition.
 
11:14 AM
TFW You find a simple solution to a problem you thought was much more complex
pls no star
Nearly said another stupid thing
 
your information given not enough, please explain more
on: what youre trying to interacting with user?
example: "searching all email with many properties"
 
C4u
Input of user: (sender="mail@somewhere.de" AND subject="mySubject") OR text="Hi there". <---
The user should be able to input conditions.
For example to search for emails.
But the user cant code. I cant place a textbox and let the user write an IF statement in C# ^^
 
List<emailmodel> emails;
var result = emails.where(x=>
x.sender=="user-input" ||
x.subject=="user-input" ||
x.subtitle=="user-input").tolist();
instead of `x.sender=="user-input"`
you may implement `x.sender.toLower().contains("user-input".toLower())`
 
C4u
That would be 3x OR
Check this textbox. This sucks. Im looking for something simpler for the user
 
GUIs for query builders are never simple, unless you constrain the options.
 
11:24 AM
how do users input that thing?
 
C4u
Yeah. Never had such case.
@nyconing THAT is the question.
How :D
 
then see my code
 
The most common one I've seen is a data grid where the user selects AND or OR, a field name, a comparison (=, >, <, !=, etc.) and a value to compare it to. It then combines each row into one big condition
 
C4u
Hmm okay. I already had the idea of a table but rather like a matrix.
           Sender Subject Text
Sender
Subject
Text
Columns are ORs and rows are ANDs.
 
11:27 AM
is it possible to put a ref parameter into field, and use it really as a ref?
 
@ntohl you can use pointers in c#
(not recommended)
 
Check out, for instance, the query builder for TFS work items:
 
C4U, youre stuck because you has bad approach.
 
@ntohl Not a field, only a local variable
 
11:28 AM
So it probably won't work with a closure either
 
C4u
Hmm.
 
@ntohl You might be able to wrap a ref param with setter and getter lambdas.
 
        public void SetValue<T>(ref T value)
        {
            _value = value;
            ...
        }

        private object _value;

        ...
        _value = XY;
 
C4u
Not looking bad but an OR would only refer to the last item? No brackets possible there I guess.
 
@AvnerShahar-Kashtan oh. Thanks
my example did not work
 
11:32 AM
@C4u Usually I think they're grouped according to precedence, for example like in C# where && has higher precedence than ||.
 
C4u
Hmm learned something new.
 
    public void SetValue<T>(ref T value)
    {
        _setMethod = (x => value = x);
can't set ref param in anonymous method...
 
@ntohl Yeah, that's what I was thinking. Not sure it would work.
 
Does that work?
5 mins ago, by Kendall Frey
So it probably won't work with a closure either
That's what I figured
@AvnerShahar-Kashtan Oh I thought you meant passing in the setter. That's what I was thinking of.
 
Nope. "Cannot use ref parameter inside anonymous method or lambda expression"
 
11:35 AM
public void SetValue(Action<T> setter)
{
    this.setter = setter;
}
 
> (3,37): error CS1628: Cannot use ref or out parameter 'value' inside an anonymous method, lambda expression, or query expression
 
I'd make it using the grammar:
S=>Expression
Expression=>(Expression)
Expression=>Expression Operator Expression
Operator =>{OR,AND}
Expression=>Field
Field=>{field1,field2,field3}
 
That could work. Passing in the setter instead of the ref.
It's much clearer, too. Instead of thinking in pointers and references, think in actions .
 
IORef ;)
 
it will be somewhat problematic to store the Func with generic parameter T...
 
11:38 AM
Is Func<T> covariant?
Probably not.
 
It is
 
(Or is it contravariant? I never remember which is which)
 
but we're not talking about Func
we're talking about Action
 
    public void SetValue<T>(Func<object, T> setterFunc)
    {
        _setterFunc = setterFunc;
complains
 
which is also
 
11:38 AM
    private Func<object, object> _setterFunc;
that was generated for _setterFunc field
 
or, rather, Action is contravariant
 
The setter should be an Action<T>.
So your field should be Action<object>, and you pass in an Action<string>
 
Worst case, you could wrap the Action<T> in a cast in an Action<object>
loses static typing though
 
    private Action<object> _setterFunc;
    public void SetValue<T>(Action<T> setterFunc)
    {
        _setterFunc = setterFunc;
still not work
 
Yes, as I explained, Action is contravariant
 
11:41 AM
@satibel then for the gui, use comboboxes for Operators and Fields, and make an add button to make an Expression into either a parethesised one or one with an operator. (show expressions as Fields by default) @C4u
 
private Action<object> _setter;
private string val;

public void PrepareSetter<T>(Action<T> setter)
{
    _setter = obj => setter((T)obj);
}

public void SetValue<T>(T value)
{
    _setter(value);
}
Then you call PrepareSetter once, and then SetValue.
PrepareSetter<string>(s => val = s);
SetValue("a");
val.Dump();
 
thanks
works like charm
 
11:58 AM
The actual setter itself isn't typesafe, as @KendallFrey mentioned, but you do have static type checking in the call to SetValue<T>.
So unless you have some other private methods in your class that access the _setter themselves, you're pretty good to go.
 
sidenote: at PrepareSetter call I have to specify T, and it can't figure it out.
 
Why can't it?
 
Because it's not awesome like Haskell
 
And again, a version with generic methods but not a generic class: dotnetfiddle.net/sQWmw2
 
yes. The same as 2nd link, just compiler couldn't find out <string> from Action<string>
 
12:14 PM
It can't infer usage automatically because s => val = s isn't explicit. You'll either have to explicitly state it as PrepareSetter<string>, or specify the arg type: PrepareSetter((string s) => val = s)
The compiler can infer a generic type from a parameter passed to a method, but it can't infer a generic type by usage inside an anonymous method.
Even though val is string and val = s will only compile if s is a string, it can't infer it .
 
oh. not val had to be explicitly typed, but s. Ok. Thanks for the more elaboration.
 
I think my MVC application has evolved into a webAPI application...
 
C4u
12:29 PM
Thanks for all that ideas.
 
12:47 PM
I have a WCF Service and have added a service reference to a wsdl service that will be posting SOAP messages to my WCF Service.
Here is my code that will consume the message
        public Message ProcessMessgae(Message message)
        {
            MessageBuffer buffer = message.CreateBufferedCopy(8192);

            // Get a copy of the original message. This will be used to read and extract the body.
            Message msgCopy = buffer.CreateMessage();

            // Take another copy of the same message. This will be used to return to the service. Returning an identical message forms part of
            // the acknowledgement in this case.
            Message returnMsg = buffer.CreateMessage();
 
Why are you working with messages instead of proxied RPC?
 
The exception I'm getting is on this line
var instance = (OTA_HotelAvailRQ)serializer.Deserialize(reader);
{"There is an error in XML document (1, 2)."}
Inner Exception is
 
And what does bodyData contain?
 
{"<OTA_HotelAvailRQ xmlns='http://www.opentravel.org/OTA/2003/05'> was not expected."}
The body for example is
<OTA_HotelAvailRQ Version="1.0" TimeStamp="2005-08-01T09:30:47+02:00" EchoToken="fb57388d" AvailRatesOnly="true" xmlns="http://www.opentravel.org/OTA/2003/05">
  <AvailRequestSegments>
    <AvailRequestSegment AvailReqType="Room">
      <HotelSearchCriteria>
        <Criterion>
          <HotelRef HotelCode="HOTEL1"></HotelRef>
        </Criterion>
      </HotelSearchCriteria>
    </AvailRequestSegment>
  </AvailRequestSegments>
</OTA_HotelAvailRQ>
 
I'm guessing the XML serialization metadata on OTA_HotelAvailRQ isn't properly mapping the fields.
 
12:52 PM
How best to overcome this issue ?
 
i think i have gitphobia
 
@AvnerShahar-Kashtan Should I look to create partial classes that defines the mapping my self ?
 
!!remove ymca
 
@juanvan That didn't make much sense. Use the !!/help command to learn more.
 
@AvnerShahar-Kashtan if I replace the xmlns with nothing like
bodyData = bodyDate.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
I get some partial serialization
But the child objects like AvailRequestSegments to start aren't serialized are are null
 
1:14 PM
Don't fix namespace problems by removing namespaces. They're there for a reason.
Learn to handle namespaces.
 
^
my favorite avner is here
 
I'm your only Avner, aren't I?
 
@AvnerShahar-Kashtan same as don't fix static problems by making everything static.
 
@AvnerShahar-Kashtan Should I look to create partial classes that defines the mapping my self ?
 
@Tommassiov Probably not.
Who created the OTA_HotelAvailRQ class?
 
1:22 PM
It was created when I added the service reference
It is in my reference.cs file
 
@AvnerShahar-Kashtan im not sure, but regardless <3
 
Does it specify the namespace as an attribute on it?
 
This is what it auto generated
   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.2046.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.opentravel.org/OTA/2003/05")]
    public partial class OTA_HotelAvailRQ : object, System.ComponentModel.INotifyPropertyChanged {

}
 
See the last attribute - it specifies that this object should be generated from XML in that namespace.
 
Yes, but strangely if I go to opentravel.org/OTA/2003/05 it doesn't exist..
 
1:29 PM
It's not an address. It's just a URI - an identifier for a schema.
The use of the http schema for XML namespaces has been a source of much confusion over the years.
It can be http://blah-blah/bloop as easily.
Or even just urn:blah-blah
4
Q: when to use a URN for xmlns

ThufirFor a "hello world" type xml document: <?xml version="1.0" encoding="UTF-8"?> <!-- see http://www.w3.org/TR/REC-xml-names/ --> <bk:book xmlns:bk="urn:loc.gov:books" xmlns:isbn="urn:ISBN:0-395-36341-6"> <bk:title>Cheaper by the Dozen</bk:title> <isbn:number>1568491379</isbn:number> </bk:book>...

 
Oh right I see
 
mr5
yo yo yo yo
my PC's back :D
 
yo yo yo
awesome
where did it go?
 
mr5
from my elder sister xD
 
@AvnerShahar-Kashtan Any ideas ??
 
1:41 PM
 
wow there was a shooting
at a GOP practice baseball game
 
DC?
 
Virginia
 
@mr5 oh america
you've done it again
 
1:45 PM
yep
but at least this time
well nvm
 
Isn't it a big slap to the face for all police officers who do get shot by rouge people, that the guy who dealt the weapons to them is ultimately their boss?
 
i was going in that direction
lol
 
@Nerdintraining wow racist must? What do you have against rouge people?
 
donnu
they start with r
 
mr5
considering the size of US and mixed cultures and races, those events are unavoidable
 
1:52 PM
(hint rouge != rogue)
 
lmao i missed that
 
!!define rogue
 
@mikeTheLiar rogue A scoundrel, rascal or unprincipled, deceitful, and unreliable person.
 
!!define rouge
 
@mikeTheLiar oh :D
 
1:53 PM
@mikeTheLiar rouge Of a reddish pink colour.
 
welp i messed up again
Why is the rum gone?
!!kieran2
 
any one know about partial encryption and decryption of a life
 
unfortunately, once lives are encrypted they cannot be decrypted
it's more of a hash than anything
 
@Prashee ATGCGCGCATAT
 
1:56 PM
@satibel :D
i got it :D
 
i am new to chat.stackoverflow
can you pls explain things
@satibel
 
!!define file
 
fun fact : cats should have CAT somewhere in their DNA.
 
@mikeTheLiar file A collection of papers collated and archived together.
 
Hola
 
1:58 PM
!!define life
 
@mikeTheLiar [life](http://en.wiktionary.org/wiki?curid=8394) (uncountable) The state of organisms preceding their death, characterized by biological processes such as metabolism and reproduction and distinguishing them from inanimate objects; the state of being alive and living.



(biology) A status possessed by any of a number of entities, including animals, plants, fungi, bacteria, and sometimes viruses, which have the properties of replication and metabolism.
 
@satibel :)
 
Mobile chat sucks
 
mr5
Isn't Caprica from anime? I remembered it was a giant girl with weirdness and stuff
 
@JABFreeware mobile keyboard sucks
 
1:59 PM
When thr keyboard come up it doesnt even auto scroll
 
@satibel so true
 
vacuum cleaners suck too.
 

« first day (2433 days earlier)      last day (2517 days later) »