IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-04-02 18:00:08
Channels: 41
Logged Lines: 6229042
Size: 1809.74 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-08-07
[00:03]<cjmgrug>question, to those alive : "Program to an interface, not to an implementation" << what does that mean, precisely??
[00:04]<zndy_wjfnz>heh :) Long story
[00:04]<vufvuzn>CodeRun: a concrete example would be to use an IList reference instead of a List reference
[00:04]<vufvuzn>there's no need to bind your code to the concrete implementation (List) when all you require is the general contract pronided by the interface
[00:05]<vufvuzn>you can take this to the logical extreme & provide fine grained interfaces for everything, but that's probably overkill
[00:06]<cjmgrug>i'm sorry, didnt get it still. why would you use an IList reference instead of a List reference, anyway?
[00:07]<vufvuzn>because you only need what's guaranteed by the IList, your code doesn't actually require that the variable refer to some specific List (of course some code might require this, but it's quite rare)
[00:07]<vufvuzn>if you code to the interface, your code is more reusable - it can be used with anything that implements that interface
[00:07]<vufvuzn>eg: imagine if someone wrote a sort routine that only worked on List?
[00:07]<vufvuzn>why restrict the operation to only work on Lists when it'd clearly work quite well on any IList?
[00:08]<cjmgrug>ah i see
[00:08]<cjmgrug>interesting. thanks )
[00:08]<cjmgrug>:)*
[00:11]<drygq>how in ***'s name, should i put this in a new class :( ? http://pastebin.ca/119400
[00:13]<szgdzzajs>by putting it in a new class?
[00:15]<drygq>yes, but then it wont be convenient to talk wiht 'ResourceManager rm'
[00:15]<drygq>classname.rm(...) is enoying
[00:16]<drygq>?
[00:16]<vufvuzn>main2: so have a static function that returns the ResourceManager
[00:16]<vufvuzn>or just access it once & assign it to a local variable, etc..
[00:16]<drygq>ok so then i would make a class of type ResourceManager which returns rm
[00:16]<vufvuzn>no..
[00:17]<vufvuzn>you'd make a class of any type you like. You'd define a static function with a return type of "ResourceManager".
[00:17]<drygq>ok
[00:17]<szgdzzajs>how would I append a line? using a streamwriter.WriteLine just writes the file over
[00:18]<vufvuzn>sanmarcos: perhaps you ought to look at StreamWriter's constructors - perhaps there's something about "append" mode there? *shrugs*
[00:18]<szgdzzajs>I thought so
[00:18]<szgdzzajs>vulture, thank you brother
[00:18]<kjr>vulture: although, there's no language level enforcement of true listness
[00:19]<kjr>vulture: just because it has the operation set of a list
[00:19]<kjr>a list, the data structure, has certain properties
[00:19]<vufvuzn>the semantics are part of the contract - but no, they're not checked by the language
[00:19]<vufvuzn>an interface is only a syntactic check, an implementor can still fail to provide the required semantics
[00:20]<drygq>vulture: i tried what you said, but something happend what i was already afraid for...
[00:20]<drygq>http://pastebin.ca/119412
[00:20]<drygq>Error 2 Cannot implicitly convert type 'System.Resources.ResourceManager' to 'bool' C:\Documents and Settings\Admin\Bureaublad\ExploreDotNet2005\MultiLang.cs 32 28 ExploreDotNet2005
[00:20]<kjr>vulture: indeed, it's part of the implicit contract
[00:22]<vufvuzn>you are trying to convert a ResourceManager to a boolean value.. why would you do that?
[00:23]<drygq>ahhh, sry i said something wrong..
[00:23]<drygq>i should specify my static method as type ResourceManager
[00:23]<drygq>(i said class, but i ment method)
[00:36]<szgdzzajs>nice, ComoBoxes support having List<string> as data sources
[00:48]<drygq>vulture: ive made my 'public ResourceManager LangSupported()'.. public ;), but i cant access it from my program class/ main
[00:49]<vufvuzn>main2: care to be more specific about what happens & what error messages you might be seeing?
[00:51]<drygq>ok,well -> ive created this method (from which i pasted the signature) in a new class
[00:52]<drygq>now when i try to create an instance of it in my startup-method/object Main(), i just cant find it with intellisense
[00:53]<vufvuzn>a) you don't create instances of methods b) you don't need an instance to invoke a static method..
[00:53]<22vnax>Is there a way to have one constructor call both the base() and the this()...or do I need multiple constructors to accomplish that?
[00:53]<drygq>last was known to me already, but a ...
[00:53]<vufvuzn>you call methods, you don't instantiate them
[00:54]<vufvuzn>you create instances of classes, not instances of methods
[00:54]<drygq>no ok, but it looks like if its a new data type this way
[00:54]<axjwmgyggm>isn't memberwise clone supposed to be supported by everything?
[00:54]<sdnffdxdlld>bbtech: get the constructor to call this() and this() to call base()
[00:54]<vufvuzn>bbtech: no, because calling another ctor in the same class ("this(..)") would cause another base class ctor invokation..
[00:54]<vufvuzn>what smellyhippy said
[00:55]<vufvuzn>main2: I don't understand.
[00:55]<22vnax>ok, thanks :D
[00:56]<drygq>vulture, something looks badly wrong to me..
[00:56]<drygq>public static ResourceManager LangSupported() << this is how the method sig currently looks
[00:56]<vufvuzn>sure..
[00:56]<vufvuzn>and what class is that method defined in?
[00:56]<drygq>this method is in a class called 'MultiLang'
[00:56]<vufvuzn>and what class are you trying to call it from?
[00:57]<vufvuzn>and what namespaces are each of these classes in?
[00:57]<drygq>in the class of my program, where the start object is defined
[00:57]<drygq>both same namespace
[00:57]<vufvuzn>I didn't want a description, I wanted the names
[00:57]<drygq>..
[00:57]<pzrrnrvqt0wr>hello
[00:57]<drygq>ExploreDotNet2005
[00:57]<vufvuzn>main2: and how were you hoping to call it? (what is the line of code you expect/want to compile/run in the ExploreDotNet2005 : Main function?)
[00:57]<drygq>after creating an instance of the MultiLang class
[00:58]<vufvuzn>I told you you didn't need to create an instance..
[00:58]<drygq>MultiLang mLang = new MultiLang()
[00:58]<vufvuzn>you're invoking a static method, there's no need for an instance.
[00:58]<drygq>mLang.LangSupported();
[01:00]<drygq>so im not allowed to create a instance of a class if i want to access its static methods?
[01:00]<vufvuzn>did you read the error message you got?
[01:01]<vufvuzn>the two things (calling static methods & creating instances) are independent - they've nothing to do with one another & never the twain shall meet
[01:03]<drygq>well, after creating an instance of the class
[01:04]<drygq>im not able to access its static method, intellisense does not comeup with it..
[01:06]<kuggys>main do MyNamespace.MyClass.MyStaticMethod();
[01:06]<drygq>doesnt work..
[01:06]<drygq>ahh yeah directly
[01:07]<drygq>it does, but not on a instance.. thats the current 'issue'
[01:09]<kuggys>It's not supposed to.
[01:10]<kuggys>You can have static methods and instance methods both with the same name. That's techinally legal, but really bad style.
[01:11]<drygq>thats called abnormal operator overloading? :P
[01:11]<kuggys>Haha
[01:27]<vufvuzn>main2: did you try writing (the static call from an instance) it & reading the compilation error that occured?
[01:37]<cj2nz>If i'm binding a datagrid to a string array but I want to do the columns manually (So I can change the header) how would I do it?
[01:52]<pzrrnrvqt0wr>wtf is up with people and binding stuff to grids?
[01:52]<pzrrnrvqt0wr>what happened to the good-old times where you did everythign by hand?
[01:56]<cj2nz>Project2501a, Developers learned that doing easy stuff by hand was a waste of their knowledge and time
[01:58]<zndy_wjfnz>I so hate users....
[01:59]<zndy_wjfnz>"Ehm, I think I found a bug in your POS app... If I enter an amount of 1000000 and select as product an item that costs over 1000$, the amount is too large to fit in the total column"
[02:00]<zndy_wjfnz>When do you ever sell 1 million items of > $1000 to one customer? :@







